babylon.gui.js 668 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441
  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, "sliceLeft", {
  6118. /**
  6119. * Gets or sets the left value for slicing (9-patch)
  6120. */
  6121. get: function () {
  6122. return this._sliceLeft;
  6123. },
  6124. set: function (value) {
  6125. if (this._sliceLeft === value) {
  6126. return;
  6127. }
  6128. this._sliceLeft = value;
  6129. this._markAsDirty();
  6130. },
  6131. enumerable: true,
  6132. configurable: true
  6133. });
  6134. Object.defineProperty(Image.prototype, "sliceRight", {
  6135. /**
  6136. * Gets or sets the right value for slicing (9-patch)
  6137. */
  6138. get: function () {
  6139. return this._sliceRight;
  6140. },
  6141. set: function (value) {
  6142. if (this._sliceRight === value) {
  6143. return;
  6144. }
  6145. this._sliceRight = value;
  6146. this._markAsDirty();
  6147. },
  6148. enumerable: true,
  6149. configurable: true
  6150. });
  6151. Object.defineProperty(Image.prototype, "sliceTop", {
  6152. /**
  6153. * Gets or sets the top value for slicing (9-patch)
  6154. */
  6155. get: function () {
  6156. return this._sliceTop;
  6157. },
  6158. set: function (value) {
  6159. if (this._sliceTop === value) {
  6160. return;
  6161. }
  6162. this._sliceTop = value;
  6163. this._markAsDirty();
  6164. },
  6165. enumerable: true,
  6166. configurable: true
  6167. });
  6168. Object.defineProperty(Image.prototype, "sliceBottom", {
  6169. /**
  6170. * Gets or sets the bottom value for slicing (9-patch)
  6171. */
  6172. get: function () {
  6173. return this._sliceBottom;
  6174. },
  6175. set: function (value) {
  6176. if (this._sliceBottom === value) {
  6177. return;
  6178. }
  6179. this._sliceBottom = value;
  6180. this._markAsDirty();
  6181. },
  6182. enumerable: true,
  6183. configurable: true
  6184. });
  6185. Object.defineProperty(Image.prototype, "sourceLeft", {
  6186. /**
  6187. * Gets or sets the left coordinate in the source image
  6188. */
  6189. get: function () {
  6190. return this._sourceLeft;
  6191. },
  6192. set: function (value) {
  6193. if (this._sourceLeft === value) {
  6194. return;
  6195. }
  6196. this._sourceLeft = value;
  6197. this._markAsDirty();
  6198. },
  6199. enumerable: true,
  6200. configurable: true
  6201. });
  6202. Object.defineProperty(Image.prototype, "sourceTop", {
  6203. /**
  6204. * Gets or sets the top coordinate in the source image
  6205. */
  6206. get: function () {
  6207. return this._sourceTop;
  6208. },
  6209. set: function (value) {
  6210. if (this._sourceTop === value) {
  6211. return;
  6212. }
  6213. this._sourceTop = value;
  6214. this._markAsDirty();
  6215. },
  6216. enumerable: true,
  6217. configurable: true
  6218. });
  6219. Object.defineProperty(Image.prototype, "sourceWidth", {
  6220. /**
  6221. * Gets or sets the width to capture in the source image
  6222. */
  6223. get: function () {
  6224. return this._sourceWidth;
  6225. },
  6226. set: function (value) {
  6227. if (this._sourceWidth === value) {
  6228. return;
  6229. }
  6230. this._sourceWidth = value;
  6231. this._markAsDirty();
  6232. },
  6233. enumerable: true,
  6234. configurable: true
  6235. });
  6236. Object.defineProperty(Image.prototype, "sourceHeight", {
  6237. /**
  6238. * Gets or sets the height to capture in the source image
  6239. */
  6240. get: function () {
  6241. return this._sourceHeight;
  6242. },
  6243. set: function (value) {
  6244. if (this._sourceHeight === value) {
  6245. return;
  6246. }
  6247. this._sourceHeight = value;
  6248. this._markAsDirty();
  6249. },
  6250. enumerable: true,
  6251. configurable: true
  6252. });
  6253. Object.defineProperty(Image.prototype, "autoScale", {
  6254. /**
  6255. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6256. * @see http://doc.babylonjs.com/how_to/gui#image
  6257. */
  6258. get: function () {
  6259. return this._autoScale;
  6260. },
  6261. set: function (value) {
  6262. if (this._autoScale === value) {
  6263. return;
  6264. }
  6265. this._autoScale = value;
  6266. if (value && this._loaded) {
  6267. this.synchronizeSizeWithContent();
  6268. }
  6269. },
  6270. enumerable: true,
  6271. configurable: true
  6272. });
  6273. Object.defineProperty(Image.prototype, "stretch", {
  6274. /** Gets or sets the streching mode used by the image */
  6275. get: function () {
  6276. return this._stretch;
  6277. },
  6278. set: function (value) {
  6279. if (this._stretch === value) {
  6280. return;
  6281. }
  6282. this._stretch = value;
  6283. this._markAsDirty();
  6284. },
  6285. enumerable: true,
  6286. configurable: true
  6287. });
  6288. Object.defineProperty(Image.prototype, "domImage", {
  6289. get: function () {
  6290. return this._domImage;
  6291. },
  6292. /**
  6293. * Gets or sets the internal DOM image used to render the control
  6294. */
  6295. set: function (value) {
  6296. var _this = this;
  6297. this._domImage = value;
  6298. this._loaded = false;
  6299. if (this._domImage.width) {
  6300. this._onImageLoaded();
  6301. }
  6302. else {
  6303. this._domImage.onload = function () {
  6304. _this._onImageLoaded();
  6305. };
  6306. }
  6307. },
  6308. enumerable: true,
  6309. configurable: true
  6310. });
  6311. Image.prototype._onImageLoaded = function () {
  6312. this._imageWidth = this._domImage.width;
  6313. this._imageHeight = this._domImage.height;
  6314. this._loaded = true;
  6315. if (this._populateNinePatchSlicesFromImage) {
  6316. this._extractNinePatchSliceDataFromImage();
  6317. }
  6318. if (this._autoScale) {
  6319. this.synchronizeSizeWithContent();
  6320. }
  6321. this.onImageLoadedObservable.notifyObservers(this);
  6322. this._markAsDirty();
  6323. };
  6324. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6325. if (!Image._WorkingCanvas) {
  6326. Image._WorkingCanvas = document.createElement('canvas');
  6327. }
  6328. var canvas = Image._WorkingCanvas;
  6329. var context = canvas.getContext('2d');
  6330. var width = this._domImage.width;
  6331. var height = this._domImage.height;
  6332. canvas.width = width;
  6333. canvas.height = height;
  6334. context.drawImage(this._domImage, 0, 0, width, height);
  6335. var imageData = context.getImageData(0, 0, width, height);
  6336. // Left and right
  6337. this._sliceLeft = -1;
  6338. this._sliceRight = -1;
  6339. for (var x = 0; x < width; x++) {
  6340. var alpha = imageData.data[x * 4 + 3];
  6341. if (alpha > 127 && this._sliceLeft === -1) {
  6342. this._sliceLeft = x;
  6343. continue;
  6344. }
  6345. if (alpha < 127 && this._sliceLeft > -1) {
  6346. this._sliceRight = x;
  6347. break;
  6348. }
  6349. }
  6350. // top and bottom
  6351. this._sliceTop = -1;
  6352. this._sliceBottom = -1;
  6353. for (var y = 0; y < height; y++) {
  6354. var alpha = imageData.data[y * width * 4 + 3];
  6355. if (alpha > 127 && this._sliceTop === -1) {
  6356. this._sliceTop = y;
  6357. continue;
  6358. }
  6359. if (alpha < 127 && this._sliceTop > -1) {
  6360. this._sliceBottom = y;
  6361. break;
  6362. }
  6363. }
  6364. };
  6365. Object.defineProperty(Image.prototype, "source", {
  6366. /**
  6367. * Gets or sets image source url
  6368. */
  6369. set: function (value) {
  6370. var _this = this;
  6371. if (this._source === value) {
  6372. return;
  6373. }
  6374. this._loaded = false;
  6375. this._source = value;
  6376. this._domImage = document.createElement("img");
  6377. this._domImage.onload = function () {
  6378. _this._onImageLoaded();
  6379. };
  6380. if (value) {
  6381. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6382. this._domImage.src = value;
  6383. }
  6384. },
  6385. enumerable: true,
  6386. configurable: true
  6387. });
  6388. Object.defineProperty(Image.prototype, "cellWidth", {
  6389. /**
  6390. * Gets or sets the cell width to use when animation sheet is enabled
  6391. * @see http://doc.babylonjs.com/how_to/gui#image
  6392. */
  6393. get: function () {
  6394. return this._cellWidth;
  6395. },
  6396. set: function (value) {
  6397. if (this._cellWidth === value) {
  6398. return;
  6399. }
  6400. this._cellWidth = value;
  6401. this._markAsDirty();
  6402. },
  6403. enumerable: true,
  6404. configurable: true
  6405. });
  6406. Object.defineProperty(Image.prototype, "cellHeight", {
  6407. /**
  6408. * Gets or sets the cell height to use when animation sheet is enabled
  6409. * @see http://doc.babylonjs.com/how_to/gui#image
  6410. */
  6411. get: function () {
  6412. return this._cellHeight;
  6413. },
  6414. set: function (value) {
  6415. if (this._cellHeight === value) {
  6416. return;
  6417. }
  6418. this._cellHeight = value;
  6419. this._markAsDirty();
  6420. },
  6421. enumerable: true,
  6422. configurable: true
  6423. });
  6424. Object.defineProperty(Image.prototype, "cellId", {
  6425. /**
  6426. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6427. * @see http://doc.babylonjs.com/how_to/gui#image
  6428. */
  6429. get: function () {
  6430. return this._cellId;
  6431. },
  6432. set: function (value) {
  6433. if (this._cellId === value) {
  6434. return;
  6435. }
  6436. this._cellId = value;
  6437. this._markAsDirty();
  6438. },
  6439. enumerable: true,
  6440. configurable: true
  6441. });
  6442. Image.prototype._getTypeName = function () {
  6443. return "Image";
  6444. };
  6445. /** Force the control to synchronize with its content */
  6446. Image.prototype.synchronizeSizeWithContent = function () {
  6447. if (!this._loaded) {
  6448. return;
  6449. }
  6450. this.width = this._domImage.width + "px";
  6451. this.height = this._domImage.height + "px";
  6452. };
  6453. Image.prototype._processMeasures = function (parentMeasure, context) {
  6454. if (this._loaded) {
  6455. switch (this._stretch) {
  6456. case Image.STRETCH_NONE:
  6457. break;
  6458. case Image.STRETCH_FILL:
  6459. break;
  6460. case Image.STRETCH_UNIFORM:
  6461. break;
  6462. case Image.STRETCH_EXTEND:
  6463. if (this._autoScale) {
  6464. this.synchronizeSizeWithContent();
  6465. }
  6466. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6467. this.parent.adaptWidthToChildren = true;
  6468. this.parent.adaptHeightToChildren = true;
  6469. }
  6470. break;
  6471. }
  6472. }
  6473. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6474. };
  6475. Image.prototype._draw = function (context) {
  6476. context.save();
  6477. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6478. context.shadowColor = this.shadowColor;
  6479. context.shadowBlur = this.shadowBlur;
  6480. context.shadowOffsetX = this.shadowOffsetX;
  6481. context.shadowOffsetY = this.shadowOffsetY;
  6482. }
  6483. var x, y, width, height;
  6484. if (this.cellId == -1) {
  6485. x = this._sourceLeft;
  6486. y = this._sourceTop;
  6487. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6488. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6489. }
  6490. else {
  6491. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6492. var column = (this.cellId / rowCount) >> 0;
  6493. var row = this.cellId % rowCount;
  6494. x = this.cellWidth * row;
  6495. y = this.cellHeight * column;
  6496. width = this.cellWidth;
  6497. height = this.cellHeight;
  6498. }
  6499. this._applyStates(context);
  6500. if (this._loaded) {
  6501. switch (this._stretch) {
  6502. case Image.STRETCH_NONE:
  6503. context.drawImage(this._domImage, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6504. break;
  6505. case Image.STRETCH_FILL:
  6506. context.drawImage(this._domImage, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6507. break;
  6508. case Image.STRETCH_UNIFORM:
  6509. var hRatio = this._currentMeasure.width / width;
  6510. var vRatio = this._currentMeasure.height / height;
  6511. var ratio = Math.min(hRatio, vRatio);
  6512. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6513. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6514. context.drawImage(this._domImage, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6515. break;
  6516. case Image.STRETCH_EXTEND:
  6517. context.drawImage(this._domImage, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6518. break;
  6519. case Image.STRETCH_NINE_PATCH:
  6520. this._renderNinePatch(context);
  6521. break;
  6522. }
  6523. }
  6524. context.restore();
  6525. };
  6526. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6527. context.drawImage(this._domImage, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6528. };
  6529. Image.prototype._renderNinePatch = function (context) {
  6530. var height = this._imageHeight;
  6531. var leftWidth = this._sliceLeft;
  6532. var topHeight = this._sliceTop;
  6533. var bottomHeight = this._imageHeight - this._sliceBottom;
  6534. var rightWidth = this._imageWidth - this._sliceRight;
  6535. var left = 0;
  6536. var top = 0;
  6537. if (this._populateNinePatchSlicesFromImage) {
  6538. left = 1;
  6539. top = 1;
  6540. height -= 2;
  6541. leftWidth -= 1;
  6542. topHeight -= 1;
  6543. bottomHeight -= 1;
  6544. rightWidth -= 1;
  6545. }
  6546. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6547. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6548. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6549. // Corners
  6550. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6551. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6552. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6553. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6554. // Center
  6555. context.drawImage(this._domImage, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6556. // Borders
  6557. context.drawImage(this._domImage, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6558. context.drawImage(this._domImage, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6559. context.drawImage(this._domImage, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6560. context.drawImage(this._domImage, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6561. };
  6562. Image.prototype.dispose = function () {
  6563. _super.prototype.dispose.call(this);
  6564. this.onImageLoadedObservable.clear();
  6565. };
  6566. Image._WorkingCanvas = null;
  6567. // Static
  6568. /** STRETCH_NONE */
  6569. Image.STRETCH_NONE = 0;
  6570. /** STRETCH_FILL */
  6571. Image.STRETCH_FILL = 1;
  6572. /** STRETCH_UNIFORM */
  6573. Image.STRETCH_UNIFORM = 2;
  6574. /** STRETCH_EXTEND */
  6575. Image.STRETCH_EXTEND = 3;
  6576. /** NINE_PATCH */
  6577. Image.STRETCH_NINE_PATCH = 4;
  6578. return Image;
  6579. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6580. /***/ }),
  6581. /***/ "./2D/controls/index.ts":
  6582. /*!******************************!*\
  6583. !*** ./2D/controls/index.ts ***!
  6584. \******************************/
  6585. /*! 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 */
  6586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6587. "use strict";
  6588. __webpack_require__.r(__webpack_exports__);
  6589. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6591. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6593. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6595. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6597. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6599. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6601. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6603. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6605. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6607. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6609. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6611. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6613. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6615. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6617. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6623. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6625. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6628. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6631. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6633. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6635. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6637. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6639. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6641. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_23__["name"]; });
  6643. /***/ }),
  6644. /***/ "./2D/controls/inputPassword.ts":
  6645. /*!**************************************!*\
  6646. !*** ./2D/controls/inputPassword.ts ***!
  6647. \**************************************/
  6648. /*! exports provided: InputPassword */
  6649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6650. "use strict";
  6651. __webpack_require__.r(__webpack_exports__);
  6652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6653. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6654. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6655. /**
  6656. * Class used to create a password control
  6657. */
  6658. var InputPassword = /** @class */ (function (_super) {
  6659. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6660. function InputPassword() {
  6661. return _super !== null && _super.apply(this, arguments) || this;
  6662. }
  6663. InputPassword.prototype._beforeRenderText = function (text) {
  6664. var txt = "";
  6665. for (var i = 0; i < text.length; i++) {
  6666. txt += "\u2022";
  6667. }
  6668. return txt;
  6669. };
  6670. return InputPassword;
  6671. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6672. /***/ }),
  6673. /***/ "./2D/controls/inputText.ts":
  6674. /*!**********************************!*\
  6675. !*** ./2D/controls/inputText.ts ***!
  6676. \**********************************/
  6677. /*! exports provided: InputText */
  6678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6679. "use strict";
  6680. __webpack_require__.r(__webpack_exports__);
  6681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6683. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6684. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6685. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6686. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6687. /**
  6688. * Class used to create input text control
  6689. */
  6690. var InputText = /** @class */ (function (_super) {
  6691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6692. /**
  6693. * Creates a new InputText
  6694. * @param name defines the control name
  6695. * @param text defines the text of the control
  6696. */
  6697. function InputText(name, text) {
  6698. if (text === void 0) { text = ""; }
  6699. var _this = _super.call(this, name) || this;
  6700. _this.name = name;
  6701. _this._text = "";
  6702. _this._placeholderText = "";
  6703. _this._background = "#222222";
  6704. _this._focusedBackground = "#000000";
  6705. _this._focusedColor = "white";
  6706. _this._placeholderColor = "gray";
  6707. _this._thickness = 1;
  6708. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6709. _this._autoStretchWidth = true;
  6710. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6711. _this._isFocused = false;
  6712. _this._blinkIsEven = false;
  6713. _this._cursorOffset = 0;
  6714. _this._deadKey = false;
  6715. _this._addKey = true;
  6716. _this._currentKey = "";
  6717. _this._isTextHighlightOn = false;
  6718. _this._textHighlightColor = "#d5e0ff";
  6719. _this._highligherOpacity = 0.4;
  6720. _this._highlightedText = "";
  6721. _this._startHighlightIndex = 0;
  6722. _this._endHighlightIndex = 0;
  6723. _this._cursorIndex = -1;
  6724. _this._onFocusSelectAll = false;
  6725. _this._isPointerDown = false;
  6726. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6727. _this.promptMessage = "Please enter text:";
  6728. /** Observable raised when the text changes */
  6729. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6730. /** Observable raised just before an entered character is to be added */
  6731. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6732. /** Observable raised when the control gets the focus */
  6733. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6734. /** Observable raised when the control loses the focus */
  6735. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6736. /**Observable raised when the text is highlighted */
  6737. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6738. /**Observable raised when copy event is triggered */
  6739. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6740. /** Observable raised when cut event is triggered */
  6741. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6742. /** Observable raised when paste event is triggered */
  6743. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6744. /** Observable raised when a key event was processed */
  6745. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6746. _this.text = text;
  6747. _this.isPointerBlocker = true;
  6748. return _this;
  6749. }
  6750. Object.defineProperty(InputText.prototype, "maxWidth", {
  6751. /** Gets or sets the maximum width allowed by the control */
  6752. get: function () {
  6753. return this._maxWidth.toString(this._host);
  6754. },
  6755. set: function (value) {
  6756. if (this._maxWidth.toString(this._host) === value) {
  6757. return;
  6758. }
  6759. if (this._maxWidth.fromString(value)) {
  6760. this._markAsDirty();
  6761. }
  6762. },
  6763. enumerable: true,
  6764. configurable: true
  6765. });
  6766. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6767. /** Gets the maximum width allowed by the control in pixels */
  6768. get: function () {
  6769. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6770. },
  6771. enumerable: true,
  6772. configurable: true
  6773. });
  6774. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6775. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6776. get: function () {
  6777. return this._highligherOpacity;
  6778. },
  6779. set: function (value) {
  6780. if (this._highligherOpacity === value) {
  6781. return;
  6782. }
  6783. this._highligherOpacity = value;
  6784. this._markAsDirty();
  6785. },
  6786. enumerable: true,
  6787. configurable: true
  6788. });
  6789. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6790. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6791. get: function () {
  6792. return this._onFocusSelectAll;
  6793. },
  6794. set: function (value) {
  6795. if (this._onFocusSelectAll === value) {
  6796. return;
  6797. }
  6798. this._onFocusSelectAll = value;
  6799. this._markAsDirty();
  6800. },
  6801. enumerable: true,
  6802. configurable: true
  6803. });
  6804. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6805. /** Gets or sets the text hightlight color */
  6806. get: function () {
  6807. return this._textHighlightColor;
  6808. },
  6809. set: function (value) {
  6810. if (this._textHighlightColor === value) {
  6811. return;
  6812. }
  6813. this._textHighlightColor = value;
  6814. this._markAsDirty();
  6815. },
  6816. enumerable: true,
  6817. configurable: true
  6818. });
  6819. Object.defineProperty(InputText.prototype, "margin", {
  6820. /** Gets or sets control margin */
  6821. get: function () {
  6822. return this._margin.toString(this._host);
  6823. },
  6824. set: function (value) {
  6825. if (this._margin.toString(this._host) === value) {
  6826. return;
  6827. }
  6828. if (this._margin.fromString(value)) {
  6829. this._markAsDirty();
  6830. }
  6831. },
  6832. enumerable: true,
  6833. configurable: true
  6834. });
  6835. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6836. /** Gets control margin in pixels */
  6837. get: function () {
  6838. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6839. },
  6840. enumerable: true,
  6841. configurable: true
  6842. });
  6843. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6844. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6845. get: function () {
  6846. return this._autoStretchWidth;
  6847. },
  6848. set: function (value) {
  6849. if (this._autoStretchWidth === value) {
  6850. return;
  6851. }
  6852. this._autoStretchWidth = value;
  6853. this._markAsDirty();
  6854. },
  6855. enumerable: true,
  6856. configurable: true
  6857. });
  6858. Object.defineProperty(InputText.prototype, "thickness", {
  6859. /** Gets or sets border thickness */
  6860. get: function () {
  6861. return this._thickness;
  6862. },
  6863. set: function (value) {
  6864. if (this._thickness === value) {
  6865. return;
  6866. }
  6867. this._thickness = value;
  6868. this._markAsDirty();
  6869. },
  6870. enumerable: true,
  6871. configurable: true
  6872. });
  6873. Object.defineProperty(InputText.prototype, "focusedBackground", {
  6874. /** Gets or sets the background color when focused */
  6875. get: function () {
  6876. return this._focusedBackground;
  6877. },
  6878. set: function (value) {
  6879. if (this._focusedBackground === value) {
  6880. return;
  6881. }
  6882. this._focusedBackground = value;
  6883. this._markAsDirty();
  6884. },
  6885. enumerable: true,
  6886. configurable: true
  6887. });
  6888. Object.defineProperty(InputText.prototype, "focusedColor", {
  6889. /** Gets or sets the background color when focused */
  6890. get: function () {
  6891. return this._focusedColor;
  6892. },
  6893. set: function (value) {
  6894. if (this._focusedColor === value) {
  6895. return;
  6896. }
  6897. this._focusedColor = value;
  6898. this._markAsDirty();
  6899. },
  6900. enumerable: true,
  6901. configurable: true
  6902. });
  6903. Object.defineProperty(InputText.prototype, "background", {
  6904. /** Gets or sets the background color */
  6905. get: function () {
  6906. return this._background;
  6907. },
  6908. set: function (value) {
  6909. if (this._background === value) {
  6910. return;
  6911. }
  6912. this._background = value;
  6913. this._markAsDirty();
  6914. },
  6915. enumerable: true,
  6916. configurable: true
  6917. });
  6918. Object.defineProperty(InputText.prototype, "placeholderColor", {
  6919. /** Gets or sets the placeholder color */
  6920. get: function () {
  6921. return this._placeholderColor;
  6922. },
  6923. set: function (value) {
  6924. if (this._placeholderColor === value) {
  6925. return;
  6926. }
  6927. this._placeholderColor = value;
  6928. this._markAsDirty();
  6929. },
  6930. enumerable: true,
  6931. configurable: true
  6932. });
  6933. Object.defineProperty(InputText.prototype, "placeholderText", {
  6934. /** Gets or sets the text displayed when the control is empty */
  6935. get: function () {
  6936. return this._placeholderText;
  6937. },
  6938. set: function (value) {
  6939. if (this._placeholderText === value) {
  6940. return;
  6941. }
  6942. this._placeholderText = value;
  6943. this._markAsDirty();
  6944. },
  6945. enumerable: true,
  6946. configurable: true
  6947. });
  6948. Object.defineProperty(InputText.prototype, "deadKey", {
  6949. /** Gets or sets the dead key flag */
  6950. get: function () {
  6951. return this._deadKey;
  6952. },
  6953. set: function (flag) {
  6954. this._deadKey = flag;
  6955. },
  6956. enumerable: true,
  6957. configurable: true
  6958. });
  6959. Object.defineProperty(InputText.prototype, "highlightedText", {
  6960. /** Gets or sets the highlight text */
  6961. get: function () {
  6962. return this._highlightedText;
  6963. },
  6964. set: function (text) {
  6965. if (this._highlightedText === text) {
  6966. return;
  6967. }
  6968. this._highlightedText = text;
  6969. this._markAsDirty();
  6970. },
  6971. enumerable: true,
  6972. configurable: true
  6973. });
  6974. Object.defineProperty(InputText.prototype, "addKey", {
  6975. /** Gets or sets if the current key should be added */
  6976. get: function () {
  6977. return this._addKey;
  6978. },
  6979. set: function (flag) {
  6980. this._addKey = flag;
  6981. },
  6982. enumerable: true,
  6983. configurable: true
  6984. });
  6985. Object.defineProperty(InputText.prototype, "currentKey", {
  6986. /** Gets or sets the value of the current key being entered */
  6987. get: function () {
  6988. return this._currentKey;
  6989. },
  6990. set: function (key) {
  6991. this._currentKey = key;
  6992. },
  6993. enumerable: true,
  6994. configurable: true
  6995. });
  6996. Object.defineProperty(InputText.prototype, "text", {
  6997. /** Gets or sets the text displayed in the control */
  6998. get: function () {
  6999. return this._text;
  7000. },
  7001. set: function (value) {
  7002. var valueAsString = value.toString(); // Forcing convertion
  7003. if (this._text === valueAsString) {
  7004. return;
  7005. }
  7006. this._text = valueAsString;
  7007. this._markAsDirty();
  7008. this.onTextChangedObservable.notifyObservers(this);
  7009. },
  7010. enumerable: true,
  7011. configurable: true
  7012. });
  7013. Object.defineProperty(InputText.prototype, "width", {
  7014. /** Gets or sets control width */
  7015. get: function () {
  7016. return this._width.toString(this._host);
  7017. },
  7018. set: function (value) {
  7019. if (this._width.toString(this._host) === value) {
  7020. return;
  7021. }
  7022. if (this._width.fromString(value)) {
  7023. this._markAsDirty();
  7024. }
  7025. this.autoStretchWidth = false;
  7026. },
  7027. enumerable: true,
  7028. configurable: true
  7029. });
  7030. /** @hidden */
  7031. InputText.prototype.onBlur = function () {
  7032. this._isFocused = false;
  7033. this._scrollLeft = null;
  7034. this._cursorOffset = 0;
  7035. clearTimeout(this._blinkTimeout);
  7036. this._markAsDirty();
  7037. this.onBlurObservable.notifyObservers(this);
  7038. this._host.unRegisterClipboardEvents();
  7039. if (this._onClipboardObserver) {
  7040. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7041. }
  7042. var scene = this._host.getScene();
  7043. if (this._onPointerDblTapObserver && scene) {
  7044. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7045. }
  7046. };
  7047. /** @hidden */
  7048. InputText.prototype.onFocus = function () {
  7049. var _this = this;
  7050. if (!this._isEnabled) {
  7051. return;
  7052. }
  7053. this._scrollLeft = null;
  7054. this._isFocused = true;
  7055. this._blinkIsEven = false;
  7056. this._cursorOffset = 0;
  7057. this._markAsDirty();
  7058. this.onFocusObservable.notifyObservers(this);
  7059. if (navigator.userAgent.indexOf("Mobile") !== -1) {
  7060. var value = prompt(this.promptMessage);
  7061. if (value !== null) {
  7062. this.text = value;
  7063. }
  7064. this._host.focusedControl = null;
  7065. return;
  7066. }
  7067. this._host.registerClipboardEvents();
  7068. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7069. // process clipboard event, can be configured.
  7070. switch (clipboardInfo.type) {
  7071. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7072. _this._onCopyText(clipboardInfo.event);
  7073. _this.onTextCopyObservable.notifyObservers(_this);
  7074. break;
  7075. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7076. _this._onCutText(clipboardInfo.event);
  7077. _this.onTextCutObservable.notifyObservers(_this);
  7078. break;
  7079. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7080. _this._onPasteText(clipboardInfo.event);
  7081. _this.onTextPasteObservable.notifyObservers(_this);
  7082. break;
  7083. default: return;
  7084. }
  7085. });
  7086. var scene = this._host.getScene();
  7087. if (scene) {
  7088. //register the pointer double tap event
  7089. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7090. if (!_this._isFocused) {
  7091. return;
  7092. }
  7093. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7094. _this._processDblClick(pointerInfo);
  7095. }
  7096. });
  7097. }
  7098. if (this._onFocusSelectAll) {
  7099. this._selectAllText();
  7100. }
  7101. };
  7102. InputText.prototype._getTypeName = function () {
  7103. return "InputText";
  7104. };
  7105. /**
  7106. * Function called to get the list of controls that should not steal the focus from this control
  7107. * @returns an array of controls
  7108. */
  7109. InputText.prototype.keepsFocusWith = function () {
  7110. if (!this._connectedVirtualKeyboard) {
  7111. return null;
  7112. }
  7113. return [this._connectedVirtualKeyboard];
  7114. };
  7115. /** @hidden */
  7116. InputText.prototype.processKey = function (keyCode, key, evt) {
  7117. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7118. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7119. return;
  7120. }
  7121. //select all
  7122. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7123. this._selectAllText();
  7124. evt.preventDefault();
  7125. return;
  7126. }
  7127. // Specific cases
  7128. switch (keyCode) {
  7129. case 32: //SPACE
  7130. key = " "; //ie11 key for space is "Spacebar"
  7131. break;
  7132. case 191: //SLASH
  7133. if (evt) {
  7134. evt.preventDefault();
  7135. }
  7136. break;
  7137. case 8: // BACKSPACE
  7138. if (this._text && this._text.length > 0) {
  7139. //delete the highlighted text
  7140. if (this._isTextHighlightOn) {
  7141. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7142. this._isTextHighlightOn = false;
  7143. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7144. this._blinkIsEven = false;
  7145. if (evt) {
  7146. evt.preventDefault();
  7147. }
  7148. return;
  7149. }
  7150. //delete single character
  7151. if (this._cursorOffset === 0) {
  7152. this.text = this._text.substr(0, this._text.length - 1);
  7153. }
  7154. else {
  7155. var deletePosition = this._text.length - this._cursorOffset;
  7156. if (deletePosition > 0) {
  7157. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7158. }
  7159. }
  7160. }
  7161. if (evt) {
  7162. evt.preventDefault();
  7163. }
  7164. return;
  7165. case 46: // DELETE
  7166. if (this._isTextHighlightOn) {
  7167. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7168. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7169. while (decrementor > 0 && this._cursorOffset > 0) {
  7170. this._cursorOffset--;
  7171. }
  7172. this._isTextHighlightOn = false;
  7173. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7174. if (evt) {
  7175. evt.preventDefault();
  7176. }
  7177. return;
  7178. }
  7179. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7180. var deletePosition = this._text.length - this._cursorOffset;
  7181. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7182. this._cursorOffset--;
  7183. }
  7184. if (evt) {
  7185. evt.preventDefault();
  7186. }
  7187. return;
  7188. case 13: // RETURN
  7189. this._host.focusedControl = null;
  7190. this._isTextHighlightOn = false;
  7191. return;
  7192. case 35: // END
  7193. this._cursorOffset = 0;
  7194. this._blinkIsEven = false;
  7195. this._isTextHighlightOn = false;
  7196. this._markAsDirty();
  7197. return;
  7198. case 36: // HOME
  7199. this._cursorOffset = this._text.length;
  7200. this._blinkIsEven = false;
  7201. this._isTextHighlightOn = false;
  7202. this._markAsDirty();
  7203. return;
  7204. case 37: // LEFT
  7205. this._cursorOffset++;
  7206. if (this._cursorOffset > this._text.length) {
  7207. this._cursorOffset = this._text.length;
  7208. }
  7209. if (evt && evt.shiftKey) {
  7210. // update the cursor
  7211. this._blinkIsEven = false;
  7212. // shift + ctrl/cmd + <-
  7213. if (evt.ctrlKey || evt.metaKey) {
  7214. if (!this._isTextHighlightOn) {
  7215. if (this._text.length === this._cursorOffset) {
  7216. return;
  7217. }
  7218. else {
  7219. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7220. }
  7221. }
  7222. this._startHighlightIndex = 0;
  7223. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7224. this._cursorOffset = this._text.length;
  7225. this._isTextHighlightOn = true;
  7226. this._markAsDirty();
  7227. return;
  7228. }
  7229. //store the starting point
  7230. if (!this._isTextHighlightOn) {
  7231. this._isTextHighlightOn = true;
  7232. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7233. }
  7234. //if text is already highlighted
  7235. else if (this._cursorIndex === -1) {
  7236. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7237. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7238. }
  7239. //set the highlight indexes
  7240. if (this._cursorIndex < this._cursorOffset) {
  7241. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7242. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7243. }
  7244. else if (this._cursorIndex > this._cursorOffset) {
  7245. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7246. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7247. }
  7248. else {
  7249. this._isTextHighlightOn = false;
  7250. }
  7251. this._markAsDirty();
  7252. return;
  7253. }
  7254. if (this._isTextHighlightOn) {
  7255. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7256. this._isTextHighlightOn = false;
  7257. }
  7258. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7259. this._cursorOffset = this.text.length;
  7260. evt.preventDefault();
  7261. }
  7262. this._blinkIsEven = false;
  7263. this._isTextHighlightOn = false;
  7264. this._cursorIndex = -1;
  7265. this._markAsDirty();
  7266. return;
  7267. case 39: // RIGHT
  7268. this._cursorOffset--;
  7269. if (this._cursorOffset < 0) {
  7270. this._cursorOffset = 0;
  7271. }
  7272. if (evt && evt.shiftKey) {
  7273. //update the cursor
  7274. this._blinkIsEven = false;
  7275. //shift + ctrl/cmd + ->
  7276. if (evt.ctrlKey || evt.metaKey) {
  7277. if (!this._isTextHighlightOn) {
  7278. if (this._cursorOffset === 0) {
  7279. return;
  7280. }
  7281. else {
  7282. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7283. }
  7284. }
  7285. this._endHighlightIndex = this._text.length;
  7286. this._isTextHighlightOn = true;
  7287. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7288. this._cursorOffset = 0;
  7289. this._markAsDirty();
  7290. return;
  7291. }
  7292. if (!this._isTextHighlightOn) {
  7293. this._isTextHighlightOn = true;
  7294. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7295. }
  7296. //if text is already highlighted
  7297. else if (this._cursorIndex === -1) {
  7298. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7299. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7300. }
  7301. //set the highlight indexes
  7302. if (this._cursorIndex < this._cursorOffset) {
  7303. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7304. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7305. }
  7306. else if (this._cursorIndex > this._cursorOffset) {
  7307. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7308. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7309. }
  7310. else {
  7311. this._isTextHighlightOn = false;
  7312. }
  7313. this._markAsDirty();
  7314. return;
  7315. }
  7316. if (this._isTextHighlightOn) {
  7317. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7318. this._isTextHighlightOn = false;
  7319. }
  7320. //ctr + ->
  7321. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7322. this._cursorOffset = 0;
  7323. evt.preventDefault();
  7324. }
  7325. this._blinkIsEven = false;
  7326. this._isTextHighlightOn = false;
  7327. this._cursorIndex = -1;
  7328. this._markAsDirty();
  7329. return;
  7330. case 222: // Dead
  7331. if (evt) {
  7332. evt.preventDefault();
  7333. }
  7334. this._cursorIndex = -1;
  7335. this.deadKey = true;
  7336. break;
  7337. }
  7338. // Printable characters
  7339. if (key &&
  7340. ((keyCode === -1) || // Direct access
  7341. (keyCode === 32) || // Space
  7342. (keyCode > 47 && keyCode < 64) || // Numbers
  7343. (keyCode > 64 && keyCode < 91) || // Letters
  7344. (keyCode > 159 && keyCode < 193) || // Special characters
  7345. (keyCode > 218 && keyCode < 223) || // Special characters
  7346. (keyCode > 95 && keyCode < 112))) { // Numpad
  7347. this._currentKey = key;
  7348. this.onBeforeKeyAddObservable.notifyObservers(this);
  7349. key = this._currentKey;
  7350. if (this._addKey) {
  7351. if (this._isTextHighlightOn) {
  7352. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7353. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7354. this._isTextHighlightOn = false;
  7355. this._blinkIsEven = false;
  7356. this._markAsDirty();
  7357. }
  7358. else if (this._cursorOffset === 0) {
  7359. this.text += key;
  7360. }
  7361. else {
  7362. var insertPosition = this._text.length - this._cursorOffset;
  7363. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7364. }
  7365. }
  7366. }
  7367. };
  7368. /** @hidden */
  7369. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7370. //update the cursor
  7371. this._blinkIsEven = false;
  7372. if (this._cursorIndex === -1) {
  7373. this._cursorIndex = offset;
  7374. }
  7375. else {
  7376. if (this._cursorIndex < this._cursorOffset) {
  7377. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7378. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7379. }
  7380. else if (this._cursorIndex > this._cursorOffset) {
  7381. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7382. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7383. }
  7384. else {
  7385. this._isTextHighlightOn = false;
  7386. this._markAsDirty();
  7387. return;
  7388. }
  7389. }
  7390. this._isTextHighlightOn = true;
  7391. this._markAsDirty();
  7392. };
  7393. /** @hidden */
  7394. InputText.prototype._processDblClick = function (evt) {
  7395. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7396. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7397. this._endHighlightIndex = this._startHighlightIndex;
  7398. var rWord = /\w+/g, moveLeft, moveRight;
  7399. do {
  7400. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7401. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7402. } while (moveLeft || moveRight);
  7403. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7404. this.onTextHighlightObservable.notifyObservers(this);
  7405. this._isTextHighlightOn = true;
  7406. this._clickedCoordinate = null;
  7407. this._blinkIsEven = true;
  7408. this._cursorIndex = -1;
  7409. this._markAsDirty();
  7410. };
  7411. /** @hidden */
  7412. InputText.prototype._selectAllText = function () {
  7413. this._blinkIsEven = true;
  7414. this._isTextHighlightOn = true;
  7415. this._startHighlightIndex = 0;
  7416. this._endHighlightIndex = this._text.length;
  7417. this._cursorOffset = this._text.length;
  7418. this._cursorIndex = -1;
  7419. this._markAsDirty();
  7420. };
  7421. /**
  7422. * Handles the keyboard event
  7423. * @param evt Defines the KeyboardEvent
  7424. */
  7425. InputText.prototype.processKeyboard = function (evt) {
  7426. // process pressed key
  7427. this.processKey(evt.keyCode, evt.key, evt);
  7428. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7429. };
  7430. /** @hidden */
  7431. InputText.prototype._onCopyText = function (ev) {
  7432. this._isTextHighlightOn = false;
  7433. //when write permission to clipbaord data is denied
  7434. try {
  7435. ev.clipboardData.setData("text/plain", this._highlightedText);
  7436. }
  7437. catch (_a) { } //pass
  7438. this._host.clipboardData = this._highlightedText;
  7439. };
  7440. /** @hidden */
  7441. InputText.prototype._onCutText = function (ev) {
  7442. if (!this._highlightedText) {
  7443. return;
  7444. }
  7445. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7446. this._isTextHighlightOn = false;
  7447. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7448. //when write permission to clipbaord data is denied
  7449. try {
  7450. ev.clipboardData.setData("text/plain", this._highlightedText);
  7451. }
  7452. catch (_a) { } //pass
  7453. this._host.clipboardData = this._highlightedText;
  7454. this._highlightedText = "";
  7455. };
  7456. /** @hidden */
  7457. InputText.prototype._onPasteText = function (ev) {
  7458. var data = "";
  7459. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7460. data = ev.clipboardData.getData("text/plain");
  7461. }
  7462. else {
  7463. //get the cached data; returns blank string by default
  7464. data = this._host.clipboardData;
  7465. }
  7466. var insertPosition = this._text.length - this._cursorOffset;
  7467. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7468. };
  7469. InputText.prototype._draw = function (context) {
  7470. var _this = this;
  7471. context.save();
  7472. this._applyStates(context);
  7473. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7474. context.shadowColor = this.shadowColor;
  7475. context.shadowBlur = this.shadowBlur;
  7476. context.shadowOffsetX = this.shadowOffsetX;
  7477. context.shadowOffsetY = this.shadowOffsetY;
  7478. }
  7479. // Background
  7480. if (this._isFocused) {
  7481. if (this._focusedBackground) {
  7482. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7483. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7484. }
  7485. }
  7486. else if (this._background) {
  7487. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7488. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7489. }
  7490. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7491. context.shadowBlur = 0;
  7492. context.shadowOffsetX = 0;
  7493. context.shadowOffsetY = 0;
  7494. }
  7495. if (!this._fontOffset) {
  7496. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7497. }
  7498. // Text
  7499. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7500. if (this.color) {
  7501. context.fillStyle = this.color;
  7502. }
  7503. var text = this._beforeRenderText(this._text);
  7504. if (!this._isFocused && !this._text && this._placeholderText) {
  7505. text = this._placeholderText;
  7506. if (this._placeholderColor) {
  7507. context.fillStyle = this._placeholderColor;
  7508. }
  7509. }
  7510. this._textWidth = context.measureText(text).width;
  7511. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7512. if (this._autoStretchWidth) {
  7513. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7514. }
  7515. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7516. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7517. context.save();
  7518. context.beginPath();
  7519. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7520. context.clip();
  7521. if (this._isFocused && this._textWidth > availableWidth) {
  7522. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7523. if (!this._scrollLeft) {
  7524. this._scrollLeft = textLeft;
  7525. }
  7526. }
  7527. else {
  7528. this._scrollLeft = clipTextLeft;
  7529. }
  7530. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7531. // Cursor
  7532. if (this._isFocused) {
  7533. // Need to move cursor
  7534. if (this._clickedCoordinate) {
  7535. var rightPosition = this._scrollLeft + this._textWidth;
  7536. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7537. var currentSize = 0;
  7538. this._cursorOffset = 0;
  7539. var previousDist = 0;
  7540. do {
  7541. if (this._cursorOffset) {
  7542. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7543. }
  7544. this._cursorOffset++;
  7545. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7546. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7547. // Find closest move
  7548. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7549. this._cursorOffset--;
  7550. }
  7551. this._blinkIsEven = false;
  7552. this._clickedCoordinate = null;
  7553. }
  7554. // Render cursor
  7555. if (!this._blinkIsEven) {
  7556. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7557. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7558. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7559. if (cursorLeft < clipTextLeft) {
  7560. this._scrollLeft += (clipTextLeft - cursorLeft);
  7561. cursorLeft = clipTextLeft;
  7562. this._markAsDirty();
  7563. }
  7564. else if (cursorLeft > clipTextLeft + availableWidth) {
  7565. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7566. cursorLeft = clipTextLeft + availableWidth;
  7567. this._markAsDirty();
  7568. }
  7569. if (!this._isTextHighlightOn) {
  7570. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7571. }
  7572. }
  7573. clearTimeout(this._blinkTimeout);
  7574. this._blinkTimeout = setTimeout(function () {
  7575. _this._blinkIsEven = !_this._blinkIsEven;
  7576. _this._markAsDirty();
  7577. }, 500);
  7578. //show the highlighted text
  7579. if (this._isTextHighlightOn) {
  7580. clearTimeout(this._blinkTimeout);
  7581. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7582. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7583. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7584. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7585. if (highlightCursorLeft < clipTextLeft) {
  7586. width = width - (clipTextLeft - highlightCursorLeft);
  7587. if (!width) {
  7588. // when using left arrow on text.length > availableWidth;
  7589. // assigns the width of the first letter after clipTextLeft
  7590. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7591. }
  7592. highlightCursorLeft = clipTextLeft;
  7593. }
  7594. //for transparancy
  7595. context.globalAlpha = this._highligherOpacity;
  7596. context.fillStyle = this._textHighlightColor;
  7597. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7598. context.globalAlpha = 1.0;
  7599. }
  7600. }
  7601. context.restore();
  7602. // Border
  7603. if (this._thickness) {
  7604. if (this._isFocused) {
  7605. if (this.focusedColor) {
  7606. context.strokeStyle = this.focusedColor;
  7607. }
  7608. }
  7609. else {
  7610. if (this.color) {
  7611. context.strokeStyle = this.color;
  7612. }
  7613. }
  7614. context.lineWidth = this._thickness;
  7615. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7616. }
  7617. context.restore();
  7618. };
  7619. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7620. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7621. return false;
  7622. }
  7623. this._clickedCoordinate = coordinates.x;
  7624. this._isTextHighlightOn = false;
  7625. this._highlightedText = "";
  7626. this._cursorIndex = -1;
  7627. this._isPointerDown = true;
  7628. this._host._capturingControl[pointerId] = this;
  7629. if (this._host.focusedControl === this) {
  7630. // Move cursor
  7631. clearTimeout(this._blinkTimeout);
  7632. this._markAsDirty();
  7633. return true;
  7634. }
  7635. if (!this._isEnabled) {
  7636. return false;
  7637. }
  7638. this._host.focusedControl = this;
  7639. return true;
  7640. };
  7641. InputText.prototype._onPointerMove = function (target, coordinates) {
  7642. if (this._host.focusedControl === this && this._isPointerDown) {
  7643. this._clickedCoordinate = coordinates.x;
  7644. this._markAsDirty();
  7645. this._updateValueFromCursorIndex(this._cursorOffset);
  7646. }
  7647. _super.prototype._onPointerMove.call(this, target, coordinates);
  7648. };
  7649. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7650. this._isPointerDown = false;
  7651. delete this._host._capturingControl[pointerId];
  7652. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7653. };
  7654. InputText.prototype._beforeRenderText = function (text) {
  7655. return text;
  7656. };
  7657. InputText.prototype.dispose = function () {
  7658. _super.prototype.dispose.call(this);
  7659. this.onBlurObservable.clear();
  7660. this.onFocusObservable.clear();
  7661. this.onTextChangedObservable.clear();
  7662. this.onTextCopyObservable.clear();
  7663. this.onTextCutObservable.clear();
  7664. this.onTextPasteObservable.clear();
  7665. this.onTextHighlightObservable.clear();
  7666. this.onKeyboardEventProcessedObservable.clear();
  7667. };
  7668. return InputText;
  7669. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7670. /***/ }),
  7671. /***/ "./2D/controls/line.ts":
  7672. /*!*****************************!*\
  7673. !*** ./2D/controls/line.ts ***!
  7674. \*****************************/
  7675. /*! exports provided: Line */
  7676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7677. "use strict";
  7678. __webpack_require__.r(__webpack_exports__);
  7679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7680. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7681. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  7682. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7683. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7684. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7685. /** Class used to render 2D lines */
  7686. var Line = /** @class */ (function (_super) {
  7687. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7688. /**
  7689. * Creates a new Line
  7690. * @param name defines the control name
  7691. */
  7692. function Line(name) {
  7693. var _this = _super.call(this, name) || this;
  7694. _this.name = name;
  7695. _this._lineWidth = 1;
  7696. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7697. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7698. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7699. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7700. _this._dash = new Array();
  7701. _this.isHitTestVisible = false;
  7702. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7703. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7704. return _this;
  7705. }
  7706. Object.defineProperty(Line.prototype, "dash", {
  7707. /** Gets or sets the dash pattern */
  7708. get: function () {
  7709. return this._dash;
  7710. },
  7711. set: function (value) {
  7712. if (this._dash === value) {
  7713. return;
  7714. }
  7715. this._dash = value;
  7716. this._markAsDirty();
  7717. },
  7718. enumerable: true,
  7719. configurable: true
  7720. });
  7721. Object.defineProperty(Line.prototype, "connectedControl", {
  7722. /** Gets or sets the control connected with the line end */
  7723. get: function () {
  7724. return this._connectedControl;
  7725. },
  7726. set: function (value) {
  7727. var _this = this;
  7728. if (this._connectedControl === value) {
  7729. return;
  7730. }
  7731. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7732. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7733. this._connectedControlDirtyObserver = null;
  7734. }
  7735. if (value) {
  7736. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7737. }
  7738. this._connectedControl = value;
  7739. this._markAsDirty();
  7740. },
  7741. enumerable: true,
  7742. configurable: true
  7743. });
  7744. Object.defineProperty(Line.prototype, "x1", {
  7745. /** Gets or sets start coordinates on X axis */
  7746. get: function () {
  7747. return this._x1.toString(this._host);
  7748. },
  7749. set: function (value) {
  7750. if (this._x1.toString(this._host) === value) {
  7751. return;
  7752. }
  7753. if (this._x1.fromString(value)) {
  7754. this._markAsDirty();
  7755. }
  7756. },
  7757. enumerable: true,
  7758. configurable: true
  7759. });
  7760. Object.defineProperty(Line.prototype, "y1", {
  7761. /** Gets or sets start coordinates on Y axis */
  7762. get: function () {
  7763. return this._y1.toString(this._host);
  7764. },
  7765. set: function (value) {
  7766. if (this._y1.toString(this._host) === value) {
  7767. return;
  7768. }
  7769. if (this._y1.fromString(value)) {
  7770. this._markAsDirty();
  7771. }
  7772. },
  7773. enumerable: true,
  7774. configurable: true
  7775. });
  7776. Object.defineProperty(Line.prototype, "x2", {
  7777. /** Gets or sets end coordinates on X axis */
  7778. get: function () {
  7779. return this._x2.toString(this._host);
  7780. },
  7781. set: function (value) {
  7782. if (this._x2.toString(this._host) === value) {
  7783. return;
  7784. }
  7785. if (this._x2.fromString(value)) {
  7786. this._markAsDirty();
  7787. }
  7788. },
  7789. enumerable: true,
  7790. configurable: true
  7791. });
  7792. Object.defineProperty(Line.prototype, "y2", {
  7793. /** Gets or sets end coordinates on Y axis */
  7794. get: function () {
  7795. return this._y2.toString(this._host);
  7796. },
  7797. set: function (value) {
  7798. if (this._y2.toString(this._host) === value) {
  7799. return;
  7800. }
  7801. if (this._y2.fromString(value)) {
  7802. this._markAsDirty();
  7803. }
  7804. },
  7805. enumerable: true,
  7806. configurable: true
  7807. });
  7808. Object.defineProperty(Line.prototype, "lineWidth", {
  7809. /** Gets or sets line width */
  7810. get: function () {
  7811. return this._lineWidth;
  7812. },
  7813. set: function (value) {
  7814. if (this._lineWidth === value) {
  7815. return;
  7816. }
  7817. this._lineWidth = value;
  7818. this._markAsDirty();
  7819. },
  7820. enumerable: true,
  7821. configurable: true
  7822. });
  7823. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7824. /** Gets or sets horizontal alignment */
  7825. set: function (value) {
  7826. return;
  7827. },
  7828. enumerable: true,
  7829. configurable: true
  7830. });
  7831. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7832. /** Gets or sets vertical alignment */
  7833. set: function (value) {
  7834. return;
  7835. },
  7836. enumerable: true,
  7837. configurable: true
  7838. });
  7839. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7840. get: function () {
  7841. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7842. },
  7843. enumerable: true,
  7844. configurable: true
  7845. });
  7846. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7847. get: function () {
  7848. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7849. },
  7850. enumerable: true,
  7851. configurable: true
  7852. });
  7853. Line.prototype._getTypeName = function () {
  7854. return "Line";
  7855. };
  7856. Line.prototype._draw = function (context) {
  7857. context.save();
  7858. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7859. context.shadowColor = this.shadowColor;
  7860. context.shadowBlur = this.shadowBlur;
  7861. context.shadowOffsetX = this.shadowOffsetX;
  7862. context.shadowOffsetY = this.shadowOffsetY;
  7863. }
  7864. this._applyStates(context);
  7865. context.strokeStyle = this.color;
  7866. context.lineWidth = this._lineWidth;
  7867. context.setLineDash(this._dash);
  7868. context.beginPath();
  7869. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  7870. context.lineTo(this._effectiveX2, this._effectiveY2);
  7871. context.stroke();
  7872. context.restore();
  7873. };
  7874. Line.prototype._measure = function () {
  7875. // Width / Height
  7876. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  7877. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  7878. };
  7879. Line.prototype._computeAlignment = function (parentMeasure, context) {
  7880. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  7881. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  7882. };
  7883. /**
  7884. * Move one end of the line given 3D cartesian coordinates.
  7885. * @param position Targeted world position
  7886. * @param scene Scene
  7887. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7888. */
  7889. Line.prototype.moveToVector3 = function (position, scene, end) {
  7890. if (end === void 0) { end = false; }
  7891. if (!this._host || this.parent !== this._host._rootContainer) {
  7892. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  7893. return;
  7894. }
  7895. var globalViewport = this._host._getGlobalViewport(scene);
  7896. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  7897. this._moveToProjectedPosition(projectedPosition, end);
  7898. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  7899. this.notRenderable = true;
  7900. return;
  7901. }
  7902. this.notRenderable = false;
  7903. };
  7904. /**
  7905. * Move one end of the line to a position in screen absolute space.
  7906. * @param projectedPosition Position in screen absolute space (X, Y)
  7907. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  7908. */
  7909. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  7910. if (end === void 0) { end = false; }
  7911. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  7912. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  7913. if (end) {
  7914. this.x2 = x;
  7915. this.y2 = y;
  7916. this._x2.ignoreAdaptiveScaling = true;
  7917. this._y2.ignoreAdaptiveScaling = true;
  7918. }
  7919. else {
  7920. this.x1 = x;
  7921. this.y1 = y;
  7922. this._x1.ignoreAdaptiveScaling = true;
  7923. this._y1.ignoreAdaptiveScaling = true;
  7924. }
  7925. };
  7926. return Line;
  7927. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7928. /***/ }),
  7929. /***/ "./2D/controls/multiLine.ts":
  7930. /*!**********************************!*\
  7931. !*** ./2D/controls/multiLine.ts ***!
  7932. \**********************************/
  7933. /*! exports provided: MultiLine */
  7934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7935. "use strict";
  7936. __webpack_require__.r(__webpack_exports__);
  7937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  7938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7939. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  7940. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  7941. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7942. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  7943. /**
  7944. * Class used to create multi line control
  7945. */
  7946. var MultiLine = /** @class */ (function (_super) {
  7947. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  7948. /**
  7949. * Creates a new MultiLine
  7950. * @param name defines the control name
  7951. */
  7952. function MultiLine(name) {
  7953. var _this = _super.call(this, name) || this;
  7954. _this.name = name;
  7955. _this._lineWidth = 1;
  7956. /** Function called when a point is updated */
  7957. _this.onPointUpdate = function () {
  7958. _this._markAsDirty();
  7959. };
  7960. _this.isHitTestVisible = false;
  7961. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7962. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7963. _this._dash = [];
  7964. _this._points = [];
  7965. return _this;
  7966. }
  7967. Object.defineProperty(MultiLine.prototype, "dash", {
  7968. /** Gets or sets dash pattern */
  7969. get: function () {
  7970. return this._dash;
  7971. },
  7972. set: function (value) {
  7973. if (this._dash === value) {
  7974. return;
  7975. }
  7976. this._dash = value;
  7977. this._markAsDirty();
  7978. },
  7979. enumerable: true,
  7980. configurable: true
  7981. });
  7982. /**
  7983. * Gets point stored at specified index
  7984. * @param index defines the index to look for
  7985. * @returns the requested point if found
  7986. */
  7987. MultiLine.prototype.getAt = function (index) {
  7988. if (!this._points[index]) {
  7989. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  7990. }
  7991. return this._points[index];
  7992. };
  7993. /**
  7994. * Adds new points to the point collection
  7995. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  7996. * @returns the list of created MultiLinePoint
  7997. */
  7998. MultiLine.prototype.add = function () {
  7999. var _this = this;
  8000. var items = [];
  8001. for (var _i = 0; _i < arguments.length; _i++) {
  8002. items[_i] = arguments[_i];
  8003. }
  8004. return items.map(function (item) { return _this.push(item); });
  8005. };
  8006. /**
  8007. * Adds a new point to the point collection
  8008. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8009. * @returns the created MultiLinePoint
  8010. */
  8011. MultiLine.prototype.push = function (item) {
  8012. var point = this.getAt(this._points.length);
  8013. if (item == null) {
  8014. return point;
  8015. }
  8016. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8017. point.mesh = item;
  8018. }
  8019. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8020. point.control = item;
  8021. }
  8022. else if (item.x != null && item.y != null) {
  8023. point.x = item.x;
  8024. point.y = item.y;
  8025. }
  8026. return point;
  8027. };
  8028. /**
  8029. * Remove a specific value or point from the active point collection
  8030. * @param value defines the value or point to remove
  8031. */
  8032. MultiLine.prototype.remove = function (value) {
  8033. var index;
  8034. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8035. index = this._points.indexOf(value);
  8036. if (index === -1) {
  8037. return;
  8038. }
  8039. }
  8040. else {
  8041. index = value;
  8042. }
  8043. var point = this._points[index];
  8044. if (!point) {
  8045. return;
  8046. }
  8047. point.dispose();
  8048. this._points.splice(index, 1);
  8049. };
  8050. /**
  8051. * Resets this object to initial state (no point)
  8052. */
  8053. MultiLine.prototype.reset = function () {
  8054. while (this._points.length > 0) {
  8055. this.remove(this._points.length - 1);
  8056. }
  8057. };
  8058. /**
  8059. * Resets all links
  8060. */
  8061. MultiLine.prototype.resetLinks = function () {
  8062. this._points.forEach(function (point) {
  8063. if (point != null) {
  8064. point.resetLinks();
  8065. }
  8066. });
  8067. };
  8068. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8069. /** Gets or sets line width */
  8070. get: function () {
  8071. return this._lineWidth;
  8072. },
  8073. set: function (value) {
  8074. if (this._lineWidth === value) {
  8075. return;
  8076. }
  8077. this._lineWidth = value;
  8078. this._markAsDirty();
  8079. },
  8080. enumerable: true,
  8081. configurable: true
  8082. });
  8083. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8084. set: function (value) {
  8085. return;
  8086. },
  8087. enumerable: true,
  8088. configurable: true
  8089. });
  8090. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8091. set: function (value) {
  8092. return;
  8093. },
  8094. enumerable: true,
  8095. configurable: true
  8096. });
  8097. MultiLine.prototype._getTypeName = function () {
  8098. return "MultiLine";
  8099. };
  8100. MultiLine.prototype._draw = function (context) {
  8101. context.save();
  8102. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8103. context.shadowColor = this.shadowColor;
  8104. context.shadowBlur = this.shadowBlur;
  8105. context.shadowOffsetX = this.shadowOffsetX;
  8106. context.shadowOffsetY = this.shadowOffsetY;
  8107. }
  8108. this._applyStates(context);
  8109. context.strokeStyle = this.color;
  8110. context.lineWidth = this._lineWidth;
  8111. context.setLineDash(this._dash);
  8112. context.beginPath();
  8113. var first = true; //first index is not necessarily 0
  8114. this._points.forEach(function (point) {
  8115. if (!point) {
  8116. return;
  8117. }
  8118. if (first) {
  8119. context.moveTo(point._point.x, point._point.y);
  8120. first = false;
  8121. }
  8122. else {
  8123. context.lineTo(point._point.x, point._point.y);
  8124. }
  8125. });
  8126. context.stroke();
  8127. context.restore();
  8128. };
  8129. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8130. var _this = this;
  8131. this._minX = null;
  8132. this._minY = null;
  8133. this._maxX = null;
  8134. this._maxY = null;
  8135. this._points.forEach(function (point, index) {
  8136. if (!point) {
  8137. return;
  8138. }
  8139. point.translate();
  8140. if (_this._minX == null || point._point.x < _this._minX) {
  8141. _this._minX = point._point.x;
  8142. }
  8143. if (_this._minY == null || point._point.y < _this._minY) {
  8144. _this._minY = point._point.y;
  8145. }
  8146. if (_this._maxX == null || point._point.x > _this._maxX) {
  8147. _this._maxX = point._point.x;
  8148. }
  8149. if (_this._maxY == null || point._point.y > _this._maxY) {
  8150. _this._maxY = point._point.y;
  8151. }
  8152. });
  8153. if (this._minX == null) {
  8154. this._minX = 0;
  8155. }
  8156. if (this._minY == null) {
  8157. this._minY = 0;
  8158. }
  8159. if (this._maxX == null) {
  8160. this._maxX = 0;
  8161. }
  8162. if (this._maxY == null) {
  8163. this._maxY = 0;
  8164. }
  8165. };
  8166. MultiLine.prototype._measure = function () {
  8167. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8168. return;
  8169. }
  8170. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8171. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8172. };
  8173. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8174. if (this._minX == null || this._minY == null) {
  8175. return;
  8176. }
  8177. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8178. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8179. };
  8180. MultiLine.prototype.dispose = function () {
  8181. this.reset();
  8182. _super.prototype.dispose.call(this);
  8183. };
  8184. return MultiLine;
  8185. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8186. /***/ }),
  8187. /***/ "./2D/controls/radioButton.ts":
  8188. /*!************************************!*\
  8189. !*** ./2D/controls/radioButton.ts ***!
  8190. \************************************/
  8191. /*! exports provided: RadioButton */
  8192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8193. "use strict";
  8194. __webpack_require__.r(__webpack_exports__);
  8195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8197. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8198. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8199. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8200. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8201. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8202. /**
  8203. * Class used to create radio button controls
  8204. */
  8205. var RadioButton = /** @class */ (function (_super) {
  8206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8207. /**
  8208. * Creates a new RadioButton
  8209. * @param name defines the control name
  8210. */
  8211. function RadioButton(name) {
  8212. var _this = _super.call(this, name) || this;
  8213. _this.name = name;
  8214. _this._isChecked = false;
  8215. _this._background = "black";
  8216. _this._checkSizeRatio = 0.8;
  8217. _this._thickness = 1;
  8218. /** Gets or sets group name */
  8219. _this.group = "";
  8220. /** Observable raised when isChecked is changed */
  8221. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8222. _this.isPointerBlocker = true;
  8223. return _this;
  8224. }
  8225. Object.defineProperty(RadioButton.prototype, "thickness", {
  8226. /** Gets or sets border thickness */
  8227. get: function () {
  8228. return this._thickness;
  8229. },
  8230. set: function (value) {
  8231. if (this._thickness === value) {
  8232. return;
  8233. }
  8234. this._thickness = value;
  8235. this._markAsDirty();
  8236. },
  8237. enumerable: true,
  8238. configurable: true
  8239. });
  8240. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8241. /** Gets or sets a value indicating the ratio between overall size and check size */
  8242. get: function () {
  8243. return this._checkSizeRatio;
  8244. },
  8245. set: function (value) {
  8246. value = Math.max(Math.min(1, value), 0);
  8247. if (this._checkSizeRatio === value) {
  8248. return;
  8249. }
  8250. this._checkSizeRatio = value;
  8251. this._markAsDirty();
  8252. },
  8253. enumerable: true,
  8254. configurable: true
  8255. });
  8256. Object.defineProperty(RadioButton.prototype, "background", {
  8257. /** Gets or sets background color */
  8258. get: function () {
  8259. return this._background;
  8260. },
  8261. set: function (value) {
  8262. if (this._background === value) {
  8263. return;
  8264. }
  8265. this._background = value;
  8266. this._markAsDirty();
  8267. },
  8268. enumerable: true,
  8269. configurable: true
  8270. });
  8271. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8272. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8273. get: function () {
  8274. return this._isChecked;
  8275. },
  8276. set: function (value) {
  8277. var _this = this;
  8278. if (this._isChecked === value) {
  8279. return;
  8280. }
  8281. this._isChecked = value;
  8282. this._markAsDirty();
  8283. this.onIsCheckedChangedObservable.notifyObservers(value);
  8284. if (this._isChecked && this._host) {
  8285. // Update all controls from same group
  8286. this._host.executeOnAllControls(function (control) {
  8287. if (control === _this) {
  8288. return;
  8289. }
  8290. if (control.group === undefined) {
  8291. return;
  8292. }
  8293. var childRadio = control;
  8294. if (childRadio.group === _this.group) {
  8295. childRadio.isChecked = false;
  8296. }
  8297. });
  8298. }
  8299. },
  8300. enumerable: true,
  8301. configurable: true
  8302. });
  8303. RadioButton.prototype._getTypeName = function () {
  8304. return "RadioButton";
  8305. };
  8306. RadioButton.prototype._draw = function (context) {
  8307. context.save();
  8308. this._applyStates(context);
  8309. var actualWidth = this._currentMeasure.width - this._thickness;
  8310. var actualHeight = this._currentMeasure.height - this._thickness;
  8311. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8312. context.shadowColor = this.shadowColor;
  8313. context.shadowBlur = this.shadowBlur;
  8314. context.shadowOffsetX = this.shadowOffsetX;
  8315. context.shadowOffsetY = this.shadowOffsetY;
  8316. }
  8317. // Outer
  8318. _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);
  8319. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8320. context.fill();
  8321. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8322. context.shadowBlur = 0;
  8323. context.shadowOffsetX = 0;
  8324. context.shadowOffsetY = 0;
  8325. }
  8326. context.strokeStyle = this.color;
  8327. context.lineWidth = this._thickness;
  8328. context.stroke();
  8329. // Inner
  8330. if (this._isChecked) {
  8331. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8332. var offsetWidth = actualWidth * this._checkSizeRatio;
  8333. var offseHeight = actualHeight * this._checkSizeRatio;
  8334. _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);
  8335. context.fill();
  8336. }
  8337. context.restore();
  8338. };
  8339. // Events
  8340. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8341. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8342. return false;
  8343. }
  8344. if (!this.isChecked) {
  8345. this.isChecked = true;
  8346. }
  8347. return true;
  8348. };
  8349. /**
  8350. * Utility function to easily create a radio button with a header
  8351. * @param title defines the label to use for the header
  8352. * @param group defines the group to use for the radio button
  8353. * @param isChecked defines the initial state of the radio button
  8354. * @param onValueChanged defines the callback to call when value changes
  8355. * @returns a StackPanel containing the radio button and a textBlock
  8356. */
  8357. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8358. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8359. panel.isVertical = false;
  8360. panel.height = "30px";
  8361. var radio = new RadioButton();
  8362. radio.width = "20px";
  8363. radio.height = "20px";
  8364. radio.isChecked = isChecked;
  8365. radio.color = "green";
  8366. radio.group = group;
  8367. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8368. panel.addControl(radio);
  8369. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8370. header.text = title;
  8371. header.width = "180px";
  8372. header.paddingLeft = "5px";
  8373. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8374. header.color = "white";
  8375. panel.addControl(header);
  8376. return panel;
  8377. };
  8378. return RadioButton;
  8379. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8380. /***/ }),
  8381. /***/ "./2D/controls/rectangle.ts":
  8382. /*!**********************************!*\
  8383. !*** ./2D/controls/rectangle.ts ***!
  8384. \**********************************/
  8385. /*! exports provided: Rectangle */
  8386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8387. "use strict";
  8388. __webpack_require__.r(__webpack_exports__);
  8389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8390. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8391. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8392. /** Class used to create rectangle container */
  8393. var Rectangle = /** @class */ (function (_super) {
  8394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8395. /**
  8396. * Creates a new Rectangle
  8397. * @param name defines the control name
  8398. */
  8399. function Rectangle(name) {
  8400. var _this = _super.call(this, name) || this;
  8401. _this.name = name;
  8402. _this._thickness = 1;
  8403. _this._cornerRadius = 0;
  8404. return _this;
  8405. }
  8406. Object.defineProperty(Rectangle.prototype, "thickness", {
  8407. /** Gets or sets border thickness */
  8408. get: function () {
  8409. return this._thickness;
  8410. },
  8411. set: function (value) {
  8412. if (this._thickness === value) {
  8413. return;
  8414. }
  8415. this._thickness = value;
  8416. this._markAsDirty();
  8417. },
  8418. enumerable: true,
  8419. configurable: true
  8420. });
  8421. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8422. /** Gets or sets the corner radius angle */
  8423. get: function () {
  8424. return this._cornerRadius;
  8425. },
  8426. set: function (value) {
  8427. if (value < 0) {
  8428. value = 0;
  8429. }
  8430. if (this._cornerRadius === value) {
  8431. return;
  8432. }
  8433. this._cornerRadius = value;
  8434. this._markAsDirty();
  8435. },
  8436. enumerable: true,
  8437. configurable: true
  8438. });
  8439. Rectangle.prototype._getTypeName = function () {
  8440. return "Rectangle";
  8441. };
  8442. Rectangle.prototype._localDraw = function (context) {
  8443. context.save();
  8444. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8445. context.shadowColor = this.shadowColor;
  8446. context.shadowBlur = this.shadowBlur;
  8447. context.shadowOffsetX = this.shadowOffsetX;
  8448. context.shadowOffsetY = this.shadowOffsetY;
  8449. }
  8450. if (this._background) {
  8451. context.fillStyle = this._background;
  8452. if (this._cornerRadius) {
  8453. this._drawRoundedRect(context, this._thickness / 2);
  8454. context.fill();
  8455. }
  8456. else {
  8457. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8458. }
  8459. }
  8460. if (this._thickness) {
  8461. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8462. context.shadowBlur = 0;
  8463. context.shadowOffsetX = 0;
  8464. context.shadowOffsetY = 0;
  8465. }
  8466. if (this.color) {
  8467. context.strokeStyle = this.color;
  8468. }
  8469. context.lineWidth = this._thickness;
  8470. if (this._cornerRadius) {
  8471. this._drawRoundedRect(context, this._thickness / 2);
  8472. context.stroke();
  8473. }
  8474. else {
  8475. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8476. }
  8477. }
  8478. context.restore();
  8479. };
  8480. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8481. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8482. this._measureForChildren.width -= 2 * this._thickness;
  8483. this._measureForChildren.height -= 2 * this._thickness;
  8484. this._measureForChildren.left += this._thickness;
  8485. this._measureForChildren.top += this._thickness;
  8486. };
  8487. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8488. if (offset === void 0) { offset = 0; }
  8489. var x = this._currentMeasure.left + offset;
  8490. var y = this._currentMeasure.top + offset;
  8491. var width = this._currentMeasure.width - offset * 2;
  8492. var height = this._currentMeasure.height - offset * 2;
  8493. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8494. context.beginPath();
  8495. context.moveTo(x + radius, y);
  8496. context.lineTo(x + width - radius, y);
  8497. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8498. context.lineTo(x + width, y + height - radius);
  8499. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8500. context.lineTo(x + radius, y + height);
  8501. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8502. context.lineTo(x, y + radius);
  8503. context.quadraticCurveTo(x, y, x + radius, y);
  8504. context.closePath();
  8505. };
  8506. Rectangle.prototype._clipForChildren = function (context) {
  8507. if (this._cornerRadius) {
  8508. this._drawRoundedRect(context, this._thickness);
  8509. context.clip();
  8510. }
  8511. };
  8512. return Rectangle;
  8513. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8514. /***/ }),
  8515. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8516. /*!***************************************************!*\
  8517. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8518. \***************************************************/
  8519. /*! exports provided: ScrollViewer */
  8520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8521. "use strict";
  8522. __webpack_require__.r(__webpack_exports__);
  8523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8525. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/observable");
  8526. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8527. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8528. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8529. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8530. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8531. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8532. /**
  8533. * Class used to hold a viewer window and sliders in a grid
  8534. */
  8535. var ScrollViewer = /** @class */ (function (_super) {
  8536. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8537. /**
  8538. * Creates a new ScrollViewer
  8539. * @param name of ScrollViewer
  8540. */
  8541. function ScrollViewer(name) {
  8542. var _this = _super.call(this, name) || this;
  8543. _this._barSize = 20;
  8544. _this._pointerIsOver = false;
  8545. _this._wheelPrecision = 0.05;
  8546. _this.onDirtyObservable.add(function () {
  8547. _this._horizontalBarSpace.color = _this.color;
  8548. _this._verticalBarSpace.color = _this.color;
  8549. _this._dragSpace.color = _this.color;
  8550. });
  8551. _this.onPointerEnterObservable.add(function () {
  8552. _this._pointerIsOver = true;
  8553. });
  8554. _this.onPointerOutObservable.add(function () {
  8555. _this._pointerIsOver = false;
  8556. });
  8557. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8558. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8559. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8560. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8561. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8562. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8563. _this._grid.addColumnDefinition(1);
  8564. _this._grid.addColumnDefinition(0, true);
  8565. _this._grid.addRowDefinition(1);
  8566. _this._grid.addRowDefinition(0, true);
  8567. _super.prototype.addControl.call(_this, _this._grid);
  8568. _this._grid.addControl(_this._window, 0, 0);
  8569. _this._verticalBar.paddingLeft = 0;
  8570. _this._verticalBar.width = "100%";
  8571. _this._verticalBar.height = "100%";
  8572. _this._verticalBar.barOffset = 0;
  8573. _this._verticalBar.value = 0;
  8574. _this._verticalBar.maximum = 1;
  8575. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8576. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8577. _this._verticalBar.isVertical = true;
  8578. _this._verticalBar.rotation = Math.PI;
  8579. _this._verticalBar.isVisible = false;
  8580. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8581. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8582. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8583. _this._verticalBarSpace.thickness = 1;
  8584. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8585. _this._verticalBarSpace.addControl(_this._verticalBar);
  8586. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8587. _this._window.top = value * _this._endTop + "px";
  8588. });
  8589. _this._horizontalBar.paddingLeft = 0;
  8590. _this._horizontalBar.width = "100%";
  8591. _this._horizontalBar.height = "100%";
  8592. _this._horizontalBar.barOffset = 0;
  8593. _this._horizontalBar.value = 0;
  8594. _this._horizontalBar.maximum = 1;
  8595. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8596. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8597. _this._horizontalBar.isVisible = false;
  8598. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8599. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8600. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8601. _this._horizontalBarSpace.thickness = 1;
  8602. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8603. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8604. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8605. _this._window.left = value * _this._endLeft + "px";
  8606. });
  8607. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8608. _this._dragSpace.thickness = 1;
  8609. _this._grid.addControl(_this._dragSpace, 1, 1);
  8610. // Colors
  8611. _this.barColor = "grey";
  8612. _this.barBackground = "transparent";
  8613. return _this;
  8614. }
  8615. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8616. /**
  8617. * Gets the horizontal scrollbar
  8618. */
  8619. get: function () {
  8620. return this._horizontalBar;
  8621. },
  8622. enumerable: true,
  8623. configurable: true
  8624. });
  8625. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8626. /**
  8627. * Gets the vertical scrollbar
  8628. */
  8629. get: function () {
  8630. return this._verticalBar;
  8631. },
  8632. enumerable: true,
  8633. configurable: true
  8634. });
  8635. /**
  8636. * Adds a new control to the current container
  8637. * @param control defines the control to add
  8638. * @returns the current container
  8639. */
  8640. ScrollViewer.prototype.addControl = function (control) {
  8641. if (!control) {
  8642. return this;
  8643. }
  8644. this._window.addControl(control);
  8645. return this;
  8646. };
  8647. /**
  8648. * Removes a control from the current container
  8649. * @param control defines the control to remove
  8650. * @returns the current container
  8651. */
  8652. ScrollViewer.prototype.removeControl = function (control) {
  8653. this._window.removeControl(control);
  8654. return this;
  8655. };
  8656. Object.defineProperty(ScrollViewer.prototype, "children", {
  8657. /** Gets the list of children */
  8658. get: function () {
  8659. return this._window.children;
  8660. },
  8661. enumerable: true,
  8662. configurable: true
  8663. });
  8664. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8665. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8666. var child = _a[_i];
  8667. child._markMatrixAsDirty();
  8668. }
  8669. };
  8670. /** Reset the scroll viewer window to initial size */
  8671. ScrollViewer.prototype.resetWindow = function () {
  8672. this._window.width = "100%";
  8673. this._window.height = "100%";
  8674. };
  8675. ScrollViewer.prototype._getTypeName = function () {
  8676. return "ScrollViewer";
  8677. };
  8678. ScrollViewer.prototype._buildClientSizes = function () {
  8679. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8680. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8681. this._clientWidth = this._window.parentClientWidth;
  8682. this._clientHeight = this._window.parentClientHeight;
  8683. };
  8684. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8685. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8686. this._buildClientSizes();
  8687. };
  8688. ScrollViewer.prototype._postMeasure = function () {
  8689. _super.prototype._postMeasure.call(this);
  8690. this._updateScroller();
  8691. };
  8692. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8693. /**
  8694. * Gets or sets the mouse wheel precision
  8695. * from 0 to 1 with a default value of 0.05
  8696. * */
  8697. get: function () {
  8698. return this._wheelPrecision;
  8699. },
  8700. set: function (value) {
  8701. if (this._wheelPrecision === value) {
  8702. return;
  8703. }
  8704. if (value < 0) {
  8705. value = 0;
  8706. }
  8707. if (value > 1) {
  8708. value = 1;
  8709. }
  8710. this._wheelPrecision = value;
  8711. },
  8712. enumerable: true,
  8713. configurable: true
  8714. });
  8715. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8716. /** Gets or sets the bar color */
  8717. get: function () {
  8718. return this._barColor;
  8719. },
  8720. set: function (color) {
  8721. if (this._barColor === color) {
  8722. return;
  8723. }
  8724. this._barColor = color;
  8725. this._horizontalBar.color = color;
  8726. this._verticalBar.color = color;
  8727. },
  8728. enumerable: true,
  8729. configurable: true
  8730. });
  8731. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8732. /** Gets or sets the size of the bar */
  8733. get: function () {
  8734. return this._barSize;
  8735. },
  8736. set: function (value) {
  8737. if (this._barSize === value) {
  8738. return;
  8739. }
  8740. this._barSize = value;
  8741. this._markAsDirty();
  8742. if (this._horizontalBar.isVisible) {
  8743. this._grid.setRowDefinition(1, this._barSize, true);
  8744. }
  8745. if (this._verticalBar.isVisible) {
  8746. this._grid.setColumnDefinition(1, this._barSize, true);
  8747. }
  8748. },
  8749. enumerable: true,
  8750. configurable: true
  8751. });
  8752. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8753. /** Gets or sets the bar background */
  8754. get: function () {
  8755. return this._barBackground;
  8756. },
  8757. set: function (color) {
  8758. if (this._barBackground === color) {
  8759. return;
  8760. }
  8761. this._barBackground = color;
  8762. this._horizontalBar.background = color;
  8763. this._verticalBar.background = color;
  8764. this._dragSpace.background = color;
  8765. },
  8766. enumerable: true,
  8767. configurable: true
  8768. });
  8769. /** @hidden */
  8770. ScrollViewer.prototype._updateScroller = function () {
  8771. var windowContentsWidth = this._window._currentMeasure.width;
  8772. var windowContentsHeight = this._window._currentMeasure.height;
  8773. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8774. this._grid.setRowDefinition(1, 0, true);
  8775. this._horizontalBar.isVisible = false;
  8776. this._horizontalBar.value = 0;
  8777. this._rebuildLayout = true;
  8778. }
  8779. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8780. this._grid.setRowDefinition(1, this._barSize, true);
  8781. this._horizontalBar.isVisible = true;
  8782. this._rebuildLayout = true;
  8783. }
  8784. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8785. this._grid.setColumnDefinition(1, 0, true);
  8786. this._verticalBar.isVisible = false;
  8787. this._verticalBar.value = 0;
  8788. this._rebuildLayout = true;
  8789. }
  8790. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8791. this._grid.setColumnDefinition(1, this._barSize, true);
  8792. this._verticalBar.isVisible = true;
  8793. this._rebuildLayout = true;
  8794. }
  8795. this._buildClientSizes();
  8796. this._endLeft = this._clientWidth - windowContentsWidth;
  8797. this._endTop = this._clientHeight - windowContentsHeight;
  8798. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8799. var newTop = this._verticalBar.value * this._endTop + "px";
  8800. if (newLeft !== this._window.left) {
  8801. this._window.left = newLeft;
  8802. this._rebuildLayout = true;
  8803. }
  8804. if (newTop !== this._window.top) {
  8805. this._window.top = newTop;
  8806. this._rebuildLayout = true;
  8807. }
  8808. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8809. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8810. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8811. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8812. };
  8813. ScrollViewer.prototype._link = function (host) {
  8814. _super.prototype._link.call(this, host);
  8815. this._attachWheel();
  8816. };
  8817. /** @hidden */
  8818. ScrollViewer.prototype._attachWheel = function () {
  8819. var _this = this;
  8820. if (this._onPointerObserver) {
  8821. return;
  8822. }
  8823. var scene = this._host.getScene();
  8824. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8825. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8826. return;
  8827. }
  8828. if (_this._verticalBar.isVisible == true) {
  8829. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8830. _this._verticalBar.value -= _this._wheelPrecision;
  8831. }
  8832. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8833. _this._verticalBar.value += _this._wheelPrecision;
  8834. }
  8835. }
  8836. if (_this._horizontalBar.isVisible == true) {
  8837. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8838. _this._horizontalBar.value += _this._wheelPrecision;
  8839. }
  8840. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8841. _this._horizontalBar.value -= _this._wheelPrecision;
  8842. }
  8843. }
  8844. });
  8845. };
  8846. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8847. if (!this.isHighlighted) {
  8848. return;
  8849. }
  8850. _super.prototype._renderHighlightSpecific.call(this, context);
  8851. this._grid._renderHighlightSpecific(context);
  8852. context.restore();
  8853. };
  8854. /** Releases associated resources */
  8855. ScrollViewer.prototype.dispose = function () {
  8856. var scene = this._host.getScene();
  8857. if (scene && this._onPointerObserver) {
  8858. scene.onPointerObservable.remove(this._onPointerObserver);
  8859. this._onPointerObserver = null;
  8860. }
  8861. _super.prototype.dispose.call(this);
  8862. };
  8863. return ScrollViewer;
  8864. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8865. /***/ }),
  8866. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  8867. /*!*********************************************************!*\
  8868. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  8869. \*********************************************************/
  8870. /*! exports provided: _ScrollViewerWindow */
  8871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8872. "use strict";
  8873. __webpack_require__.r(__webpack_exports__);
  8874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  8875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8876. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  8877. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  8878. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8879. /**
  8880. * Class used to hold a the container for ScrollViewer
  8881. * @hidden
  8882. */
  8883. var _ScrollViewerWindow = /** @class */ (function (_super) {
  8884. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  8885. /**
  8886. * Creates a new ScrollViewerWindow
  8887. * @param name of ScrollViewerWindow
  8888. */
  8889. function _ScrollViewerWindow(name) {
  8890. return _super.call(this, name) || this;
  8891. }
  8892. _ScrollViewerWindow.prototype._getTypeName = function () {
  8893. return "ScrollViewerWindow";
  8894. };
  8895. /** @hidden */
  8896. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  8897. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8898. this._measureForChildren.left = this._currentMeasure.left;
  8899. this._measureForChildren.top = this._currentMeasure.top;
  8900. this._measureForChildren.width = parentMeasure.width;
  8901. this._measureForChildren.height = parentMeasure.height;
  8902. };
  8903. _ScrollViewerWindow.prototype._postMeasure = function () {
  8904. var maxWidth = this.parentClientWidth;
  8905. var maxHeight = this.parentClientHeight;
  8906. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  8907. var child = _a[_i];
  8908. if (!child.isVisible || child.notRenderable) {
  8909. continue;
  8910. }
  8911. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  8912. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  8913. }
  8914. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  8915. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  8916. }
  8917. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  8918. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  8919. }
  8920. if (this._currentMeasure.width !== maxWidth) {
  8921. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8922. this._currentMeasure.width = maxWidth;
  8923. this._rebuildLayout = true;
  8924. this._isDirty = true;
  8925. }
  8926. if (this._currentMeasure.height !== maxHeight) {
  8927. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  8928. this._currentMeasure.height = maxHeight;
  8929. this._rebuildLayout = true;
  8930. this._isDirty = true;
  8931. }
  8932. _super.prototype._postMeasure.call(this);
  8933. };
  8934. return _ScrollViewerWindow;
  8935. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8936. /***/ }),
  8937. /***/ "./2D/controls/selector.ts":
  8938. /*!*********************************!*\
  8939. !*** ./2D/controls/selector.ts ***!
  8940. \*********************************/
  8941. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  8942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8943. "use strict";
  8944. __webpack_require__.r(__webpack_exports__);
  8945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  8946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  8947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  8948. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  8949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  8950. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8951. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  8952. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8953. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8954. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8955. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  8956. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  8957. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  8958. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8959. /** Class used to create a RadioGroup
  8960. * which contains groups of radio buttons
  8961. */
  8962. var SelectorGroup = /** @class */ (function () {
  8963. /**
  8964. * Creates a new SelectorGroup
  8965. * @param name of group, used as a group heading
  8966. */
  8967. function SelectorGroup(
  8968. /** name of SelectorGroup */
  8969. name) {
  8970. this.name = name;
  8971. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  8972. this._selectors = new Array();
  8973. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  8974. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8975. this._groupHeader = this._addGroupHeader(name);
  8976. }
  8977. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  8978. /** Gets the groupPanel of the SelectorGroup */
  8979. get: function () {
  8980. return this._groupPanel;
  8981. },
  8982. enumerable: true,
  8983. configurable: true
  8984. });
  8985. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  8986. /** Gets the selectors array */
  8987. get: function () {
  8988. return this._selectors;
  8989. },
  8990. enumerable: true,
  8991. configurable: true
  8992. });
  8993. Object.defineProperty(SelectorGroup.prototype, "header", {
  8994. /** Gets and sets the group header */
  8995. get: function () {
  8996. return this._groupHeader.text;
  8997. },
  8998. set: function (label) {
  8999. if (this._groupHeader.text === "label") {
  9000. return;
  9001. }
  9002. this._groupHeader.text = label;
  9003. },
  9004. enumerable: true,
  9005. configurable: true
  9006. });
  9007. /** @hidden */
  9008. SelectorGroup.prototype._addGroupHeader = function (text) {
  9009. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9010. groupHeading.width = 0.9;
  9011. groupHeading.height = "30px";
  9012. groupHeading.textWrapping = true;
  9013. groupHeading.color = "black";
  9014. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9015. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9016. groupHeading.left = "2px";
  9017. this._groupPanel.addControl(groupHeading);
  9018. return groupHeading;
  9019. };
  9020. /** @hidden*/
  9021. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9022. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9023. return;
  9024. }
  9025. return this._selectors[selectorNb];
  9026. };
  9027. /** Removes the selector at the given position
  9028. * @param selectorNb the position of the selector within the group
  9029. */
  9030. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9031. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9032. return;
  9033. }
  9034. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9035. this._selectors.splice(selectorNb, 1);
  9036. };
  9037. return SelectorGroup;
  9038. }());
  9039. /** Class used to create a CheckboxGroup
  9040. * which contains groups of checkbox buttons
  9041. */
  9042. var CheckboxGroup = /** @class */ (function (_super) {
  9043. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9044. function CheckboxGroup() {
  9045. return _super !== null && _super.apply(this, arguments) || this;
  9046. }
  9047. /** Adds a checkbox as a control
  9048. * @param text is the label for the selector
  9049. * @param func is the function called when the Selector is checked
  9050. * @param checked is true when Selector is checked
  9051. */
  9052. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9053. if (func === void 0) { func = function (s) { }; }
  9054. if (checked === void 0) { checked = false; }
  9055. var checked = checked || false;
  9056. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9057. button.width = "20px";
  9058. button.height = "20px";
  9059. button.color = "#364249";
  9060. button.background = "#CCCCCC";
  9061. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9062. button.onIsCheckedChangedObservable.add(function (state) {
  9063. func(state);
  9064. });
  9065. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9066. _selector.height = "30px";
  9067. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9068. _selector.left = "4px";
  9069. this.groupPanel.addControl(_selector);
  9070. this.selectors.push(_selector);
  9071. button.isChecked = checked;
  9072. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9073. button.color = this.groupPanel.parent.parent.buttonColor;
  9074. button.background = this.groupPanel.parent.parent.buttonBackground;
  9075. }
  9076. };
  9077. /** @hidden */
  9078. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9079. this.selectors[selectorNb].children[1].text = label;
  9080. };
  9081. /** @hidden */
  9082. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9083. this.selectors[selectorNb].children[1].color = color;
  9084. };
  9085. /** @hidden */
  9086. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9087. this.selectors[selectorNb].children[0].color = color;
  9088. };
  9089. /** @hidden */
  9090. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9091. this.selectors[selectorNb].children[0].background = color;
  9092. };
  9093. return CheckboxGroup;
  9094. }(SelectorGroup));
  9095. /** Class used to create a RadioGroup
  9096. * which contains groups of radio buttons
  9097. */
  9098. var RadioGroup = /** @class */ (function (_super) {
  9099. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9100. function RadioGroup() {
  9101. var _this = _super !== null && _super.apply(this, arguments) || this;
  9102. _this._selectNb = 0;
  9103. return _this;
  9104. }
  9105. /** Adds a radio button as a control
  9106. * @param label is the label for the selector
  9107. * @param func is the function called when the Selector is checked
  9108. * @param checked is true when Selector is checked
  9109. */
  9110. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9111. if (func === void 0) { func = function (n) { }; }
  9112. if (checked === void 0) { checked = false; }
  9113. var nb = this._selectNb++;
  9114. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9115. button.name = label;
  9116. button.width = "20px";
  9117. button.height = "20px";
  9118. button.color = "#364249";
  9119. button.background = "#CCCCCC";
  9120. button.group = this.name;
  9121. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9122. button.onIsCheckedChangedObservable.add(function (state) {
  9123. if (state) {
  9124. func(nb);
  9125. }
  9126. });
  9127. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9128. _selector.height = "30px";
  9129. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9130. _selector.left = "4px";
  9131. this.groupPanel.addControl(_selector);
  9132. this.selectors.push(_selector);
  9133. button.isChecked = checked;
  9134. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9135. button.color = this.groupPanel.parent.parent.buttonColor;
  9136. button.background = this.groupPanel.parent.parent.buttonBackground;
  9137. }
  9138. };
  9139. /** @hidden */
  9140. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9141. this.selectors[selectorNb].children[1].text = label;
  9142. };
  9143. /** @hidden */
  9144. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9145. this.selectors[selectorNb].children[1].color = color;
  9146. };
  9147. /** @hidden */
  9148. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9149. this.selectors[selectorNb].children[0].color = color;
  9150. };
  9151. /** @hidden */
  9152. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9153. this.selectors[selectorNb].children[0].background = color;
  9154. };
  9155. return RadioGroup;
  9156. }(SelectorGroup));
  9157. /** Class used to create a SliderGroup
  9158. * which contains groups of slider buttons
  9159. */
  9160. var SliderGroup = /** @class */ (function (_super) {
  9161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9162. function SliderGroup() {
  9163. return _super !== null && _super.apply(this, arguments) || this;
  9164. }
  9165. /**
  9166. * Adds a slider to the SelectorGroup
  9167. * @param label is the label for the SliderBar
  9168. * @param func is the function called when the Slider moves
  9169. * @param unit is a string describing the units used, eg degrees or metres
  9170. * @param min is the minimum value for the Slider
  9171. * @param max is the maximum value for the Slider
  9172. * @param value is the start value for the Slider between min and max
  9173. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9174. */
  9175. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9176. if (func === void 0) { func = function (v) { }; }
  9177. if (unit === void 0) { unit = "Units"; }
  9178. if (min === void 0) { min = 0; }
  9179. if (max === void 0) { max = 0; }
  9180. if (value === void 0) { value = 0; }
  9181. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9182. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9183. button.name = unit;
  9184. button.value = value;
  9185. button.minimum = min;
  9186. button.maximum = max;
  9187. button.width = 0.9;
  9188. button.height = "20px";
  9189. button.color = "#364249";
  9190. button.background = "#CCCCCC";
  9191. button.borderColor = "black";
  9192. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9193. button.left = "4px";
  9194. button.paddingBottom = "4px";
  9195. button.onValueChangedObservable.add(function (value) {
  9196. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9197. func(value);
  9198. });
  9199. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9200. _selector.height = "60px";
  9201. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9202. _selector.left = "4px";
  9203. _selector.children[0].name = label;
  9204. this.groupPanel.addControl(_selector);
  9205. this.selectors.push(_selector);
  9206. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9207. button.color = this.groupPanel.parent.parent.buttonColor;
  9208. button.background = this.groupPanel.parent.parent.buttonBackground;
  9209. }
  9210. };
  9211. /** @hidden */
  9212. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9213. this.selectors[selectorNb].children[0].name = label;
  9214. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9215. };
  9216. /** @hidden */
  9217. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9218. this.selectors[selectorNb].children[0].color = color;
  9219. };
  9220. /** @hidden */
  9221. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9222. this.selectors[selectorNb].children[1].color = color;
  9223. };
  9224. /** @hidden */
  9225. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9226. this.selectors[selectorNb].children[1].background = color;
  9227. };
  9228. return SliderGroup;
  9229. }(SelectorGroup));
  9230. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9231. * @see http://doc.babylonjs.com/how_to/selector
  9232. */
  9233. var SelectionPanel = /** @class */ (function (_super) {
  9234. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9235. /**
  9236. * Creates a new SelectionPanel
  9237. * @param name of SelectionPanel
  9238. * @param groups is an array of SelectionGroups
  9239. */
  9240. function SelectionPanel(
  9241. /** name of SelectionPanel */
  9242. name,
  9243. /** an array of SelectionGroups */
  9244. groups) {
  9245. if (groups === void 0) { groups = []; }
  9246. var _this = _super.call(this, name) || this;
  9247. _this.name = name;
  9248. _this.groups = groups;
  9249. _this._buttonColor = "#364249";
  9250. _this._buttonBackground = "#CCCCCC";
  9251. _this._headerColor = "black";
  9252. _this._barColor = "white";
  9253. _this._barHeight = "2px";
  9254. _this._spacerHeight = "20px";
  9255. _this._bars = new Array();
  9256. _this._groups = groups;
  9257. _this.thickness = 2;
  9258. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9259. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9260. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9261. _this._panel.top = 5;
  9262. _this._panel.left = 5;
  9263. _this._panel.width = 0.95;
  9264. if (groups.length > 0) {
  9265. for (var i = 0; i < groups.length - 1; i++) {
  9266. _this._panel.addControl(groups[i].groupPanel);
  9267. _this._addSpacer();
  9268. }
  9269. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9270. }
  9271. _this.addControl(_this._panel);
  9272. return _this;
  9273. }
  9274. SelectionPanel.prototype._getTypeName = function () {
  9275. return "SelectionPanel";
  9276. };
  9277. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9278. /** Gets or sets the headerColor */
  9279. get: function () {
  9280. return this._headerColor;
  9281. },
  9282. set: function (color) {
  9283. if (this._headerColor === color) {
  9284. return;
  9285. }
  9286. this._headerColor = color;
  9287. this._setHeaderColor();
  9288. },
  9289. enumerable: true,
  9290. configurable: true
  9291. });
  9292. SelectionPanel.prototype._setHeaderColor = function () {
  9293. for (var i = 0; i < this._groups.length; i++) {
  9294. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9295. }
  9296. };
  9297. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9298. /** Gets or sets the button color */
  9299. get: function () {
  9300. return this._buttonColor;
  9301. },
  9302. set: function (color) {
  9303. if (this._buttonColor === color) {
  9304. return;
  9305. }
  9306. this._buttonColor = color;
  9307. this._setbuttonColor();
  9308. },
  9309. enumerable: true,
  9310. configurable: true
  9311. });
  9312. SelectionPanel.prototype._setbuttonColor = function () {
  9313. for (var i = 0; i < this._groups.length; i++) {
  9314. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9315. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9316. }
  9317. }
  9318. };
  9319. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9320. /** Gets or sets the label color */
  9321. get: function () {
  9322. return this._labelColor;
  9323. },
  9324. set: function (color) {
  9325. if (this._labelColor === color) {
  9326. return;
  9327. }
  9328. this._labelColor = color;
  9329. this._setLabelColor();
  9330. },
  9331. enumerable: true,
  9332. configurable: true
  9333. });
  9334. SelectionPanel.prototype._setLabelColor = function () {
  9335. for (var i = 0; i < this._groups.length; i++) {
  9336. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9337. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9338. }
  9339. }
  9340. };
  9341. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9342. /** Gets or sets the button background */
  9343. get: function () {
  9344. return this._buttonBackground;
  9345. },
  9346. set: function (color) {
  9347. if (this._buttonBackground === color) {
  9348. return;
  9349. }
  9350. this._buttonBackground = color;
  9351. this._setButtonBackground();
  9352. },
  9353. enumerable: true,
  9354. configurable: true
  9355. });
  9356. SelectionPanel.prototype._setButtonBackground = function () {
  9357. for (var i = 0; i < this._groups.length; i++) {
  9358. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9359. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9360. }
  9361. }
  9362. };
  9363. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9364. /** Gets or sets the color of separator bar */
  9365. get: function () {
  9366. return this._barColor;
  9367. },
  9368. set: function (color) {
  9369. if (this._barColor === color) {
  9370. return;
  9371. }
  9372. this._barColor = color;
  9373. this._setBarColor();
  9374. },
  9375. enumerable: true,
  9376. configurable: true
  9377. });
  9378. SelectionPanel.prototype._setBarColor = function () {
  9379. for (var i = 0; i < this._bars.length; i++) {
  9380. this._bars[i].children[0].background = this._barColor;
  9381. }
  9382. };
  9383. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9384. /** Gets or sets the height of separator bar */
  9385. get: function () {
  9386. return this._barHeight;
  9387. },
  9388. set: function (value) {
  9389. if (this._barHeight === value) {
  9390. return;
  9391. }
  9392. this._barHeight = value;
  9393. this._setBarHeight();
  9394. },
  9395. enumerable: true,
  9396. configurable: true
  9397. });
  9398. SelectionPanel.prototype._setBarHeight = function () {
  9399. for (var i = 0; i < this._bars.length; i++) {
  9400. this._bars[i].children[0].height = this._barHeight;
  9401. }
  9402. };
  9403. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9404. /** Gets or sets the height of spacers*/
  9405. get: function () {
  9406. return this._spacerHeight;
  9407. },
  9408. set: function (value) {
  9409. if (this._spacerHeight === value) {
  9410. return;
  9411. }
  9412. this._spacerHeight = value;
  9413. this._setSpacerHeight();
  9414. },
  9415. enumerable: true,
  9416. configurable: true
  9417. });
  9418. SelectionPanel.prototype._setSpacerHeight = function () {
  9419. for (var i = 0; i < this._bars.length; i++) {
  9420. this._bars[i].height = this._spacerHeight;
  9421. }
  9422. };
  9423. /** Adds a bar between groups */
  9424. SelectionPanel.prototype._addSpacer = function () {
  9425. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9426. separator.width = 1;
  9427. separator.height = this._spacerHeight;
  9428. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9429. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9430. bar.width = 1;
  9431. bar.height = this._barHeight;
  9432. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9433. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9434. bar.background = this._barColor;
  9435. bar.color = "transparent";
  9436. separator.addControl(bar);
  9437. this._panel.addControl(separator);
  9438. this._bars.push(separator);
  9439. };
  9440. /** Add a group to the selection panel
  9441. * @param group is the selector group to add
  9442. */
  9443. SelectionPanel.prototype.addGroup = function (group) {
  9444. if (this._groups.length > 0) {
  9445. this._addSpacer();
  9446. }
  9447. this._panel.addControl(group.groupPanel);
  9448. this._groups.push(group);
  9449. group.groupPanel.children[0].color = this._headerColor;
  9450. for (var j = 0; j < group.selectors.length; j++) {
  9451. group._setSelectorButtonColor(j, this._buttonColor);
  9452. group._setSelectorButtonBackground(j, this._buttonBackground);
  9453. }
  9454. };
  9455. /** Remove the group from the given position
  9456. * @param groupNb is the position of the group in the list
  9457. */
  9458. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9459. if (groupNb < 0 || groupNb >= this._groups.length) {
  9460. return;
  9461. }
  9462. var group = this._groups[groupNb];
  9463. this._panel.removeControl(group.groupPanel);
  9464. this._groups.splice(groupNb, 1);
  9465. if (groupNb < this._bars.length) {
  9466. this._panel.removeControl(this._bars[groupNb]);
  9467. this._bars.splice(groupNb, 1);
  9468. }
  9469. };
  9470. /** Change a group header label
  9471. * @param label is the new group header label
  9472. * @param groupNb is the number of the group to relabel
  9473. * */
  9474. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9475. if (groupNb < 0 || groupNb >= this._groups.length) {
  9476. return;
  9477. }
  9478. var group = this._groups[groupNb];
  9479. group.groupPanel.children[0].text = label;
  9480. };
  9481. /** Change selector label to the one given
  9482. * @param label is the new selector label
  9483. * @param groupNb is the number of the groupcontaining the selector
  9484. * @param selectorNb is the number of the selector within a group to relabel
  9485. * */
  9486. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9487. if (groupNb < 0 || groupNb >= this._groups.length) {
  9488. return;
  9489. }
  9490. var group = this._groups[groupNb];
  9491. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9492. return;
  9493. }
  9494. group._setSelectorLabel(selectorNb, label);
  9495. };
  9496. /** For a given group position remove the selector at the given position
  9497. * @param groupNb is the number of the group to remove the selector from
  9498. * @param selectorNb is the number of the selector within the group
  9499. */
  9500. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9501. if (groupNb < 0 || groupNb >= this._groups.length) {
  9502. return;
  9503. }
  9504. var group = this._groups[groupNb];
  9505. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9506. return;
  9507. }
  9508. group.removeSelector(selectorNb);
  9509. };
  9510. /** For a given group position of correct type add a checkbox button
  9511. * @param groupNb is the number of the group to remove the selector from
  9512. * @param label is the label for the selector
  9513. * @param func is the function called when the Selector is checked
  9514. * @param checked is true when Selector is checked
  9515. */
  9516. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9517. if (func === void 0) { func = function () { }; }
  9518. if (checked === void 0) { checked = false; }
  9519. if (groupNb < 0 || groupNb >= this._groups.length) {
  9520. return;
  9521. }
  9522. var group = this._groups[groupNb];
  9523. group.addCheckbox(label, func, checked);
  9524. };
  9525. /** For a given group position of correct type add a radio button
  9526. * @param groupNb is the number of the group to remove the selector from
  9527. * @param label is the label for the selector
  9528. * @param func is the function called when the Selector is checked
  9529. * @param checked is true when Selector is checked
  9530. */
  9531. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9532. if (func === void 0) { func = function () { }; }
  9533. if (checked === void 0) { checked = false; }
  9534. if (groupNb < 0 || groupNb >= this._groups.length) {
  9535. return;
  9536. }
  9537. var group = this._groups[groupNb];
  9538. group.addRadio(label, func, checked);
  9539. };
  9540. /**
  9541. * For a given slider group add a slider
  9542. * @param groupNb is the number of the group to add the slider to
  9543. * @param label is the label for the Slider
  9544. * @param func is the function called when the Slider moves
  9545. * @param unit is a string describing the units used, eg degrees or metres
  9546. * @param min is the minimum value for the Slider
  9547. * @param max is the maximum value for the Slider
  9548. * @param value is the start value for the Slider between min and max
  9549. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9550. */
  9551. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9552. if (func === void 0) { func = function () { }; }
  9553. if (unit === void 0) { unit = "Units"; }
  9554. if (min === void 0) { min = 0; }
  9555. if (max === void 0) { max = 0; }
  9556. if (value === void 0) { value = 0; }
  9557. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9558. if (groupNb < 0 || groupNb >= this._groups.length) {
  9559. return;
  9560. }
  9561. var group = this._groups[groupNb];
  9562. group.addSlider(label, func, unit, min, max, value, onVal);
  9563. };
  9564. return SelectionPanel;
  9565. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9566. /***/ }),
  9567. /***/ "./2D/controls/sliders/baseSlider.ts":
  9568. /*!*******************************************!*\
  9569. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9570. \*******************************************/
  9571. /*! exports provided: BaseSlider */
  9572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9573. "use strict";
  9574. __webpack_require__.r(__webpack_exports__);
  9575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9579. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9580. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9581. /**
  9582. * Class used to create slider controls
  9583. */
  9584. var BaseSlider = /** @class */ (function (_super) {
  9585. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9586. /**
  9587. * Creates a new BaseSlider
  9588. * @param name defines the control name
  9589. */
  9590. function BaseSlider(name) {
  9591. var _this = _super.call(this, name) || this;
  9592. _this.name = name;
  9593. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9594. _this._minimum = 0;
  9595. _this._maximum = 100;
  9596. _this._value = 50;
  9597. _this._isVertical = false;
  9598. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9599. _this._isThumbClamped = false;
  9600. _this._displayThumb = true;
  9601. // Shared rendering info
  9602. _this._effectiveBarOffset = 0;
  9603. /** Observable raised when the sldier value changes */
  9604. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9605. // Events
  9606. _this._pointerIsDown = false;
  9607. _this.isPointerBlocker = true;
  9608. return _this;
  9609. }
  9610. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9611. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9612. get: function () {
  9613. return this._displayThumb;
  9614. },
  9615. set: function (value) {
  9616. if (this._displayThumb === value) {
  9617. return;
  9618. }
  9619. this._displayThumb = value;
  9620. this._markAsDirty();
  9621. },
  9622. enumerable: true,
  9623. configurable: true
  9624. });
  9625. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9626. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9627. get: function () {
  9628. return this._barOffset.toString(this._host);
  9629. },
  9630. set: function (value) {
  9631. if (this._barOffset.toString(this._host) === value) {
  9632. return;
  9633. }
  9634. if (this._barOffset.fromString(value)) {
  9635. this._markAsDirty();
  9636. }
  9637. },
  9638. enumerable: true,
  9639. configurable: true
  9640. });
  9641. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9642. /** Gets main bar offset in pixels*/
  9643. get: function () {
  9644. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9645. },
  9646. enumerable: true,
  9647. configurable: true
  9648. });
  9649. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9650. /** Gets or sets thumb width */
  9651. get: function () {
  9652. return this._thumbWidth.toString(this._host);
  9653. },
  9654. set: function (value) {
  9655. if (this._thumbWidth.toString(this._host) === value) {
  9656. return;
  9657. }
  9658. if (this._thumbWidth.fromString(value)) {
  9659. this._markAsDirty();
  9660. }
  9661. },
  9662. enumerable: true,
  9663. configurable: true
  9664. });
  9665. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9666. /** Gets thumb width in pixels */
  9667. get: function () {
  9668. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9669. },
  9670. enumerable: true,
  9671. configurable: true
  9672. });
  9673. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9674. /** Gets or sets minimum value */
  9675. get: function () {
  9676. return this._minimum;
  9677. },
  9678. set: function (value) {
  9679. if (this._minimum === value) {
  9680. return;
  9681. }
  9682. this._minimum = value;
  9683. this._markAsDirty();
  9684. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9685. },
  9686. enumerable: true,
  9687. configurable: true
  9688. });
  9689. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9690. /** Gets or sets maximum value */
  9691. get: function () {
  9692. return this._maximum;
  9693. },
  9694. set: function (value) {
  9695. if (this._maximum === value) {
  9696. return;
  9697. }
  9698. this._maximum = value;
  9699. this._markAsDirty();
  9700. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9701. },
  9702. enumerable: true,
  9703. configurable: true
  9704. });
  9705. Object.defineProperty(BaseSlider.prototype, "value", {
  9706. /** Gets or sets current value */
  9707. get: function () {
  9708. return this._value;
  9709. },
  9710. set: function (value) {
  9711. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9712. if (this._value === value) {
  9713. return;
  9714. }
  9715. this._value = value;
  9716. this._markAsDirty();
  9717. this.onValueChangedObservable.notifyObservers(this._value);
  9718. },
  9719. enumerable: true,
  9720. configurable: true
  9721. });
  9722. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9723. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9724. get: function () {
  9725. return this._isVertical;
  9726. },
  9727. set: function (value) {
  9728. if (this._isVertical === value) {
  9729. return;
  9730. }
  9731. this._isVertical = value;
  9732. this._markAsDirty();
  9733. },
  9734. enumerable: true,
  9735. configurable: true
  9736. });
  9737. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9738. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9739. get: function () {
  9740. return this._isThumbClamped;
  9741. },
  9742. set: function (value) {
  9743. if (this._isThumbClamped === value) {
  9744. return;
  9745. }
  9746. this._isThumbClamped = value;
  9747. this._markAsDirty();
  9748. },
  9749. enumerable: true,
  9750. configurable: true
  9751. });
  9752. BaseSlider.prototype._getTypeName = function () {
  9753. return "BaseSlider";
  9754. };
  9755. BaseSlider.prototype._getThumbPosition = function () {
  9756. if (this.isVertical) {
  9757. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9758. }
  9759. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9760. };
  9761. BaseSlider.prototype._getThumbThickness = function (type) {
  9762. var thumbThickness = 0;
  9763. switch (type) {
  9764. case "circle":
  9765. if (this._thumbWidth.isPixel) {
  9766. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9767. }
  9768. else {
  9769. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9770. }
  9771. break;
  9772. case "rectangle":
  9773. if (this._thumbWidth.isPixel) {
  9774. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9775. }
  9776. else {
  9777. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9778. }
  9779. }
  9780. return thumbThickness;
  9781. };
  9782. BaseSlider.prototype._prepareRenderingData = function (type) {
  9783. // Main bar
  9784. this._effectiveBarOffset = 0;
  9785. this._renderLeft = this._currentMeasure.left;
  9786. this._renderTop = this._currentMeasure.top;
  9787. this._renderWidth = this._currentMeasure.width;
  9788. this._renderHeight = this._currentMeasure.height;
  9789. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9790. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9791. this._effectiveThumbThickness = this._getThumbThickness(type);
  9792. if (this.displayThumb) {
  9793. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9794. }
  9795. //throw error when height is less than width for vertical slider
  9796. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9797. console.error("Height should be greater than width");
  9798. return;
  9799. }
  9800. if (this._barOffset.isPixel) {
  9801. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9802. }
  9803. else {
  9804. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9805. }
  9806. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9807. if (this.isVertical) {
  9808. this._renderLeft += this._effectiveBarOffset;
  9809. if (!this.isThumbClamped && this.displayThumb) {
  9810. this._renderTop += (this._effectiveThumbThickness / 2);
  9811. }
  9812. this._renderHeight = this._backgroundBoxLength;
  9813. this._renderWidth = this._backgroundBoxThickness;
  9814. }
  9815. else {
  9816. this._renderTop += this._effectiveBarOffset;
  9817. if (!this.isThumbClamped && this.displayThumb) {
  9818. this._renderLeft += (this._effectiveThumbThickness / 2);
  9819. }
  9820. this._renderHeight = this._backgroundBoxThickness;
  9821. this._renderWidth = this._backgroundBoxLength;
  9822. }
  9823. };
  9824. /** @hidden */
  9825. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9826. if (this.rotation != 0) {
  9827. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9828. x = this._transformedPosition.x;
  9829. y = this._transformedPosition.y;
  9830. }
  9831. if (this._isVertical) {
  9832. this.value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9833. }
  9834. else {
  9835. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9836. }
  9837. };
  9838. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9839. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9840. return false;
  9841. }
  9842. this._pointerIsDown = true;
  9843. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9844. this._host._capturingControl[pointerId] = this;
  9845. return true;
  9846. };
  9847. BaseSlider.prototype._onPointerMove = function (target, coordinates) {
  9848. if (this._pointerIsDown) {
  9849. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9850. }
  9851. _super.prototype._onPointerMove.call(this, target, coordinates);
  9852. };
  9853. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  9854. this._pointerIsDown = false;
  9855. delete this._host._capturingControl[pointerId];
  9856. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  9857. };
  9858. return BaseSlider;
  9859. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9860. /***/ }),
  9861. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  9862. /*!*************************************************!*\
  9863. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  9864. \*************************************************/
  9865. /*! exports provided: ImageBasedSlider */
  9866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9867. "use strict";
  9868. __webpack_require__.r(__webpack_exports__);
  9869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  9870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9871. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  9872. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9873. /**
  9874. * Class used to create slider controls based on images
  9875. */
  9876. var ImageBasedSlider = /** @class */ (function (_super) {
  9877. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  9878. /**
  9879. * Creates a new ImageBasedSlider
  9880. * @param name defines the control name
  9881. */
  9882. function ImageBasedSlider(name) {
  9883. var _this = _super.call(this, name) || this;
  9884. _this.name = name;
  9885. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  9886. return _this;
  9887. }
  9888. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  9889. get: function () {
  9890. return this._displayThumb && this.thumbImage != null;
  9891. },
  9892. set: function (value) {
  9893. if (this._displayThumb === value) {
  9894. return;
  9895. }
  9896. this._displayThumb = value;
  9897. this._markAsDirty();
  9898. },
  9899. enumerable: true,
  9900. configurable: true
  9901. });
  9902. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  9903. /**
  9904. * Gets or sets the image used to render the background
  9905. */
  9906. get: function () {
  9907. return this._backgroundImage;
  9908. },
  9909. set: function (value) {
  9910. var _this = this;
  9911. if (this._backgroundImage === value) {
  9912. return;
  9913. }
  9914. this._backgroundImage = value;
  9915. if (value && !value.isLoaded) {
  9916. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9917. }
  9918. this._markAsDirty();
  9919. },
  9920. enumerable: true,
  9921. configurable: true
  9922. });
  9923. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  9924. /**
  9925. * Gets or sets the image used to render the value bar
  9926. */
  9927. get: function () {
  9928. return this._valueBarImage;
  9929. },
  9930. set: function (value) {
  9931. var _this = this;
  9932. if (this._valueBarImage === value) {
  9933. return;
  9934. }
  9935. this._valueBarImage = value;
  9936. if (value && !value.isLoaded) {
  9937. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9938. }
  9939. this._markAsDirty();
  9940. },
  9941. enumerable: true,
  9942. configurable: true
  9943. });
  9944. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  9945. /**
  9946. * Gets or sets the image used to render the thumb
  9947. */
  9948. get: function () {
  9949. return this._thumbImage;
  9950. },
  9951. set: function (value) {
  9952. var _this = this;
  9953. if (this._thumbImage === value) {
  9954. return;
  9955. }
  9956. this._thumbImage = value;
  9957. if (value && !value.isLoaded) {
  9958. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  9959. }
  9960. this._markAsDirty();
  9961. },
  9962. enumerable: true,
  9963. configurable: true
  9964. });
  9965. ImageBasedSlider.prototype._getTypeName = function () {
  9966. return "ImageBasedSlider";
  9967. };
  9968. ImageBasedSlider.prototype._draw = function (context) {
  9969. context.save();
  9970. this._applyStates(context);
  9971. this._prepareRenderingData("rectangle");
  9972. var thumbPosition = this._getThumbPosition();
  9973. var left = this._renderLeft;
  9974. var top = this._renderTop;
  9975. var width = this._renderWidth;
  9976. var height = this._renderHeight;
  9977. // Background
  9978. if (this._backgroundImage) {
  9979. this._tempMeasure.copyFromFloats(left, top, width, height);
  9980. if (this.isThumbClamped && this.displayThumb) {
  9981. if (this.isVertical) {
  9982. this._tempMeasure.height += this._effectiveThumbThickness;
  9983. }
  9984. else {
  9985. this._tempMeasure.width += this._effectiveThumbThickness;
  9986. }
  9987. }
  9988. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  9989. this._backgroundImage._draw(context);
  9990. }
  9991. // Bar
  9992. if (this._valueBarImage) {
  9993. if (this.isVertical) {
  9994. if (this.isThumbClamped && this.displayThumb) {
  9995. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  9996. }
  9997. else {
  9998. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  9999. }
  10000. }
  10001. else {
  10002. if (this.isThumbClamped && this.displayThumb) {
  10003. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10004. }
  10005. else {
  10006. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10007. }
  10008. }
  10009. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10010. this._valueBarImage._draw(context);
  10011. }
  10012. // Thumb
  10013. if (this.displayThumb) {
  10014. if (this.isVertical) {
  10015. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10016. }
  10017. else {
  10018. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10019. }
  10020. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10021. this._thumbImage._draw(context);
  10022. }
  10023. context.restore();
  10024. };
  10025. return ImageBasedSlider;
  10026. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10027. /***/ }),
  10028. /***/ "./2D/controls/sliders/scrollBar.ts":
  10029. /*!******************************************!*\
  10030. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10031. \******************************************/
  10032. /*! exports provided: ScrollBar */
  10033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10034. "use strict";
  10035. __webpack_require__.r(__webpack_exports__);
  10036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10038. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10039. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10040. /**
  10041. * Class used to create slider controls
  10042. */
  10043. var ScrollBar = /** @class */ (function (_super) {
  10044. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10045. /**
  10046. * Creates a new Slider
  10047. * @param name defines the control name
  10048. */
  10049. function ScrollBar(name) {
  10050. var _this = _super.call(this, name) || this;
  10051. _this.name = name;
  10052. _this._background = "black";
  10053. _this._borderColor = "white";
  10054. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10055. return _this;
  10056. }
  10057. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10058. /** Gets or sets border color */
  10059. get: function () {
  10060. return this._borderColor;
  10061. },
  10062. set: function (value) {
  10063. if (this._borderColor === value) {
  10064. return;
  10065. }
  10066. this._borderColor = value;
  10067. this._markAsDirty();
  10068. },
  10069. enumerable: true,
  10070. configurable: true
  10071. });
  10072. Object.defineProperty(ScrollBar.prototype, "background", {
  10073. /** Gets or sets background color */
  10074. get: function () {
  10075. return this._background;
  10076. },
  10077. set: function (value) {
  10078. if (this._background === value) {
  10079. return;
  10080. }
  10081. this._background = value;
  10082. this._markAsDirty();
  10083. },
  10084. enumerable: true,
  10085. configurable: true
  10086. });
  10087. ScrollBar.prototype._getTypeName = function () {
  10088. return "Scrollbar";
  10089. };
  10090. ScrollBar.prototype._getThumbThickness = function () {
  10091. var thumbThickness = 0;
  10092. if (this._thumbWidth.isPixel) {
  10093. thumbThickness = this._thumbWidth.getValue(this._host);
  10094. }
  10095. else {
  10096. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10097. }
  10098. return thumbThickness;
  10099. };
  10100. ScrollBar.prototype._draw = function (context) {
  10101. context.save();
  10102. this._applyStates(context);
  10103. this._prepareRenderingData("rectangle");
  10104. var left = this._renderLeft;
  10105. var thumbPosition = this._getThumbPosition();
  10106. context.fillStyle = this._background;
  10107. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10108. // Value bar
  10109. context.fillStyle = this.color;
  10110. // Thumb
  10111. if (this.isVertical) {
  10112. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10113. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10114. this._thumbMeasure.width = this._currentMeasure.width;
  10115. this._thumbMeasure.height = this._effectiveThumbThickness;
  10116. }
  10117. else {
  10118. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10119. this._thumbMeasure.top = this._currentMeasure.top;
  10120. this._thumbMeasure.width = this._effectiveThumbThickness;
  10121. this._thumbMeasure.height = this._currentMeasure.height;
  10122. }
  10123. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10124. context.restore();
  10125. };
  10126. /** @hidden */
  10127. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10128. if (this.rotation != 0) {
  10129. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10130. x = this._transformedPosition.x;
  10131. y = this._transformedPosition.y;
  10132. }
  10133. if (this._first) {
  10134. this._first = false;
  10135. this._originX = x;
  10136. this._originY = y;
  10137. // Check if move is required
  10138. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10139. if (this.isVertical) {
  10140. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10141. }
  10142. else {
  10143. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10144. }
  10145. }
  10146. }
  10147. // Delta mode
  10148. var delta = 0;
  10149. if (this.isVertical) {
  10150. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10151. }
  10152. else {
  10153. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10154. }
  10155. this.value += delta * (this.maximum - this.minimum);
  10156. this._originX = x;
  10157. this._originY = y;
  10158. };
  10159. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10160. this._first = true;
  10161. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10162. };
  10163. return ScrollBar;
  10164. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10165. /***/ }),
  10166. /***/ "./2D/controls/sliders/slider.ts":
  10167. /*!***************************************!*\
  10168. !*** ./2D/controls/sliders/slider.ts ***!
  10169. \***************************************/
  10170. /*! exports provided: Slider */
  10171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10172. "use strict";
  10173. __webpack_require__.r(__webpack_exports__);
  10174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10176. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10177. /**
  10178. * Class used to create slider controls
  10179. */
  10180. var Slider = /** @class */ (function (_super) {
  10181. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10182. /**
  10183. * Creates a new Slider
  10184. * @param name defines the control name
  10185. */
  10186. function Slider(name) {
  10187. var _this = _super.call(this, name) || this;
  10188. _this.name = name;
  10189. _this._background = "black";
  10190. _this._borderColor = "white";
  10191. _this._isThumbCircle = false;
  10192. _this._displayValueBar = true;
  10193. return _this;
  10194. }
  10195. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10196. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10197. get: function () {
  10198. return this._displayValueBar;
  10199. },
  10200. set: function (value) {
  10201. if (this._displayValueBar === value) {
  10202. return;
  10203. }
  10204. this._displayValueBar = value;
  10205. this._markAsDirty();
  10206. },
  10207. enumerable: true,
  10208. configurable: true
  10209. });
  10210. Object.defineProperty(Slider.prototype, "borderColor", {
  10211. /** Gets or sets border color */
  10212. get: function () {
  10213. return this._borderColor;
  10214. },
  10215. set: function (value) {
  10216. if (this._borderColor === value) {
  10217. return;
  10218. }
  10219. this._borderColor = value;
  10220. this._markAsDirty();
  10221. },
  10222. enumerable: true,
  10223. configurable: true
  10224. });
  10225. Object.defineProperty(Slider.prototype, "background", {
  10226. /** Gets or sets background color */
  10227. get: function () {
  10228. return this._background;
  10229. },
  10230. set: function (value) {
  10231. if (this._background === value) {
  10232. return;
  10233. }
  10234. this._background = value;
  10235. this._markAsDirty();
  10236. },
  10237. enumerable: true,
  10238. configurable: true
  10239. });
  10240. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10241. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10242. get: function () {
  10243. return this._isThumbCircle;
  10244. },
  10245. set: function (value) {
  10246. if (this._isThumbCircle === value) {
  10247. return;
  10248. }
  10249. this._isThumbCircle = value;
  10250. this._markAsDirty();
  10251. },
  10252. enumerable: true,
  10253. configurable: true
  10254. });
  10255. Slider.prototype._getTypeName = function () {
  10256. return "Slider";
  10257. };
  10258. Slider.prototype._draw = function (context) {
  10259. context.save();
  10260. this._applyStates(context);
  10261. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10262. var left = this._renderLeft;
  10263. var top = this._renderTop;
  10264. var width = this._renderWidth;
  10265. var height = this._renderHeight;
  10266. var radius = 0;
  10267. if (this.isThumbClamped && this.isThumbCircle) {
  10268. if (this.isVertical) {
  10269. top += (this._effectiveThumbThickness / 2);
  10270. }
  10271. else {
  10272. left += (this._effectiveThumbThickness / 2);
  10273. }
  10274. radius = this._backgroundBoxThickness / 2;
  10275. }
  10276. else {
  10277. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10278. }
  10279. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10280. context.shadowColor = this.shadowColor;
  10281. context.shadowBlur = this.shadowBlur;
  10282. context.shadowOffsetX = this.shadowOffsetX;
  10283. context.shadowOffsetY = this.shadowOffsetY;
  10284. }
  10285. var thumbPosition = this._getThumbPosition();
  10286. context.fillStyle = this._background;
  10287. if (this.isVertical) {
  10288. if (this.isThumbClamped) {
  10289. if (this.isThumbCircle) {
  10290. context.beginPath();
  10291. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10292. context.fill();
  10293. context.fillRect(left, top, width, height);
  10294. }
  10295. else {
  10296. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10297. }
  10298. }
  10299. else {
  10300. context.fillRect(left, top, width, height);
  10301. }
  10302. }
  10303. else {
  10304. if (this.isThumbClamped) {
  10305. if (this.isThumbCircle) {
  10306. context.beginPath();
  10307. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10308. context.fill();
  10309. context.fillRect(left, top, width, height);
  10310. }
  10311. else {
  10312. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10313. }
  10314. }
  10315. else {
  10316. context.fillRect(left, top, width, height);
  10317. }
  10318. }
  10319. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10320. context.shadowBlur = 0;
  10321. context.shadowOffsetX = 0;
  10322. context.shadowOffsetY = 0;
  10323. }
  10324. // Value bar
  10325. context.fillStyle = this.color;
  10326. if (this._displayValueBar) {
  10327. if (this.isVertical) {
  10328. if (this.isThumbClamped) {
  10329. if (this.isThumbCircle) {
  10330. context.beginPath();
  10331. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10332. context.fill();
  10333. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10334. }
  10335. else {
  10336. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10337. }
  10338. }
  10339. else {
  10340. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10341. }
  10342. }
  10343. else {
  10344. if (this.isThumbClamped) {
  10345. if (this.isThumbCircle) {
  10346. context.beginPath();
  10347. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10348. context.fill();
  10349. context.fillRect(left, top, thumbPosition, height);
  10350. }
  10351. else {
  10352. context.fillRect(left, top, thumbPosition, height);
  10353. }
  10354. }
  10355. else {
  10356. context.fillRect(left, top, thumbPosition, height);
  10357. }
  10358. }
  10359. }
  10360. // Thumb
  10361. if (this.displayThumb) {
  10362. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10363. context.shadowColor = this.shadowColor;
  10364. context.shadowBlur = this.shadowBlur;
  10365. context.shadowOffsetX = this.shadowOffsetX;
  10366. context.shadowOffsetY = this.shadowOffsetY;
  10367. }
  10368. if (this._isThumbCircle) {
  10369. context.beginPath();
  10370. if (this.isVertical) {
  10371. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10372. }
  10373. else {
  10374. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10375. }
  10376. context.fill();
  10377. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10378. context.shadowBlur = 0;
  10379. context.shadowOffsetX = 0;
  10380. context.shadowOffsetY = 0;
  10381. }
  10382. context.strokeStyle = this._borderColor;
  10383. context.stroke();
  10384. }
  10385. else {
  10386. if (this.isVertical) {
  10387. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10388. }
  10389. else {
  10390. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10391. }
  10392. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10393. context.shadowBlur = 0;
  10394. context.shadowOffsetX = 0;
  10395. context.shadowOffsetY = 0;
  10396. }
  10397. context.strokeStyle = this._borderColor;
  10398. if (this.isVertical) {
  10399. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10400. }
  10401. else {
  10402. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10403. }
  10404. }
  10405. }
  10406. context.restore();
  10407. };
  10408. return Slider;
  10409. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10410. /***/ }),
  10411. /***/ "./2D/controls/stackPanel.ts":
  10412. /*!***********************************!*\
  10413. !*** ./2D/controls/stackPanel.ts ***!
  10414. \***********************************/
  10415. /*! exports provided: StackPanel */
  10416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10417. "use strict";
  10418. __webpack_require__.r(__webpack_exports__);
  10419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10420. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10421. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  10422. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10423. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10424. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10425. /**
  10426. * Class used to create a 2D stack panel container
  10427. */
  10428. var StackPanel = /** @class */ (function (_super) {
  10429. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10430. /**
  10431. * Creates a new StackPanel
  10432. * @param name defines control name
  10433. */
  10434. function StackPanel(name) {
  10435. var _this = _super.call(this, name) || this;
  10436. _this.name = name;
  10437. _this._isVertical = true;
  10438. _this._manualWidth = false;
  10439. _this._manualHeight = false;
  10440. _this._doNotTrackManualChanges = false;
  10441. return _this;
  10442. }
  10443. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10444. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10445. get: function () {
  10446. return this._isVertical;
  10447. },
  10448. set: function (value) {
  10449. if (this._isVertical === value) {
  10450. return;
  10451. }
  10452. this._isVertical = value;
  10453. this._markAsDirty();
  10454. },
  10455. enumerable: true,
  10456. configurable: true
  10457. });
  10458. Object.defineProperty(StackPanel.prototype, "width", {
  10459. get: function () {
  10460. return this._width.toString(this._host);
  10461. },
  10462. /**
  10463. * Gets or sets panel width.
  10464. * This value should not be set when in horizontal mode as it will be computed automatically
  10465. */
  10466. set: function (value) {
  10467. if (!this._doNotTrackManualChanges) {
  10468. this._manualWidth = true;
  10469. }
  10470. if (this._width.toString(this._host) === value) {
  10471. return;
  10472. }
  10473. if (this._width.fromString(value)) {
  10474. this._markAsDirty();
  10475. }
  10476. },
  10477. enumerable: true,
  10478. configurable: true
  10479. });
  10480. Object.defineProperty(StackPanel.prototype, "height", {
  10481. get: function () {
  10482. return this._height.toString(this._host);
  10483. },
  10484. /**
  10485. * Gets or sets panel height.
  10486. * This value should not be set when in vertical mode as it will be computed automatically
  10487. */
  10488. set: function (value) {
  10489. if (!this._doNotTrackManualChanges) {
  10490. this._manualHeight = true;
  10491. }
  10492. if (this._height.toString(this._host) === value) {
  10493. return;
  10494. }
  10495. if (this._height.fromString(value)) {
  10496. this._markAsDirty();
  10497. }
  10498. },
  10499. enumerable: true,
  10500. configurable: true
  10501. });
  10502. StackPanel.prototype._getTypeName = function () {
  10503. return "StackPanel";
  10504. };
  10505. /** @hidden */
  10506. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10507. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10508. var child = _a[_i];
  10509. if (this._isVertical) {
  10510. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10511. }
  10512. else {
  10513. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10514. }
  10515. }
  10516. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10517. };
  10518. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10519. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10520. this._measureForChildren.copyFrom(parentMeasure);
  10521. this._measureForChildren.left = this._currentMeasure.left;
  10522. this._measureForChildren.top = this._currentMeasure.top;
  10523. if (!this.isVertical || this._manualWidth) {
  10524. this._measureForChildren.width = this._currentMeasure.width;
  10525. }
  10526. if (this.isVertical || this._manualHeight) {
  10527. this._measureForChildren.height = this._currentMeasure.height;
  10528. }
  10529. };
  10530. StackPanel.prototype._postMeasure = function () {
  10531. var stackWidth = 0;
  10532. var stackHeight = 0;
  10533. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10534. var child = _a[_i];
  10535. if (!child.isVisible || child.notRenderable) {
  10536. continue;
  10537. }
  10538. if (this._isVertical) {
  10539. if (child.top !== stackHeight + "px") {
  10540. child.top = stackHeight + "px";
  10541. this._rebuildLayout = true;
  10542. child._top.ignoreAdaptiveScaling = true;
  10543. }
  10544. if (child._height.isPercentage) {
  10545. 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");
  10546. }
  10547. else {
  10548. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10549. }
  10550. }
  10551. else {
  10552. if (child.left !== stackWidth + "px") {
  10553. child.left = stackWidth + "px";
  10554. this._rebuildLayout = true;
  10555. child._left.ignoreAdaptiveScaling = true;
  10556. }
  10557. if (child._width.isPercentage) {
  10558. 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");
  10559. }
  10560. else {
  10561. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10562. }
  10563. }
  10564. }
  10565. this._doNotTrackManualChanges = true;
  10566. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10567. // User can now define their own height and width for stack panel.
  10568. var panelWidthChanged = false;
  10569. var panelHeightChanged = false;
  10570. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10571. var previousHeight = this.height;
  10572. this.height = stackHeight + "px";
  10573. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10574. }
  10575. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10576. var previousWidth = this.width;
  10577. this.width = stackWidth + "px";
  10578. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10579. }
  10580. if (panelHeightChanged) {
  10581. this._height.ignoreAdaptiveScaling = true;
  10582. }
  10583. if (panelWidthChanged) {
  10584. this._width.ignoreAdaptiveScaling = true;
  10585. }
  10586. this._doNotTrackManualChanges = false;
  10587. if (panelWidthChanged || panelHeightChanged) {
  10588. this._rebuildLayout = true;
  10589. }
  10590. _super.prototype._postMeasure.call(this);
  10591. };
  10592. return StackPanel;
  10593. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10594. /***/ }),
  10595. /***/ "./2D/controls/statics.ts":
  10596. /*!********************************!*\
  10597. !*** ./2D/controls/statics.ts ***!
  10598. \********************************/
  10599. /*! exports provided: name */
  10600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10601. "use strict";
  10602. __webpack_require__.r(__webpack_exports__);
  10603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10604. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10605. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10606. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10607. /**
  10608. * Forcing an export so that this code will execute
  10609. * @hidden
  10610. */
  10611. var name = "Statics";
  10612. /**
  10613. * Creates a stack panel that can be used to render headers
  10614. * @param control defines the control to associate with the header
  10615. * @param text defines the text of the header
  10616. * @param size defines the size of the header
  10617. * @param options defines options used to configure the header
  10618. * @returns a new StackPanel
  10619. */
  10620. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10621. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10622. var isHorizontal = options ? options.isHorizontal : true;
  10623. var controlFirst = options ? options.controlFirst : true;
  10624. panel.isVertical = !isHorizontal;
  10625. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10626. header.text = text;
  10627. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10628. if (isHorizontal) {
  10629. header.width = size;
  10630. }
  10631. else {
  10632. header.height = size;
  10633. }
  10634. if (controlFirst) {
  10635. panel.addControl(control);
  10636. panel.addControl(header);
  10637. header.paddingLeft = "5px";
  10638. }
  10639. else {
  10640. panel.addControl(header);
  10641. panel.addControl(control);
  10642. header.paddingRight = "5px";
  10643. }
  10644. header.shadowBlur = control.shadowBlur;
  10645. header.shadowColor = control.shadowColor;
  10646. header.shadowOffsetX = control.shadowOffsetX;
  10647. header.shadowOffsetY = control.shadowOffsetY;
  10648. return panel;
  10649. };
  10650. /***/ }),
  10651. /***/ "./2D/controls/textBlock.ts":
  10652. /*!**********************************!*\
  10653. !*** ./2D/controls/textBlock.ts ***!
  10654. \**********************************/
  10655. /*! exports provided: TextWrapping, TextBlock */
  10656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10657. "use strict";
  10658. __webpack_require__.r(__webpack_exports__);
  10659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10661. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10662. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10663. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10664. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10665. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10666. /**
  10667. * Enum that determines the text-wrapping mode to use.
  10668. */
  10669. var TextWrapping;
  10670. (function (TextWrapping) {
  10671. /**
  10672. * Clip the text when it's larger than Control.width; this is the default mode.
  10673. */
  10674. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10675. /**
  10676. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10677. */
  10678. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10679. /**
  10680. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10681. */
  10682. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10683. })(TextWrapping || (TextWrapping = {}));
  10684. /**
  10685. * Class used to create text block control
  10686. */
  10687. var TextBlock = /** @class */ (function (_super) {
  10688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10689. /**
  10690. * Creates a new TextBlock object
  10691. * @param name defines the name of the control
  10692. * @param text defines the text to display (emptry string by default)
  10693. */
  10694. function TextBlock(
  10695. /**
  10696. * Defines the name of the control
  10697. */
  10698. name, text) {
  10699. if (text === void 0) { text = ""; }
  10700. var _this = _super.call(this, name) || this;
  10701. _this.name = name;
  10702. _this._text = "";
  10703. _this._textWrapping = TextWrapping.Clip;
  10704. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10705. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10706. _this._resizeToFit = false;
  10707. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10708. _this._outlineWidth = 0;
  10709. _this._outlineColor = "white";
  10710. /**
  10711. * An event triggered after the text is changed
  10712. */
  10713. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10714. /**
  10715. * An event triggered after the text was broken up into lines
  10716. */
  10717. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10718. _this.text = text;
  10719. return _this;
  10720. }
  10721. Object.defineProperty(TextBlock.prototype, "lines", {
  10722. /**
  10723. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10724. */
  10725. get: function () {
  10726. return this._lines;
  10727. },
  10728. enumerable: true,
  10729. configurable: true
  10730. });
  10731. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10732. /**
  10733. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10734. */
  10735. get: function () {
  10736. return this._resizeToFit;
  10737. },
  10738. /**
  10739. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10740. */
  10741. set: function (value) {
  10742. if (this._resizeToFit === value) {
  10743. return;
  10744. }
  10745. this._resizeToFit = value;
  10746. if (this._resizeToFit) {
  10747. this._width.ignoreAdaptiveScaling = true;
  10748. this._height.ignoreAdaptiveScaling = true;
  10749. }
  10750. this._markAsDirty();
  10751. },
  10752. enumerable: true,
  10753. configurable: true
  10754. });
  10755. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10756. /**
  10757. * Gets or sets a boolean indicating if text must be wrapped
  10758. */
  10759. get: function () {
  10760. return this._textWrapping;
  10761. },
  10762. /**
  10763. * Gets or sets a boolean indicating if text must be wrapped
  10764. */
  10765. set: function (value) {
  10766. if (this._textWrapping === value) {
  10767. return;
  10768. }
  10769. this._textWrapping = +value;
  10770. this._markAsDirty();
  10771. },
  10772. enumerable: true,
  10773. configurable: true
  10774. });
  10775. Object.defineProperty(TextBlock.prototype, "text", {
  10776. /**
  10777. * Gets or sets text to display
  10778. */
  10779. get: function () {
  10780. return this._text;
  10781. },
  10782. /**
  10783. * Gets or sets text to display
  10784. */
  10785. set: function (value) {
  10786. if (this._text === value) {
  10787. return;
  10788. }
  10789. this._text = value;
  10790. this._markAsDirty();
  10791. this.onTextChangedObservable.notifyObservers(this);
  10792. },
  10793. enumerable: true,
  10794. configurable: true
  10795. });
  10796. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10797. /**
  10798. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10799. */
  10800. get: function () {
  10801. return this._textHorizontalAlignment;
  10802. },
  10803. /**
  10804. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10805. */
  10806. set: function (value) {
  10807. if (this._textHorizontalAlignment === value) {
  10808. return;
  10809. }
  10810. this._textHorizontalAlignment = value;
  10811. this._markAsDirty();
  10812. },
  10813. enumerable: true,
  10814. configurable: true
  10815. });
  10816. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10817. /**
  10818. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10819. */
  10820. get: function () {
  10821. return this._textVerticalAlignment;
  10822. },
  10823. /**
  10824. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10825. */
  10826. set: function (value) {
  10827. if (this._textVerticalAlignment === value) {
  10828. return;
  10829. }
  10830. this._textVerticalAlignment = value;
  10831. this._markAsDirty();
  10832. },
  10833. enumerable: true,
  10834. configurable: true
  10835. });
  10836. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10837. /**
  10838. * Gets or sets line spacing value
  10839. */
  10840. get: function () {
  10841. return this._lineSpacing.toString(this._host);
  10842. },
  10843. /**
  10844. * Gets or sets line spacing value
  10845. */
  10846. set: function (value) {
  10847. if (this._lineSpacing.fromString(value)) {
  10848. this._markAsDirty();
  10849. }
  10850. },
  10851. enumerable: true,
  10852. configurable: true
  10853. });
  10854. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  10855. /**
  10856. * Gets or sets outlineWidth of the text to display
  10857. */
  10858. get: function () {
  10859. return this._outlineWidth;
  10860. },
  10861. /**
  10862. * Gets or sets outlineWidth of the text to display
  10863. */
  10864. set: function (value) {
  10865. if (this._outlineWidth === value) {
  10866. return;
  10867. }
  10868. this._outlineWidth = value;
  10869. this._markAsDirty();
  10870. },
  10871. enumerable: true,
  10872. configurable: true
  10873. });
  10874. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  10875. /**
  10876. * Gets or sets outlineColor of the text to display
  10877. */
  10878. get: function () {
  10879. return this._outlineColor;
  10880. },
  10881. /**
  10882. * Gets or sets outlineColor of the text to display
  10883. */
  10884. set: function (value) {
  10885. if (this._outlineColor === value) {
  10886. return;
  10887. }
  10888. this._outlineColor = value;
  10889. this._markAsDirty();
  10890. },
  10891. enumerable: true,
  10892. configurable: true
  10893. });
  10894. TextBlock.prototype._getTypeName = function () {
  10895. return "TextBlock";
  10896. };
  10897. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  10898. if (!this._fontOffset) {
  10899. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  10900. }
  10901. _super.prototype._processMeasures.call(this, parentMeasure, context);
  10902. // Prepare lines
  10903. this._lines = this._breakLines(this._currentMeasure.width, context);
  10904. this.onLinesReadyObservable.notifyObservers(this);
  10905. var maxLineWidth = 0;
  10906. for (var i = 0; i < this._lines.length; i++) {
  10907. var line = this._lines[i];
  10908. if (line.width > maxLineWidth) {
  10909. maxLineWidth = line.width;
  10910. }
  10911. }
  10912. if (this._resizeToFit) {
  10913. if (this._textWrapping === TextWrapping.Clip) {
  10914. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  10915. if (newWidth !== this._width.internalValue) {
  10916. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10917. this._rebuildLayout = true;
  10918. }
  10919. }
  10920. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  10921. if (newHeight !== this._height.internalValue) {
  10922. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  10923. this._rebuildLayout = true;
  10924. }
  10925. }
  10926. };
  10927. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  10928. var width = this._currentMeasure.width;
  10929. var x = 0;
  10930. switch (this._textHorizontalAlignment) {
  10931. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  10932. x = 0;
  10933. break;
  10934. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  10935. x = width - textWidth;
  10936. break;
  10937. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  10938. x = (width - textWidth) / 2;
  10939. break;
  10940. }
  10941. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10942. context.shadowColor = this.shadowColor;
  10943. context.shadowBlur = this.shadowBlur;
  10944. context.shadowOffsetX = this.shadowOffsetX;
  10945. context.shadowOffsetY = this.shadowOffsetY;
  10946. }
  10947. if (this.outlineWidth) {
  10948. context.strokeText(text, this._currentMeasure.left + x, y);
  10949. }
  10950. context.fillText(text, this._currentMeasure.left + x, y);
  10951. };
  10952. /** @hidden */
  10953. TextBlock.prototype._draw = function (context) {
  10954. context.save();
  10955. this._applyStates(context);
  10956. // Render lines
  10957. this._renderLines(context);
  10958. context.restore();
  10959. };
  10960. TextBlock.prototype._applyStates = function (context) {
  10961. _super.prototype._applyStates.call(this, context);
  10962. if (this.outlineWidth) {
  10963. context.lineWidth = this.outlineWidth;
  10964. context.strokeStyle = this.outlineColor;
  10965. }
  10966. };
  10967. TextBlock.prototype._breakLines = function (refWidth, context) {
  10968. var lines = [];
  10969. var _lines = this.text.split("\n");
  10970. if (this._textWrapping === TextWrapping.Ellipsis) {
  10971. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  10972. var _line = _lines_1[_i];
  10973. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  10974. }
  10975. }
  10976. else if (this._textWrapping === TextWrapping.WordWrap) {
  10977. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  10978. var _line = _lines_2[_a];
  10979. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  10980. }
  10981. }
  10982. else {
  10983. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  10984. var _line = _lines_3[_b];
  10985. lines.push(this._parseLine(_line, context));
  10986. }
  10987. }
  10988. return lines;
  10989. };
  10990. TextBlock.prototype._parseLine = function (line, context) {
  10991. if (line === void 0) { line = ''; }
  10992. return { text: line, width: context.measureText(line).width };
  10993. };
  10994. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  10995. if (line === void 0) { line = ''; }
  10996. var lineWidth = context.measureText(line).width;
  10997. if (lineWidth > width) {
  10998. line += '…';
  10999. }
  11000. while (line.length > 2 && lineWidth > width) {
  11001. line = line.slice(0, -2) + '…';
  11002. lineWidth = context.measureText(line).width;
  11003. }
  11004. return { text: line, width: lineWidth };
  11005. };
  11006. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11007. if (line === void 0) { line = ''; }
  11008. var lines = [];
  11009. var words = line.split(' ');
  11010. var lineWidth = 0;
  11011. for (var n = 0; n < words.length; n++) {
  11012. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11013. var metrics = context.measureText(testLine);
  11014. var testWidth = metrics.width;
  11015. if (testWidth > width && n > 0) {
  11016. lines.push({ text: line, width: lineWidth });
  11017. line = words[n];
  11018. lineWidth = context.measureText(line).width;
  11019. }
  11020. else {
  11021. lineWidth = testWidth;
  11022. line = testLine;
  11023. }
  11024. }
  11025. lines.push({ text: line, width: lineWidth });
  11026. return lines;
  11027. };
  11028. TextBlock.prototype._renderLines = function (context) {
  11029. var height = this._currentMeasure.height;
  11030. var rootY = 0;
  11031. switch (this._textVerticalAlignment) {
  11032. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11033. rootY = this._fontOffset.ascent;
  11034. break;
  11035. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11036. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11037. break;
  11038. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11039. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11040. break;
  11041. }
  11042. rootY += this._currentMeasure.top;
  11043. for (var i = 0; i < this._lines.length; i++) {
  11044. var line = this._lines[i];
  11045. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11046. if (this._lineSpacing.isPixel) {
  11047. rootY += this._lineSpacing.getValue(this._host);
  11048. }
  11049. else {
  11050. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11051. }
  11052. }
  11053. this._drawText(line.text, line.width, rootY, context);
  11054. rootY += this._fontOffset.height;
  11055. }
  11056. };
  11057. /**
  11058. * Given a width constraint applied on the text block, find the expected height
  11059. * @returns expected height
  11060. */
  11061. TextBlock.prototype.computeExpectedHeight = function () {
  11062. if (this.text && this.widthInPixels) {
  11063. var context_1 = document.createElement('canvas').getContext('2d');
  11064. if (context_1) {
  11065. this._applyStates(context_1);
  11066. if (!this._fontOffset) {
  11067. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11068. }
  11069. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11070. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11071. }
  11072. }
  11073. return 0;
  11074. };
  11075. TextBlock.prototype.dispose = function () {
  11076. _super.prototype.dispose.call(this);
  11077. this.onTextChangedObservable.clear();
  11078. };
  11079. return TextBlock;
  11080. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11081. /***/ }),
  11082. /***/ "./2D/controls/virtualKeyboard.ts":
  11083. /*!****************************************!*\
  11084. !*** ./2D/controls/virtualKeyboard.ts ***!
  11085. \****************************************/
  11086. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11088. "use strict";
  11089. __webpack_require__.r(__webpack_exports__);
  11090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11093. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11094. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11095. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11096. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11097. /**
  11098. * Class used to store key control properties
  11099. */
  11100. var KeyPropertySet = /** @class */ (function () {
  11101. function KeyPropertySet() {
  11102. }
  11103. return KeyPropertySet;
  11104. }());
  11105. /**
  11106. * Class used to create virtual keyboard
  11107. */
  11108. var VirtualKeyboard = /** @class */ (function (_super) {
  11109. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11110. function VirtualKeyboard() {
  11111. var _this = _super !== null && _super.apply(this, arguments) || this;
  11112. /** Observable raised when a key is pressed */
  11113. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11114. /** Gets or sets default key button width */
  11115. _this.defaultButtonWidth = "40px";
  11116. /** Gets or sets default key button height */
  11117. _this.defaultButtonHeight = "40px";
  11118. /** Gets or sets default key button left padding */
  11119. _this.defaultButtonPaddingLeft = "2px";
  11120. /** Gets or sets default key button right padding */
  11121. _this.defaultButtonPaddingRight = "2px";
  11122. /** Gets or sets default key button top padding */
  11123. _this.defaultButtonPaddingTop = "2px";
  11124. /** Gets or sets default key button bottom padding */
  11125. _this.defaultButtonPaddingBottom = "2px";
  11126. /** Gets or sets default key button foreground color */
  11127. _this.defaultButtonColor = "#DDD";
  11128. /** Gets or sets default key button background color */
  11129. _this.defaultButtonBackground = "#070707";
  11130. /** Gets or sets shift button foreground color */
  11131. _this.shiftButtonColor = "#7799FF";
  11132. /** Gets or sets shift button thickness*/
  11133. _this.selectedShiftThickness = 1;
  11134. /** Gets shift key state */
  11135. _this.shiftState = 0;
  11136. _this._currentlyConnectedInputText = null;
  11137. _this._connectedInputTexts = [];
  11138. _this._onKeyPressObserver = null;
  11139. return _this;
  11140. }
  11141. VirtualKeyboard.prototype._getTypeName = function () {
  11142. return "VirtualKeyboard";
  11143. };
  11144. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11145. var _this = this;
  11146. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11147. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11148. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11149. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11150. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11151. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11152. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11153. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11154. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11155. button.thickness = 0;
  11156. button.isFocusInvisible = true;
  11157. button.shadowColor = this.shadowColor;
  11158. button.shadowBlur = this.shadowBlur;
  11159. button.shadowOffsetX = this.shadowOffsetX;
  11160. button.shadowOffsetY = this.shadowOffsetY;
  11161. button.onPointerUpObservable.add(function () {
  11162. _this.onKeyPressObservable.notifyObservers(key);
  11163. });
  11164. return button;
  11165. };
  11166. /**
  11167. * Adds a new row of keys
  11168. * @param keys defines the list of keys to add
  11169. * @param propertySets defines the associated property sets
  11170. */
  11171. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11172. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11173. panel.isVertical = false;
  11174. panel.isFocusInvisible = true;
  11175. for (var i = 0; i < keys.length; i++) {
  11176. var properties = null;
  11177. if (propertySets && propertySets.length === keys.length) {
  11178. properties = propertySets[i];
  11179. }
  11180. panel.addControl(this._createKey(keys[i], properties));
  11181. }
  11182. this.addControl(panel);
  11183. };
  11184. /**
  11185. * Set the shift key to a specific state
  11186. * @param shiftState defines the new shift state
  11187. */
  11188. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11189. if (!this.children) {
  11190. return;
  11191. }
  11192. for (var i = 0; i < this.children.length; i++) {
  11193. var row = this.children[i];
  11194. if (!row || !row.children) {
  11195. continue;
  11196. }
  11197. var rowContainer = row;
  11198. for (var j = 0; j < rowContainer.children.length; j++) {
  11199. var button = rowContainer.children[j];
  11200. if (!button || !button.children[0]) {
  11201. continue;
  11202. }
  11203. var button_tblock = button.children[0];
  11204. if (button_tblock.text === "\u21E7") {
  11205. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11206. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11207. }
  11208. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11209. }
  11210. }
  11211. };
  11212. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11213. /** Gets the input text control currently attached to the keyboard */
  11214. get: function () {
  11215. return this._currentlyConnectedInputText;
  11216. },
  11217. enumerable: true,
  11218. configurable: true
  11219. });
  11220. /**
  11221. * Connects the keyboard with an input text control
  11222. *
  11223. * @param input defines the target control
  11224. */
  11225. VirtualKeyboard.prototype.connect = function (input) {
  11226. var _this = this;
  11227. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11228. if (inputTextAlreadyConnected) {
  11229. return;
  11230. }
  11231. if (this._onKeyPressObserver === null) {
  11232. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11233. if (!_this._currentlyConnectedInputText) {
  11234. return;
  11235. }
  11236. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11237. switch (key) {
  11238. case "\u21E7":
  11239. _this.shiftState++;
  11240. if (_this.shiftState > 2) {
  11241. _this.shiftState = 0;
  11242. }
  11243. _this.applyShiftState(_this.shiftState);
  11244. return;
  11245. case "\u2190":
  11246. _this._currentlyConnectedInputText.processKey(8);
  11247. return;
  11248. case "\u21B5":
  11249. _this._currentlyConnectedInputText.processKey(13);
  11250. return;
  11251. }
  11252. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11253. if (_this.shiftState === 1) {
  11254. _this.shiftState = 0;
  11255. _this.applyShiftState(_this.shiftState);
  11256. }
  11257. });
  11258. }
  11259. this.isVisible = false;
  11260. this._currentlyConnectedInputText = input;
  11261. input._connectedVirtualKeyboard = this;
  11262. // Events hooking
  11263. var onFocusObserver = input.onFocusObservable.add(function () {
  11264. _this._currentlyConnectedInputText = input;
  11265. input._connectedVirtualKeyboard = _this;
  11266. _this.isVisible = true;
  11267. });
  11268. var onBlurObserver = input.onBlurObservable.add(function () {
  11269. input._connectedVirtualKeyboard = null;
  11270. _this._currentlyConnectedInputText = null;
  11271. _this.isVisible = false;
  11272. });
  11273. this._connectedInputTexts.push({
  11274. input: input,
  11275. onBlurObserver: onBlurObserver,
  11276. onFocusObserver: onFocusObserver
  11277. });
  11278. };
  11279. /**
  11280. * Disconnects the keyboard from connected InputText controls
  11281. *
  11282. * @param input optionally defines a target control, otherwise all are disconnected
  11283. */
  11284. VirtualKeyboard.prototype.disconnect = function (input) {
  11285. var _this = this;
  11286. if (input) {
  11287. // .find not available on IE
  11288. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11289. if (filtered.length === 1) {
  11290. this._removeConnectedInputObservables(filtered[0]);
  11291. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11292. if (this._currentlyConnectedInputText === input) {
  11293. this._currentlyConnectedInputText = null;
  11294. }
  11295. }
  11296. }
  11297. else {
  11298. this._connectedInputTexts.forEach(function (connectedInputText) {
  11299. _this._removeConnectedInputObservables(connectedInputText);
  11300. });
  11301. this._connectedInputTexts = [];
  11302. }
  11303. if (this._connectedInputTexts.length === 0) {
  11304. this._currentlyConnectedInputText = null;
  11305. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11306. this._onKeyPressObserver = null;
  11307. }
  11308. };
  11309. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11310. connectedInputText.input._connectedVirtualKeyboard = null;
  11311. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11312. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11313. };
  11314. /**
  11315. * Release all resources
  11316. */
  11317. VirtualKeyboard.prototype.dispose = function () {
  11318. _super.prototype.dispose.call(this);
  11319. this.disconnect();
  11320. };
  11321. // Statics
  11322. /**
  11323. * Creates a new keyboard using a default layout
  11324. *
  11325. * @param name defines control name
  11326. * @returns a new VirtualKeyboard
  11327. */
  11328. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11329. var returnValue = new VirtualKeyboard(name);
  11330. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11331. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11332. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11333. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11334. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11335. return returnValue;
  11336. };
  11337. return VirtualKeyboard;
  11338. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11339. /***/ }),
  11340. /***/ "./2D/index.ts":
  11341. /*!*********************!*\
  11342. !*** ./2D/index.ts ***!
  11343. \*********************/
  11344. /*! 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 */
  11345. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11346. "use strict";
  11347. __webpack_require__.r(__webpack_exports__);
  11348. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11379. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11381. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11383. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11386. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11388. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11390. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11392. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11394. /***/ }),
  11395. /***/ "./2D/math2D.ts":
  11396. /*!**********************!*\
  11397. !*** ./2D/math2D.ts ***!
  11398. \**********************/
  11399. /*! exports provided: Vector2WithInfo, Matrix2D */
  11400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11401. "use strict";
  11402. __webpack_require__.r(__webpack_exports__);
  11403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11406. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11407. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11408. /**
  11409. * Class used to transport Vector2 information for pointer events
  11410. */
  11411. var Vector2WithInfo = /** @class */ (function (_super) {
  11412. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11413. /**
  11414. * Creates a new Vector2WithInfo
  11415. * @param source defines the vector2 data to transport
  11416. * @param buttonIndex defines the current mouse button index
  11417. */
  11418. function Vector2WithInfo(source,
  11419. /** defines the current mouse button index */
  11420. buttonIndex) {
  11421. if (buttonIndex === void 0) { buttonIndex = 0; }
  11422. var _this = _super.call(this, source.x, source.y) || this;
  11423. _this.buttonIndex = buttonIndex;
  11424. return _this;
  11425. }
  11426. return Vector2WithInfo;
  11427. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11428. /** Class used to provide 2D matrix features */
  11429. var Matrix2D = /** @class */ (function () {
  11430. /**
  11431. * Creates a new matrix
  11432. * @param m00 defines value for (0, 0)
  11433. * @param m01 defines value for (0, 1)
  11434. * @param m10 defines value for (1, 0)
  11435. * @param m11 defines value for (1, 1)
  11436. * @param m20 defines value for (2, 0)
  11437. * @param m21 defines value for (2, 1)
  11438. */
  11439. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11440. /** Gets the internal array of 6 floats used to store matrix data */
  11441. this.m = new Float32Array(6);
  11442. this.fromValues(m00, m01, m10, m11, m20, m21);
  11443. }
  11444. /**
  11445. * Fills the matrix from direct values
  11446. * @param m00 defines value for (0, 0)
  11447. * @param m01 defines value for (0, 1)
  11448. * @param m10 defines value for (1, 0)
  11449. * @param m11 defines value for (1, 1)
  11450. * @param m20 defines value for (2, 0)
  11451. * @param m21 defines value for (2, 1)
  11452. * @returns the current modified matrix
  11453. */
  11454. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11455. this.m[0] = m00;
  11456. this.m[1] = m01;
  11457. this.m[2] = m10;
  11458. this.m[3] = m11;
  11459. this.m[4] = m20;
  11460. this.m[5] = m21;
  11461. return this;
  11462. };
  11463. /**
  11464. * Gets matrix determinant
  11465. * @returns the determinant
  11466. */
  11467. Matrix2D.prototype.determinant = function () {
  11468. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11469. };
  11470. /**
  11471. * Inverses the matrix and stores it in a target matrix
  11472. * @param result defines the target matrix
  11473. * @returns the current matrix
  11474. */
  11475. Matrix2D.prototype.invertToRef = function (result) {
  11476. var l0 = this.m[0];
  11477. var l1 = this.m[1];
  11478. var l2 = this.m[2];
  11479. var l3 = this.m[3];
  11480. var l4 = this.m[4];
  11481. var l5 = this.m[5];
  11482. var det = this.determinant();
  11483. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11484. result.m[0] = 0;
  11485. result.m[1] = 0;
  11486. result.m[2] = 0;
  11487. result.m[3] = 0;
  11488. result.m[4] = 0;
  11489. result.m[5] = 0;
  11490. return this;
  11491. }
  11492. var detDiv = 1 / det;
  11493. var det4 = l2 * l5 - l3 * l4;
  11494. var det5 = l1 * l4 - l0 * l5;
  11495. result.m[0] = l3 * detDiv;
  11496. result.m[1] = -l1 * detDiv;
  11497. result.m[2] = -l2 * detDiv;
  11498. result.m[3] = l0 * detDiv;
  11499. result.m[4] = det4 * detDiv;
  11500. result.m[5] = det5 * detDiv;
  11501. return this;
  11502. };
  11503. /**
  11504. * Multiplies the current matrix with another one
  11505. * @param other defines the second operand
  11506. * @param result defines the target matrix
  11507. * @returns the current matrix
  11508. */
  11509. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11510. var l0 = this.m[0];
  11511. var l1 = this.m[1];
  11512. var l2 = this.m[2];
  11513. var l3 = this.m[3];
  11514. var l4 = this.m[4];
  11515. var l5 = this.m[5];
  11516. var r0 = other.m[0];
  11517. var r1 = other.m[1];
  11518. var r2 = other.m[2];
  11519. var r3 = other.m[3];
  11520. var r4 = other.m[4];
  11521. var r5 = other.m[5];
  11522. result.m[0] = l0 * r0 + l1 * r2;
  11523. result.m[1] = l0 * r1 + l1 * r3;
  11524. result.m[2] = l2 * r0 + l3 * r2;
  11525. result.m[3] = l2 * r1 + l3 * r3;
  11526. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11527. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11528. return this;
  11529. };
  11530. /**
  11531. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11532. * @param x defines the x coordinate to transform
  11533. * @param y defines the x coordinate to transform
  11534. * @param result defines the target vector2
  11535. * @returns the current matrix
  11536. */
  11537. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11538. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11539. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11540. return this;
  11541. };
  11542. // Statics
  11543. /**
  11544. * Creates an identity matrix
  11545. * @returns a new matrix
  11546. */
  11547. Matrix2D.Identity = function () {
  11548. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11549. };
  11550. /**
  11551. * Creates a translation matrix and stores it in a target matrix
  11552. * @param x defines the x coordinate of the translation
  11553. * @param y defines the y coordinate of the translation
  11554. * @param result defines the target matrix
  11555. */
  11556. Matrix2D.TranslationToRef = function (x, y, result) {
  11557. result.fromValues(1, 0, 0, 1, x, y);
  11558. };
  11559. /**
  11560. * Creates a scaling matrix and stores it in a target matrix
  11561. * @param x defines the x coordinate of the scaling
  11562. * @param y defines the y coordinate of the scaling
  11563. * @param result defines the target matrix
  11564. */
  11565. Matrix2D.ScalingToRef = function (x, y, result) {
  11566. result.fromValues(x, 0, 0, y, 0, 0);
  11567. };
  11568. /**
  11569. * Creates a rotation matrix and stores it in a target matrix
  11570. * @param angle defines the rotation angle
  11571. * @param result defines the target matrix
  11572. */
  11573. Matrix2D.RotationToRef = function (angle, result) {
  11574. var s = Math.sin(angle);
  11575. var c = Math.cos(angle);
  11576. result.fromValues(c, s, -s, c, 0, 0);
  11577. };
  11578. /**
  11579. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11580. * @param tx defines the x coordinate of the translation
  11581. * @param ty defines the y coordinate of the translation
  11582. * @param angle defines the rotation angle
  11583. * @param scaleX defines the x coordinate of the scaling
  11584. * @param scaleY defines the y coordinate of the scaling
  11585. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11586. * @param result defines the target matrix
  11587. */
  11588. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11589. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11590. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11591. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11592. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11593. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11594. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11595. if (parentMatrix) {
  11596. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11597. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11598. }
  11599. else {
  11600. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11601. }
  11602. };
  11603. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11604. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11605. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11606. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11607. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11608. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11609. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11610. return Matrix2D;
  11611. }());
  11612. /***/ }),
  11613. /***/ "./2D/measure.ts":
  11614. /*!***********************!*\
  11615. !*** ./2D/measure.ts ***!
  11616. \***********************/
  11617. /*! exports provided: Measure */
  11618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11619. "use strict";
  11620. __webpack_require__.r(__webpack_exports__);
  11621. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11622. /**
  11623. * Class used to store 2D control sizes
  11624. */
  11625. var Measure = /** @class */ (function () {
  11626. /**
  11627. * Creates a new measure
  11628. * @param left defines left coordinate
  11629. * @param top defines top coordinate
  11630. * @param width defines width dimension
  11631. * @param height defines height dimension
  11632. */
  11633. function Measure(
  11634. /** defines left coordinate */
  11635. left,
  11636. /** defines top coordinate */
  11637. top,
  11638. /** defines width dimension */
  11639. width,
  11640. /** defines height dimension */
  11641. height) {
  11642. this.left = left;
  11643. this.top = top;
  11644. this.width = width;
  11645. this.height = height;
  11646. }
  11647. /**
  11648. * Copy from another measure
  11649. * @param other defines the other measure to copy from
  11650. */
  11651. Measure.prototype.copyFrom = function (other) {
  11652. this.left = other.left;
  11653. this.top = other.top;
  11654. this.width = other.width;
  11655. this.height = other.height;
  11656. };
  11657. /**
  11658. * Copy from a group of 4 floats
  11659. * @param left defines left coordinate
  11660. * @param top defines top coordinate
  11661. * @param width defines width dimension
  11662. * @param height defines height dimension
  11663. */
  11664. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11665. this.left = left;
  11666. this.top = top;
  11667. this.width = width;
  11668. this.height = height;
  11669. };
  11670. /**
  11671. * Check equality between this measure and another one
  11672. * @param other defines the other measures
  11673. * @returns true if both measures are equals
  11674. */
  11675. Measure.prototype.isEqualsTo = function (other) {
  11676. if (this.left !== other.left) {
  11677. return false;
  11678. }
  11679. if (this.top !== other.top) {
  11680. return false;
  11681. }
  11682. if (this.width !== other.width) {
  11683. return false;
  11684. }
  11685. if (this.height !== other.height) {
  11686. return false;
  11687. }
  11688. return true;
  11689. };
  11690. /**
  11691. * Creates an empty measure
  11692. * @returns a new measure
  11693. */
  11694. Measure.Empty = function () {
  11695. return new Measure(0, 0, 0, 0);
  11696. };
  11697. return Measure;
  11698. }());
  11699. /***/ }),
  11700. /***/ "./2D/multiLinePoint.ts":
  11701. /*!******************************!*\
  11702. !*** ./2D/multiLinePoint.ts ***!
  11703. \******************************/
  11704. /*! exports provided: MultiLinePoint */
  11705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11706. "use strict";
  11707. __webpack_require__.r(__webpack_exports__);
  11708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11709. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  11710. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11711. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11712. /**
  11713. * Class used to store a point for a MultiLine object.
  11714. * The point can be pure 2D coordinates, a mesh or a control
  11715. */
  11716. var MultiLinePoint = /** @class */ (function () {
  11717. /**
  11718. * Creates a new MultiLinePoint
  11719. * @param multiLine defines the source MultiLine object
  11720. */
  11721. function MultiLinePoint(multiLine) {
  11722. this._multiLine = multiLine;
  11723. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11724. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11725. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11726. }
  11727. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11728. /** Gets or sets x coordinate */
  11729. get: function () {
  11730. return this._x.toString(this._multiLine._host);
  11731. },
  11732. set: function (value) {
  11733. if (this._x.toString(this._multiLine._host) === value) {
  11734. return;
  11735. }
  11736. if (this._x.fromString(value)) {
  11737. this._multiLine._markAsDirty();
  11738. }
  11739. },
  11740. enumerable: true,
  11741. configurable: true
  11742. });
  11743. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11744. /** Gets or sets y coordinate */
  11745. get: function () {
  11746. return this._y.toString(this._multiLine._host);
  11747. },
  11748. set: function (value) {
  11749. if (this._y.toString(this._multiLine._host) === value) {
  11750. return;
  11751. }
  11752. if (this._y.fromString(value)) {
  11753. this._multiLine._markAsDirty();
  11754. }
  11755. },
  11756. enumerable: true,
  11757. configurable: true
  11758. });
  11759. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11760. /** Gets or sets the control associated with this point */
  11761. get: function () {
  11762. return this._control;
  11763. },
  11764. set: function (value) {
  11765. if (this._control === value) {
  11766. return;
  11767. }
  11768. if (this._control && this._controlObserver) {
  11769. this._control.onDirtyObservable.remove(this._controlObserver);
  11770. this._controlObserver = null;
  11771. }
  11772. this._control = value;
  11773. if (this._control) {
  11774. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11775. }
  11776. this._multiLine._markAsDirty();
  11777. },
  11778. enumerable: true,
  11779. configurable: true
  11780. });
  11781. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11782. /** Gets or sets the mesh associated with this point */
  11783. get: function () {
  11784. return this._mesh;
  11785. },
  11786. set: function (value) {
  11787. if (this._mesh === value) {
  11788. return;
  11789. }
  11790. if (this._mesh && this._meshObserver) {
  11791. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11792. }
  11793. this._mesh = value;
  11794. if (this._mesh) {
  11795. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  11796. }
  11797. this._multiLine._markAsDirty();
  11798. },
  11799. enumerable: true,
  11800. configurable: true
  11801. });
  11802. /** Resets links */
  11803. MultiLinePoint.prototype.resetLinks = function () {
  11804. this.control = null;
  11805. this.mesh = null;
  11806. };
  11807. /**
  11808. * Gets a translation vector
  11809. * @returns the translation vector
  11810. */
  11811. MultiLinePoint.prototype.translate = function () {
  11812. this._point = this._translatePoint();
  11813. return this._point;
  11814. };
  11815. MultiLinePoint.prototype._translatePoint = function () {
  11816. if (this._mesh != null) {
  11817. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  11818. }
  11819. else if (this._control != null) {
  11820. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  11821. }
  11822. else {
  11823. var host = this._multiLine._host;
  11824. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  11825. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  11826. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  11827. }
  11828. };
  11829. /** Release associated resources */
  11830. MultiLinePoint.prototype.dispose = function () {
  11831. this.resetLinks();
  11832. };
  11833. return MultiLinePoint;
  11834. }());
  11835. /***/ }),
  11836. /***/ "./2D/style.ts":
  11837. /*!*********************!*\
  11838. !*** ./2D/style.ts ***!
  11839. \*********************/
  11840. /*! exports provided: Style */
  11841. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11842. "use strict";
  11843. __webpack_require__.r(__webpack_exports__);
  11844. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  11845. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11846. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  11847. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11848. /**
  11849. * Define a style used by control to automatically setup properties based on a template.
  11850. * Only support font related properties so far
  11851. */
  11852. var Style = /** @class */ (function () {
  11853. /**
  11854. * Creates a new style object
  11855. * @param host defines the AdvancedDynamicTexture which hosts this style
  11856. */
  11857. function Style(host) {
  11858. this._fontFamily = "Arial";
  11859. this._fontStyle = "";
  11860. this._fontWeight = "";
  11861. /** @hidden */
  11862. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11863. /**
  11864. * Observable raised when the style values are changed
  11865. */
  11866. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  11867. this._host = host;
  11868. }
  11869. Object.defineProperty(Style.prototype, "fontSize", {
  11870. /**
  11871. * Gets or sets the font size
  11872. */
  11873. get: function () {
  11874. return this._fontSize.toString(this._host);
  11875. },
  11876. set: function (value) {
  11877. if (this._fontSize.toString(this._host) === value) {
  11878. return;
  11879. }
  11880. if (this._fontSize.fromString(value)) {
  11881. this.onChangedObservable.notifyObservers(this);
  11882. }
  11883. },
  11884. enumerable: true,
  11885. configurable: true
  11886. });
  11887. Object.defineProperty(Style.prototype, "fontFamily", {
  11888. /**
  11889. * Gets or sets the font family
  11890. */
  11891. get: function () {
  11892. return this._fontFamily;
  11893. },
  11894. set: function (value) {
  11895. if (this._fontFamily === value) {
  11896. return;
  11897. }
  11898. this._fontFamily = value;
  11899. this.onChangedObservable.notifyObservers(this);
  11900. },
  11901. enumerable: true,
  11902. configurable: true
  11903. });
  11904. Object.defineProperty(Style.prototype, "fontStyle", {
  11905. /**
  11906. * Gets or sets the font style
  11907. */
  11908. get: function () {
  11909. return this._fontStyle;
  11910. },
  11911. set: function (value) {
  11912. if (this._fontStyle === value) {
  11913. return;
  11914. }
  11915. this._fontStyle = value;
  11916. this.onChangedObservable.notifyObservers(this);
  11917. },
  11918. enumerable: true,
  11919. configurable: true
  11920. });
  11921. Object.defineProperty(Style.prototype, "fontWeight", {
  11922. /** Gets or sets font weight */
  11923. get: function () {
  11924. return this._fontWeight;
  11925. },
  11926. set: function (value) {
  11927. if (this._fontWeight === value) {
  11928. return;
  11929. }
  11930. this._fontWeight = value;
  11931. this.onChangedObservable.notifyObservers(this);
  11932. },
  11933. enumerable: true,
  11934. configurable: true
  11935. });
  11936. /** Dispose all associated resources */
  11937. Style.prototype.dispose = function () {
  11938. this.onChangedObservable.clear();
  11939. };
  11940. return Style;
  11941. }());
  11942. /***/ }),
  11943. /***/ "./2D/valueAndUnit.ts":
  11944. /*!****************************!*\
  11945. !*** ./2D/valueAndUnit.ts ***!
  11946. \****************************/
  11947. /*! exports provided: ValueAndUnit */
  11948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11949. "use strict";
  11950. __webpack_require__.r(__webpack_exports__);
  11951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  11952. /**
  11953. * Class used to specific a value and its associated unit
  11954. */
  11955. var ValueAndUnit = /** @class */ (function () {
  11956. /**
  11957. * Creates a new ValueAndUnit
  11958. * @param value defines the value to store
  11959. * @param unit defines the unit to store
  11960. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  11961. */
  11962. function ValueAndUnit(value,
  11963. /** defines the unit to store */
  11964. unit,
  11965. /** defines a boolean indicating if the value can be negative */
  11966. negativeValueAllowed) {
  11967. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  11968. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  11969. this.unit = unit;
  11970. this.negativeValueAllowed = negativeValueAllowed;
  11971. this._value = 1;
  11972. /**
  11973. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  11974. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  11975. */
  11976. this.ignoreAdaptiveScaling = false;
  11977. this._value = value;
  11978. this._originalUnit = unit;
  11979. }
  11980. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  11981. /** Gets a boolean indicating if the value is a percentage */
  11982. get: function () {
  11983. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  11989. /** Gets a boolean indicating if the value is store as pixel */
  11990. get: function () {
  11991. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  11992. },
  11993. enumerable: true,
  11994. configurable: true
  11995. });
  11996. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  11997. /** Gets direct internal value */
  11998. get: function () {
  11999. return this._value;
  12000. },
  12001. enumerable: true,
  12002. configurable: true
  12003. });
  12004. /**
  12005. * Gets value as pixel
  12006. * @param host defines the root host
  12007. * @param refValue defines the reference value for percentages
  12008. * @returns the value as pixel
  12009. */
  12010. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12011. if (this.isPixel) {
  12012. return this.getValue(host);
  12013. }
  12014. return this.getValue(host) * refValue;
  12015. };
  12016. /**
  12017. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12018. * @param value defines the value to store
  12019. * @param unit defines the unit to store
  12020. * @returns the current ValueAndUnit
  12021. */
  12022. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12023. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12024. this._value = value;
  12025. this.unit = unit;
  12026. return this;
  12027. };
  12028. /**
  12029. * Gets the value accordingly to its unit
  12030. * @param host defines the root host
  12031. * @returns the value
  12032. */
  12033. ValueAndUnit.prototype.getValue = function (host) {
  12034. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12035. var width = 0;
  12036. var height = 0;
  12037. if (host.idealWidth) {
  12038. width = (this._value * host.getSize().width) / host.idealWidth;
  12039. }
  12040. if (host.idealHeight) {
  12041. height = (this._value * host.getSize().height) / host.idealHeight;
  12042. }
  12043. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12044. return window.innerWidth < window.innerHeight ? width : height;
  12045. }
  12046. if (host.idealWidth) { // horizontal
  12047. return width;
  12048. }
  12049. if (host.idealHeight) { // vertical
  12050. return height;
  12051. }
  12052. }
  12053. return this._value;
  12054. };
  12055. /**
  12056. * Gets a string representation of the value
  12057. * @param host defines the root host
  12058. * @returns a string
  12059. */
  12060. ValueAndUnit.prototype.toString = function (host) {
  12061. switch (this.unit) {
  12062. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12063. return (this.getValue(host) * 100) + "%";
  12064. case ValueAndUnit.UNITMODE_PIXEL:
  12065. return this.getValue(host) + "px";
  12066. }
  12067. return this.unit.toString();
  12068. };
  12069. /**
  12070. * Store a value parsed from a string
  12071. * @param source defines the source string
  12072. * @returns true if the value was successfully parsed
  12073. */
  12074. ValueAndUnit.prototype.fromString = function (source) {
  12075. var match = ValueAndUnit._Regex.exec(source.toString());
  12076. if (!match || match.length === 0) {
  12077. return false;
  12078. }
  12079. var sourceValue = parseFloat(match[1]);
  12080. var sourceUnit = this._originalUnit;
  12081. if (!this.negativeValueAllowed) {
  12082. if (sourceValue < 0) {
  12083. sourceValue = 0;
  12084. }
  12085. }
  12086. if (match.length === 4) {
  12087. switch (match[3]) {
  12088. case "px":
  12089. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12090. break;
  12091. case "%":
  12092. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12093. sourceValue /= 100.0;
  12094. break;
  12095. }
  12096. }
  12097. if (sourceValue === this._value && sourceUnit === this.unit) {
  12098. return false;
  12099. }
  12100. this._value = sourceValue;
  12101. this.unit = sourceUnit;
  12102. return true;
  12103. };
  12104. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12105. /** UNITMODE_PERCENTAGE */
  12106. get: function () {
  12107. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12108. },
  12109. enumerable: true,
  12110. configurable: true
  12111. });
  12112. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12113. /** UNITMODE_PIXEL */
  12114. get: function () {
  12115. return ValueAndUnit._UNITMODE_PIXEL;
  12116. },
  12117. enumerable: true,
  12118. configurable: true
  12119. });
  12120. // Static
  12121. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12122. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12123. ValueAndUnit._UNITMODE_PIXEL = 1;
  12124. return ValueAndUnit;
  12125. }());
  12126. /***/ }),
  12127. /***/ "./3D/controls/abstractButton3D.ts":
  12128. /*!*****************************************!*\
  12129. !*** ./3D/controls/abstractButton3D.ts ***!
  12130. \*****************************************/
  12131. /*! exports provided: AbstractButton3D */
  12132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12133. "use strict";
  12134. __webpack_require__.r(__webpack_exports__);
  12135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12137. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12138. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12139. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12140. /**
  12141. * Class used as a root to all buttons
  12142. */
  12143. var AbstractButton3D = /** @class */ (function (_super) {
  12144. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12145. /**
  12146. * Creates a new button
  12147. * @param name defines the control name
  12148. */
  12149. function AbstractButton3D(name) {
  12150. return _super.call(this, name) || this;
  12151. }
  12152. AbstractButton3D.prototype._getTypeName = function () {
  12153. return "AbstractButton3D";
  12154. };
  12155. // Mesh association
  12156. AbstractButton3D.prototype._createNode = function (scene) {
  12157. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12158. };
  12159. return AbstractButton3D;
  12160. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12161. /***/ }),
  12162. /***/ "./3D/controls/button3D.ts":
  12163. /*!*********************************!*\
  12164. !*** ./3D/controls/button3D.ts ***!
  12165. \*********************************/
  12166. /*! exports provided: Button3D */
  12167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12168. "use strict";
  12169. __webpack_require__.r(__webpack_exports__);
  12170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12171. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12172. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12173. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12174. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12175. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12176. /**
  12177. * Class used to create a button in 3D
  12178. */
  12179. var Button3D = /** @class */ (function (_super) {
  12180. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12181. /**
  12182. * Creates a new button
  12183. * @param name defines the control name
  12184. */
  12185. function Button3D(name) {
  12186. var _this = _super.call(this, name) || this;
  12187. _this._contentResolution = 512;
  12188. _this._contentScaleRatio = 2;
  12189. // Default animations
  12190. _this.pointerEnterAnimation = function () {
  12191. if (!_this.mesh) {
  12192. return;
  12193. }
  12194. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12195. };
  12196. _this.pointerOutAnimation = function () {
  12197. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12198. };
  12199. _this.pointerDownAnimation = function () {
  12200. if (!_this.mesh) {
  12201. return;
  12202. }
  12203. _this.mesh.scaling.scaleInPlace(0.95);
  12204. };
  12205. _this.pointerUpAnimation = function () {
  12206. if (!_this.mesh) {
  12207. return;
  12208. }
  12209. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12210. };
  12211. return _this;
  12212. }
  12213. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12214. /**
  12215. * Gets or sets the texture resolution used to render content (512 by default)
  12216. */
  12217. get: function () {
  12218. return this._contentResolution;
  12219. },
  12220. set: function (value) {
  12221. if (this._contentResolution === value) {
  12222. return;
  12223. }
  12224. this._contentResolution = value;
  12225. this._resetContent();
  12226. },
  12227. enumerable: true,
  12228. configurable: true
  12229. });
  12230. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12231. /**
  12232. * Gets or sets the texture scale ratio used to render content (2 by default)
  12233. */
  12234. get: function () {
  12235. return this._contentScaleRatio;
  12236. },
  12237. set: function (value) {
  12238. if (this._contentScaleRatio === value) {
  12239. return;
  12240. }
  12241. this._contentScaleRatio = value;
  12242. this._resetContent();
  12243. },
  12244. enumerable: true,
  12245. configurable: true
  12246. });
  12247. Button3D.prototype._disposeFacadeTexture = function () {
  12248. if (this._facadeTexture) {
  12249. this._facadeTexture.dispose();
  12250. this._facadeTexture = null;
  12251. }
  12252. };
  12253. Button3D.prototype._resetContent = function () {
  12254. this._disposeFacadeTexture();
  12255. this.content = this._content;
  12256. };
  12257. Object.defineProperty(Button3D.prototype, "content", {
  12258. /**
  12259. * Gets or sets the GUI 2D content used to display the button's facade
  12260. */
  12261. get: function () {
  12262. return this._content;
  12263. },
  12264. set: function (value) {
  12265. this._content = value;
  12266. if (!this._host || !this._host.utilityLayer) {
  12267. return;
  12268. }
  12269. if (!this._facadeTexture) {
  12270. 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);
  12271. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12272. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12273. this._facadeTexture.premulAlpha = true;
  12274. }
  12275. this._facadeTexture.addControl(value);
  12276. this._applyFacade(this._facadeTexture);
  12277. },
  12278. enumerable: true,
  12279. configurable: true
  12280. });
  12281. /**
  12282. * Apply the facade texture (created from the content property).
  12283. * This function can be overloaded by child classes
  12284. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12285. */
  12286. Button3D.prototype._applyFacade = function (facadeTexture) {
  12287. this._currentMaterial.emissiveTexture = facadeTexture;
  12288. };
  12289. Button3D.prototype._getTypeName = function () {
  12290. return "Button3D";
  12291. };
  12292. // Mesh association
  12293. Button3D.prototype._createNode = function (scene) {
  12294. var faceUV = new Array(6);
  12295. for (var i = 0; i < 6; i++) {
  12296. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12297. }
  12298. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12299. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["MeshBuilder"].CreateBox(this.name + "_rootMesh", {
  12300. width: 1.0,
  12301. height: 1.0,
  12302. depth: 0.08,
  12303. faceUV: faceUV
  12304. }, scene);
  12305. return mesh;
  12306. };
  12307. Button3D.prototype._affectMaterial = function (mesh) {
  12308. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12309. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12310. mesh.material = material;
  12311. this._currentMaterial = material;
  12312. this._resetContent();
  12313. };
  12314. /**
  12315. * Releases all associated resources
  12316. */
  12317. Button3D.prototype.dispose = function () {
  12318. _super.prototype.dispose.call(this);
  12319. this._disposeFacadeTexture();
  12320. if (this._currentMaterial) {
  12321. this._currentMaterial.dispose();
  12322. }
  12323. };
  12324. return Button3D;
  12325. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12326. /***/ }),
  12327. /***/ "./3D/controls/container3D.ts":
  12328. /*!************************************!*\
  12329. !*** ./3D/controls/container3D.ts ***!
  12330. \************************************/
  12331. /*! exports provided: Container3D */
  12332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12333. "use strict";
  12334. __webpack_require__.r(__webpack_exports__);
  12335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12337. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  12338. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12339. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12340. /**
  12341. * Class used to create containers for controls
  12342. */
  12343. var Container3D = /** @class */ (function (_super) {
  12344. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12345. /**
  12346. * Creates a new container
  12347. * @param name defines the container name
  12348. */
  12349. function Container3D(name) {
  12350. var _this = _super.call(this, name) || this;
  12351. _this._blockLayout = false;
  12352. /**
  12353. * Gets the list of child controls
  12354. */
  12355. _this._children = new Array();
  12356. return _this;
  12357. }
  12358. Object.defineProperty(Container3D.prototype, "children", {
  12359. /**
  12360. * Gets the list of child controls
  12361. */
  12362. get: function () {
  12363. return this._children;
  12364. },
  12365. enumerable: true,
  12366. configurable: true
  12367. });
  12368. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12369. /**
  12370. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12371. * This is helpful to optimize layout operation when adding multiple children in a row
  12372. */
  12373. get: function () {
  12374. return this._blockLayout;
  12375. },
  12376. set: function (value) {
  12377. if (this._blockLayout === value) {
  12378. return;
  12379. }
  12380. this._blockLayout = value;
  12381. if (!this._blockLayout) {
  12382. this._arrangeChildren();
  12383. }
  12384. },
  12385. enumerable: true,
  12386. configurable: true
  12387. });
  12388. /**
  12389. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12390. * @returns the current container
  12391. */
  12392. Container3D.prototype.updateLayout = function () {
  12393. this._arrangeChildren();
  12394. return this;
  12395. };
  12396. /**
  12397. * Gets a boolean indicating if the given control is in the children of this control
  12398. * @param control defines the control to check
  12399. * @returns true if the control is in the child list
  12400. */
  12401. Container3D.prototype.containsControl = function (control) {
  12402. return this._children.indexOf(control) !== -1;
  12403. };
  12404. /**
  12405. * Adds a control to the children of this control
  12406. * @param control defines the control to add
  12407. * @returns the current container
  12408. */
  12409. Container3D.prototype.addControl = function (control) {
  12410. var index = this._children.indexOf(control);
  12411. if (index !== -1) {
  12412. return this;
  12413. }
  12414. control.parent = this;
  12415. control._host = this._host;
  12416. this._children.push(control);
  12417. if (this._host.utilityLayer) {
  12418. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12419. if (control.node) {
  12420. control.node.parent = this.node;
  12421. }
  12422. if (!this.blockLayout) {
  12423. this._arrangeChildren();
  12424. }
  12425. }
  12426. return this;
  12427. };
  12428. /**
  12429. * This function will be called everytime a new control is added
  12430. */
  12431. Container3D.prototype._arrangeChildren = function () {
  12432. };
  12433. Container3D.prototype._createNode = function (scene) {
  12434. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12435. };
  12436. /**
  12437. * Removes a control from the children of this control
  12438. * @param control defines the control to remove
  12439. * @returns the current container
  12440. */
  12441. Container3D.prototype.removeControl = function (control) {
  12442. var index = this._children.indexOf(control);
  12443. if (index !== -1) {
  12444. this._children.splice(index, 1);
  12445. control.parent = null;
  12446. control._disposeNode();
  12447. }
  12448. return this;
  12449. };
  12450. Container3D.prototype._getTypeName = function () {
  12451. return "Container3D";
  12452. };
  12453. /**
  12454. * Releases all associated resources
  12455. */
  12456. Container3D.prototype.dispose = function () {
  12457. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12458. var control = _a[_i];
  12459. control.dispose();
  12460. }
  12461. this._children = [];
  12462. _super.prototype.dispose.call(this);
  12463. };
  12464. /** Control rotation will remain unchanged */
  12465. Container3D.UNSET_ORIENTATION = 0;
  12466. /** Control will rotate to make it look at sphere central axis */
  12467. Container3D.FACEORIGIN_ORIENTATION = 1;
  12468. /** Control will rotate to make it look back at sphere central axis */
  12469. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12470. /** Control will rotate to look at z axis (0, 0, 1) */
  12471. Container3D.FACEFORWARD_ORIENTATION = 3;
  12472. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12473. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12474. return Container3D;
  12475. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12476. /***/ }),
  12477. /***/ "./3D/controls/control3D.ts":
  12478. /*!**********************************!*\
  12479. !*** ./3D/controls/control3D.ts ***!
  12480. \**********************************/
  12481. /*! exports provided: Control3D */
  12482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12483. "use strict";
  12484. __webpack_require__.r(__webpack_exports__);
  12485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12486. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12487. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12488. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12489. /**
  12490. * Class used as base class for controls
  12491. */
  12492. var Control3D = /** @class */ (function () {
  12493. /**
  12494. * Creates a new control
  12495. * @param name defines the control name
  12496. */
  12497. function Control3D(
  12498. /** Defines the control name */
  12499. name) {
  12500. this.name = name;
  12501. this._downCount = 0;
  12502. this._enterCount = -1;
  12503. this._downPointerIds = {};
  12504. this._isVisible = true;
  12505. /**
  12506. * An event triggered when the pointer move over the control
  12507. */
  12508. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12509. /**
  12510. * An event triggered when the pointer move out of the control
  12511. */
  12512. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12513. /**
  12514. * An event triggered when the pointer taps the control
  12515. */
  12516. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12517. /**
  12518. * An event triggered when pointer is up
  12519. */
  12520. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12521. /**
  12522. * An event triggered when a control is clicked on (with a mouse)
  12523. */
  12524. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12525. /**
  12526. * An event triggered when pointer enters the control
  12527. */
  12528. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12529. // Behaviors
  12530. this._behaviors = new Array();
  12531. }
  12532. Object.defineProperty(Control3D.prototype, "position", {
  12533. /** Gets or sets the control position in world space */
  12534. get: function () {
  12535. if (!this._node) {
  12536. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12537. }
  12538. return this._node.position;
  12539. },
  12540. set: function (value) {
  12541. if (!this._node) {
  12542. return;
  12543. }
  12544. this._node.position = value;
  12545. },
  12546. enumerable: true,
  12547. configurable: true
  12548. });
  12549. Object.defineProperty(Control3D.prototype, "scaling", {
  12550. /** Gets or sets the control scaling in world space */
  12551. get: function () {
  12552. if (!this._node) {
  12553. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12554. }
  12555. return this._node.scaling;
  12556. },
  12557. set: function (value) {
  12558. if (!this._node) {
  12559. return;
  12560. }
  12561. this._node.scaling = value;
  12562. },
  12563. enumerable: true,
  12564. configurable: true
  12565. });
  12566. Object.defineProperty(Control3D.prototype, "behaviors", {
  12567. /**
  12568. * Gets the list of attached behaviors
  12569. * @see http://doc.babylonjs.com/features/behaviour
  12570. */
  12571. get: function () {
  12572. return this._behaviors;
  12573. },
  12574. enumerable: true,
  12575. configurable: true
  12576. });
  12577. /**
  12578. * Attach a behavior to the control
  12579. * @see http://doc.babylonjs.com/features/behaviour
  12580. * @param behavior defines the behavior to attach
  12581. * @returns the current control
  12582. */
  12583. Control3D.prototype.addBehavior = function (behavior) {
  12584. var _this = this;
  12585. var index = this._behaviors.indexOf(behavior);
  12586. if (index !== -1) {
  12587. return this;
  12588. }
  12589. behavior.init();
  12590. var scene = this._host.scene;
  12591. if (scene.isLoading) {
  12592. // We defer the attach when the scene will be loaded
  12593. scene.onDataLoadedObservable.addOnce(function () {
  12594. behavior.attach(_this);
  12595. });
  12596. }
  12597. else {
  12598. behavior.attach(this);
  12599. }
  12600. this._behaviors.push(behavior);
  12601. return this;
  12602. };
  12603. /**
  12604. * Remove an attached behavior
  12605. * @see http://doc.babylonjs.com/features/behaviour
  12606. * @param behavior defines the behavior to attach
  12607. * @returns the current control
  12608. */
  12609. Control3D.prototype.removeBehavior = function (behavior) {
  12610. var index = this._behaviors.indexOf(behavior);
  12611. if (index === -1) {
  12612. return this;
  12613. }
  12614. this._behaviors[index].detach();
  12615. this._behaviors.splice(index, 1);
  12616. return this;
  12617. };
  12618. /**
  12619. * Gets an attached behavior by name
  12620. * @param name defines the name of the behavior to look for
  12621. * @see http://doc.babylonjs.com/features/behaviour
  12622. * @returns null if behavior was not found else the requested behavior
  12623. */
  12624. Control3D.prototype.getBehaviorByName = function (name) {
  12625. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12626. var behavior = _a[_i];
  12627. if (behavior.name === name) {
  12628. return behavior;
  12629. }
  12630. }
  12631. return null;
  12632. };
  12633. Object.defineProperty(Control3D.prototype, "isVisible", {
  12634. /** Gets or sets a boolean indicating if the control is visible */
  12635. get: function () {
  12636. return this._isVisible;
  12637. },
  12638. set: function (value) {
  12639. if (this._isVisible === value) {
  12640. return;
  12641. }
  12642. this._isVisible = value;
  12643. var mesh = this.mesh;
  12644. if (mesh) {
  12645. mesh.setEnabled(value);
  12646. }
  12647. },
  12648. enumerable: true,
  12649. configurable: true
  12650. });
  12651. Object.defineProperty(Control3D.prototype, "typeName", {
  12652. /**
  12653. * Gets a string representing the class name
  12654. */
  12655. get: function () {
  12656. return this._getTypeName();
  12657. },
  12658. enumerable: true,
  12659. configurable: true
  12660. });
  12661. /**
  12662. * Get the current class name of the control.
  12663. * @returns current class name
  12664. */
  12665. Control3D.prototype.getClassName = function () {
  12666. return this._getTypeName();
  12667. };
  12668. Control3D.prototype._getTypeName = function () {
  12669. return "Control3D";
  12670. };
  12671. Object.defineProperty(Control3D.prototype, "node", {
  12672. /**
  12673. * Gets the transform node used by this control
  12674. */
  12675. get: function () {
  12676. return this._node;
  12677. },
  12678. enumerable: true,
  12679. configurable: true
  12680. });
  12681. Object.defineProperty(Control3D.prototype, "mesh", {
  12682. /**
  12683. * Gets the mesh used to render this control
  12684. */
  12685. get: function () {
  12686. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12687. return this._node;
  12688. }
  12689. return null;
  12690. },
  12691. enumerable: true,
  12692. configurable: true
  12693. });
  12694. /**
  12695. * Link the control as child of the given node
  12696. * @param node defines the node to link to. Use null to unlink the control
  12697. * @returns the current control
  12698. */
  12699. Control3D.prototype.linkToTransformNode = function (node) {
  12700. if (this._node) {
  12701. this._node.parent = node;
  12702. }
  12703. return this;
  12704. };
  12705. /** @hidden **/
  12706. Control3D.prototype._prepareNode = function (scene) {
  12707. if (!this._node) {
  12708. this._node = this._createNode(scene);
  12709. if (!this.node) {
  12710. return;
  12711. }
  12712. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12713. this._node.position = this.position;
  12714. this._node.scaling = this.scaling;
  12715. var mesh = this.mesh;
  12716. if (mesh) {
  12717. mesh.isPickable = true;
  12718. this._affectMaterial(mesh);
  12719. }
  12720. }
  12721. };
  12722. /**
  12723. * Node creation.
  12724. * Can be overriden by children
  12725. * @param scene defines the scene where the node must be attached
  12726. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12727. */
  12728. Control3D.prototype._createNode = function (scene) {
  12729. // Do nothing by default
  12730. return null;
  12731. };
  12732. /**
  12733. * Affect a material to the given mesh
  12734. * @param mesh defines the mesh which will represent the control
  12735. */
  12736. Control3D.prototype._affectMaterial = function (mesh) {
  12737. mesh.material = null;
  12738. };
  12739. // Pointers
  12740. /** @hidden */
  12741. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12742. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12743. };
  12744. /** @hidden */
  12745. Control3D.prototype._onPointerEnter = function (target) {
  12746. if (this._enterCount > 0) {
  12747. return false;
  12748. }
  12749. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12750. this._enterCount = 0;
  12751. }
  12752. this._enterCount++;
  12753. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12754. if (this.pointerEnterAnimation) {
  12755. this.pointerEnterAnimation();
  12756. }
  12757. return true;
  12758. };
  12759. /** @hidden */
  12760. Control3D.prototype._onPointerOut = function (target) {
  12761. this._enterCount = 0;
  12762. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12763. if (this.pointerOutAnimation) {
  12764. this.pointerOutAnimation();
  12765. }
  12766. };
  12767. /** @hidden */
  12768. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12769. if (this._downCount !== 0) {
  12770. return false;
  12771. }
  12772. this._downCount++;
  12773. this._downPointerIds[pointerId] = true;
  12774. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12775. if (this.pointerDownAnimation) {
  12776. this.pointerDownAnimation();
  12777. }
  12778. return true;
  12779. };
  12780. /** @hidden */
  12781. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12782. this._downCount = 0;
  12783. delete this._downPointerIds[pointerId];
  12784. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  12785. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12786. }
  12787. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12788. if (this.pointerUpAnimation) {
  12789. this.pointerUpAnimation();
  12790. }
  12791. };
  12792. /** @hidden */
  12793. Control3D.prototype.forcePointerUp = function (pointerId) {
  12794. if (pointerId === void 0) { pointerId = null; }
  12795. if (pointerId !== null) {
  12796. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  12797. }
  12798. else {
  12799. for (var key in this._downPointerIds) {
  12800. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  12801. }
  12802. }
  12803. };
  12804. /** @hidden */
  12805. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  12806. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  12807. this._onPointerMove(this, pickedPoint);
  12808. var previousControlOver = this._host._lastControlOver[pointerId];
  12809. if (previousControlOver && previousControlOver !== this) {
  12810. previousControlOver._onPointerOut(this);
  12811. }
  12812. if (previousControlOver !== this) {
  12813. this._onPointerEnter(this);
  12814. }
  12815. this._host._lastControlOver[pointerId] = this;
  12816. return true;
  12817. }
  12818. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  12819. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  12820. this._host._lastControlDown[pointerId] = this;
  12821. this._host._lastPickedControl = this;
  12822. return true;
  12823. }
  12824. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  12825. if (this._host._lastControlDown[pointerId]) {
  12826. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  12827. }
  12828. delete this._host._lastControlDown[pointerId];
  12829. return true;
  12830. }
  12831. return false;
  12832. };
  12833. /** @hidden */
  12834. Control3D.prototype._disposeNode = function () {
  12835. if (this._node) {
  12836. this._node.dispose();
  12837. this._node = null;
  12838. }
  12839. };
  12840. /**
  12841. * Releases all associated resources
  12842. */
  12843. Control3D.prototype.dispose = function () {
  12844. this.onPointerDownObservable.clear();
  12845. this.onPointerEnterObservable.clear();
  12846. this.onPointerMoveObservable.clear();
  12847. this.onPointerOutObservable.clear();
  12848. this.onPointerUpObservable.clear();
  12849. this.onPointerClickObservable.clear();
  12850. this._disposeNode();
  12851. // Behaviors
  12852. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12853. var behavior = _a[_i];
  12854. behavior.detach();
  12855. }
  12856. };
  12857. return Control3D;
  12858. }());
  12859. /***/ }),
  12860. /***/ "./3D/controls/cylinderPanel.ts":
  12861. /*!**************************************!*\
  12862. !*** ./3D/controls/cylinderPanel.ts ***!
  12863. \**************************************/
  12864. /*! exports provided: CylinderPanel */
  12865. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12866. "use strict";
  12867. __webpack_require__.r(__webpack_exports__);
  12868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  12869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12870. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12871. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12872. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  12873. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  12874. /**
  12875. * Class used to create a container panel deployed on the surface of a cylinder
  12876. */
  12877. var CylinderPanel = /** @class */ (function (_super) {
  12878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  12879. function CylinderPanel() {
  12880. var _this = _super !== null && _super.apply(this, arguments) || this;
  12881. _this._radius = 5.0;
  12882. return _this;
  12883. }
  12884. Object.defineProperty(CylinderPanel.prototype, "radius", {
  12885. /**
  12886. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  12887. */
  12888. get: function () {
  12889. return this._radius;
  12890. },
  12891. set: function (value) {
  12892. var _this = this;
  12893. if (this._radius === value) {
  12894. return;
  12895. }
  12896. this._radius = value;
  12897. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  12898. _this._arrangeChildren();
  12899. });
  12900. },
  12901. enumerable: true,
  12902. configurable: true
  12903. });
  12904. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  12905. var mesh = control.mesh;
  12906. if (!mesh) {
  12907. return;
  12908. }
  12909. var newPos = this._cylindricalMapping(nodePosition);
  12910. control.position = newPos;
  12911. switch (this.orientation) {
  12912. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  12913. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  12914. break;
  12915. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  12916. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  12917. break;
  12918. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  12919. break;
  12920. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  12921. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  12922. break;
  12923. }
  12924. };
  12925. CylinderPanel.prototype._cylindricalMapping = function (source) {
  12926. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  12927. var yAngle = (source.x / this._radius);
  12928. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  12929. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  12930. };
  12931. return CylinderPanel;
  12932. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  12933. /***/ }),
  12934. /***/ "./3D/controls/holographicButton.ts":
  12935. /*!******************************************!*\
  12936. !*** ./3D/controls/holographicButton.ts ***!
  12937. \******************************************/
  12938. /*! exports provided: HolographicButton */
  12939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12940. "use strict";
  12941. __webpack_require__.r(__webpack_exports__);
  12942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  12943. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12944. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  12945. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  12946. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  12947. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  12948. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  12949. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  12950. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  12951. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12952. /**
  12953. * Class used to create a holographic button in 3D
  12954. */
  12955. var HolographicButton = /** @class */ (function (_super) {
  12956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  12957. /**
  12958. * Creates a new button
  12959. * @param name defines the control name
  12960. */
  12961. function HolographicButton(name, shareMaterials) {
  12962. if (shareMaterials === void 0) { shareMaterials = true; }
  12963. var _this = _super.call(this, name) || this;
  12964. _this._shareMaterials = true;
  12965. _this._shareMaterials = shareMaterials;
  12966. // Default animations
  12967. _this.pointerEnterAnimation = function () {
  12968. if (!_this.mesh) {
  12969. return;
  12970. }
  12971. _this._frontPlate.setEnabled(true);
  12972. };
  12973. _this.pointerOutAnimation = function () {
  12974. if (!_this.mesh) {
  12975. return;
  12976. }
  12977. _this._frontPlate.setEnabled(false);
  12978. };
  12979. return _this;
  12980. }
  12981. HolographicButton.prototype._disposeTooltip = function () {
  12982. this._tooltipFade = null;
  12983. if (this._tooltipTextBlock) {
  12984. this._tooltipTextBlock.dispose();
  12985. }
  12986. if (this._tooltipTexture) {
  12987. this._tooltipTexture.dispose();
  12988. }
  12989. if (this._tooltipMesh) {
  12990. this._tooltipMesh.dispose();
  12991. }
  12992. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  12993. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  12994. };
  12995. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  12996. get: function () {
  12997. if (this._tooltipTextBlock) {
  12998. return this._tooltipTextBlock.text;
  12999. }
  13000. return null;
  13001. },
  13002. /**
  13003. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13004. */
  13005. set: function (text) {
  13006. var _this = this;
  13007. if (!text) {
  13008. this._disposeTooltip();
  13009. return;
  13010. }
  13011. if (!this._tooltipFade) {
  13012. // Create tooltip with mesh and text
  13013. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13014. 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);
  13015. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13016. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13017. tooltipBackground.material = mat;
  13018. tooltipBackground.isPickable = false;
  13019. this._tooltipMesh.addChild(tooltipBackground);
  13020. tooltipBackground.position.z = 0.05;
  13021. this._tooltipMesh.scaling.y = 1 / 3;
  13022. this._tooltipMesh.position.y = 0.7;
  13023. this._tooltipMesh.position.z = -0.15;
  13024. this._tooltipMesh.isPickable = false;
  13025. this._tooltipMesh.parent = this._backPlate;
  13026. // Create text texture for the tooltip
  13027. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13028. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13029. this._tooltipTextBlock.scaleY = 3;
  13030. this._tooltipTextBlock.color = "white";
  13031. this._tooltipTextBlock.fontSize = 130;
  13032. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13033. // Add hover action to tooltip
  13034. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13035. this._tooltipFade.delay = 500;
  13036. this._tooltipMesh.addBehavior(this._tooltipFade);
  13037. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13038. if (_this._tooltipFade) {
  13039. _this._tooltipFade.fadeIn(true);
  13040. }
  13041. });
  13042. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13043. if (_this._tooltipFade) {
  13044. _this._tooltipFade.fadeIn(false);
  13045. }
  13046. });
  13047. }
  13048. if (this._tooltipTextBlock) {
  13049. this._tooltipTextBlock.text = text;
  13050. }
  13051. },
  13052. enumerable: true,
  13053. configurable: true
  13054. });
  13055. Object.defineProperty(HolographicButton.prototype, "text", {
  13056. /**
  13057. * Gets or sets text for the button
  13058. */
  13059. get: function () {
  13060. return this._text;
  13061. },
  13062. set: function (value) {
  13063. if (this._text === value) {
  13064. return;
  13065. }
  13066. this._text = value;
  13067. this._rebuildContent();
  13068. },
  13069. enumerable: true,
  13070. configurable: true
  13071. });
  13072. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13073. /**
  13074. * Gets or sets the image url for the button
  13075. */
  13076. get: function () {
  13077. return this._imageUrl;
  13078. },
  13079. set: function (value) {
  13080. if (this._imageUrl === value) {
  13081. return;
  13082. }
  13083. this._imageUrl = value;
  13084. this._rebuildContent();
  13085. },
  13086. enumerable: true,
  13087. configurable: true
  13088. });
  13089. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13090. /**
  13091. * Gets the back material used by this button
  13092. */
  13093. get: function () {
  13094. return this._backMaterial;
  13095. },
  13096. enumerable: true,
  13097. configurable: true
  13098. });
  13099. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13100. /**
  13101. * Gets the front material used by this button
  13102. */
  13103. get: function () {
  13104. return this._frontMaterial;
  13105. },
  13106. enumerable: true,
  13107. configurable: true
  13108. });
  13109. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13110. /**
  13111. * Gets the plate material used by this button
  13112. */
  13113. get: function () {
  13114. return this._plateMaterial;
  13115. },
  13116. enumerable: true,
  13117. configurable: true
  13118. });
  13119. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13120. /**
  13121. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13122. */
  13123. get: function () {
  13124. return this._shareMaterials;
  13125. },
  13126. enumerable: true,
  13127. configurable: true
  13128. });
  13129. HolographicButton.prototype._getTypeName = function () {
  13130. return "HolographicButton";
  13131. };
  13132. HolographicButton.prototype._rebuildContent = function () {
  13133. this._disposeFacadeTexture();
  13134. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13135. panel.isVertical = true;
  13136. if (this._imageUrl) {
  13137. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13138. image.source = this._imageUrl;
  13139. image.paddingTop = "40px";
  13140. image.height = "180px";
  13141. image.width = "100px";
  13142. image.paddingBottom = "40px";
  13143. panel.addControl(image);
  13144. }
  13145. if (this._text) {
  13146. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13147. text.text = this._text;
  13148. text.color = "white";
  13149. text.height = "30px";
  13150. text.fontSize = 24;
  13151. panel.addControl(text);
  13152. }
  13153. if (this._frontPlate) {
  13154. this.content = panel;
  13155. }
  13156. };
  13157. // Mesh association
  13158. HolographicButton.prototype._createNode = function (scene) {
  13159. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "BackMesh", {
  13160. width: 1.0,
  13161. height: 1.0,
  13162. depth: 0.08
  13163. }, scene);
  13164. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["MeshBuilder"].CreateBox(this.name + "FrontMesh", {
  13165. width: 1.0,
  13166. height: 1.0,
  13167. depth: 0.08
  13168. }, scene);
  13169. this._frontPlate.parent = this._backPlate;
  13170. this._frontPlate.position.z = -0.08;
  13171. this._frontPlate.isPickable = false;
  13172. this._frontPlate.setEnabled(false);
  13173. this._textPlate = _super.prototype._createNode.call(this, scene);
  13174. this._textPlate.parent = this._backPlate;
  13175. this._textPlate.position.z = -0.08;
  13176. this._textPlate.isPickable = false;
  13177. return this._backPlate;
  13178. };
  13179. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13180. this._plateMaterial.emissiveTexture = facadeTexture;
  13181. this._plateMaterial.opacityTexture = facadeTexture;
  13182. };
  13183. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13184. var _this = this;
  13185. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13186. this._backMaterial.renderHoverLight = true;
  13187. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13188. if (pickedPoint) {
  13189. _this._backMaterial.hoverPosition = pickedPoint;
  13190. _this._backMaterial.hoverColor.a = 1.0;
  13191. }
  13192. else {
  13193. _this._backMaterial.hoverColor.a = 0;
  13194. }
  13195. });
  13196. };
  13197. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13198. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13199. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13200. this._frontMaterial.alpha = 0.5; // Additive
  13201. this._frontMaterial.renderBorders = true;
  13202. };
  13203. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13204. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13205. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13206. };
  13207. HolographicButton.prototype._affectMaterial = function (mesh) {
  13208. // Back
  13209. if (this._shareMaterials) {
  13210. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13211. this._createBackMaterial(mesh);
  13212. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13213. }
  13214. else {
  13215. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13216. }
  13217. // Front
  13218. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13219. this._createFrontMaterial(mesh);
  13220. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13221. }
  13222. else {
  13223. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13224. }
  13225. }
  13226. else {
  13227. this._createBackMaterial(mesh);
  13228. this._createFrontMaterial(mesh);
  13229. }
  13230. this._createPlateMaterial(mesh);
  13231. this._backPlate.material = this._backMaterial;
  13232. this._frontPlate.material = this._frontMaterial;
  13233. this._textPlate.material = this._plateMaterial;
  13234. this._rebuildContent();
  13235. };
  13236. /**
  13237. * Releases all associated resources
  13238. */
  13239. HolographicButton.prototype.dispose = function () {
  13240. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13241. this._disposeTooltip();
  13242. if (!this.shareMaterials) {
  13243. this._backMaterial.dispose();
  13244. this._frontMaterial.dispose();
  13245. this._plateMaterial.dispose();
  13246. if (this._pickedPointObserver) {
  13247. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13248. this._pickedPointObserver = null;
  13249. }
  13250. }
  13251. };
  13252. return HolographicButton;
  13253. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13254. /***/ }),
  13255. /***/ "./3D/controls/index.ts":
  13256. /*!******************************!*\
  13257. !*** ./3D/controls/index.ts ***!
  13258. \******************************/
  13259. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13261. "use strict";
  13262. __webpack_require__.r(__webpack_exports__);
  13263. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13265. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13267. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13269. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13271. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13273. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13275. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13277. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13279. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13281. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13283. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13285. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13287. /***/ }),
  13288. /***/ "./3D/controls/meshButton3D.ts":
  13289. /*!*************************************!*\
  13290. !*** ./3D/controls/meshButton3D.ts ***!
  13291. \*************************************/
  13292. /*! exports provided: MeshButton3D */
  13293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13294. "use strict";
  13295. __webpack_require__.r(__webpack_exports__);
  13296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13298. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13299. /**
  13300. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13301. */
  13302. var MeshButton3D = /** @class */ (function (_super) {
  13303. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13304. /**
  13305. * Creates a new 3D button based on a mesh
  13306. * @param mesh mesh to become a 3D button
  13307. * @param name defines the control name
  13308. */
  13309. function MeshButton3D(mesh, name) {
  13310. var _this = _super.call(this, name) || this;
  13311. _this._currentMesh = mesh;
  13312. /**
  13313. * Provides a default behavior on hover/out & up/down
  13314. * Override those function to create your own desired behavior specific to your mesh
  13315. */
  13316. _this.pointerEnterAnimation = function () {
  13317. if (!_this.mesh) {
  13318. return;
  13319. }
  13320. _this.mesh.scaling.scaleInPlace(1.1);
  13321. };
  13322. _this.pointerOutAnimation = function () {
  13323. if (!_this.mesh) {
  13324. return;
  13325. }
  13326. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13327. };
  13328. _this.pointerDownAnimation = function () {
  13329. if (!_this.mesh) {
  13330. return;
  13331. }
  13332. _this.mesh.scaling.scaleInPlace(0.95);
  13333. };
  13334. _this.pointerUpAnimation = function () {
  13335. if (!_this.mesh) {
  13336. return;
  13337. }
  13338. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13339. };
  13340. return _this;
  13341. }
  13342. MeshButton3D.prototype._getTypeName = function () {
  13343. return "MeshButton3D";
  13344. };
  13345. // Mesh association
  13346. MeshButton3D.prototype._createNode = function (scene) {
  13347. var _this = this;
  13348. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13349. mesh.metadata = _this;
  13350. });
  13351. return this._currentMesh;
  13352. };
  13353. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13354. };
  13355. return MeshButton3D;
  13356. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13357. /***/ }),
  13358. /***/ "./3D/controls/planePanel.ts":
  13359. /*!***********************************!*\
  13360. !*** ./3D/controls/planePanel.ts ***!
  13361. \***********************************/
  13362. /*! exports provided: PlanePanel */
  13363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13364. "use strict";
  13365. __webpack_require__.r(__webpack_exports__);
  13366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13368. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  13369. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13370. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13371. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13372. /**
  13373. * Class used to create a container panel deployed on the surface of a plane
  13374. */
  13375. var PlanePanel = /** @class */ (function (_super) {
  13376. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13377. function PlanePanel() {
  13378. return _super !== null && _super.apply(this, arguments) || this;
  13379. }
  13380. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13381. var mesh = control.mesh;
  13382. if (!mesh) {
  13383. return;
  13384. }
  13385. control.position = nodePosition.clone();
  13386. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13387. target.copyFrom(nodePosition);
  13388. switch (this.orientation) {
  13389. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13390. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13391. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13392. mesh.lookAt(target);
  13393. break;
  13394. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13395. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13396. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13397. mesh.lookAt(target);
  13398. break;
  13399. }
  13400. };
  13401. return PlanePanel;
  13402. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13403. /***/ }),
  13404. /***/ "./3D/controls/scatterPanel.ts":
  13405. /*!*************************************!*\
  13406. !*** ./3D/controls/scatterPanel.ts ***!
  13407. \*************************************/
  13408. /*! exports provided: ScatterPanel */
  13409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13410. "use strict";
  13411. __webpack_require__.r(__webpack_exports__);
  13412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13414. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13415. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13416. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13417. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13418. /**
  13419. * Class used to create a container panel where items get randomized planar mapping
  13420. */
  13421. var ScatterPanel = /** @class */ (function (_super) {
  13422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13423. function ScatterPanel() {
  13424. var _this = _super !== null && _super.apply(this, arguments) || this;
  13425. _this._iteration = 100.0;
  13426. return _this;
  13427. }
  13428. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13429. /**
  13430. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13431. */
  13432. get: function () {
  13433. return this._iteration;
  13434. },
  13435. set: function (value) {
  13436. var _this = this;
  13437. if (this._iteration === value) {
  13438. return;
  13439. }
  13440. this._iteration = value;
  13441. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13442. _this._arrangeChildren();
  13443. });
  13444. },
  13445. enumerable: true,
  13446. configurable: true
  13447. });
  13448. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13449. var mesh = control.mesh;
  13450. var newPos = this._scatterMapping(nodePosition);
  13451. if (!mesh) {
  13452. return;
  13453. }
  13454. switch (this.orientation) {
  13455. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13456. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13457. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13458. break;
  13459. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13460. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13461. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13462. break;
  13463. }
  13464. control.position = newPos;
  13465. };
  13466. ScatterPanel.prototype._scatterMapping = function (source) {
  13467. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13468. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13469. return source;
  13470. };
  13471. ScatterPanel.prototype._finalProcessing = function () {
  13472. var meshes = [];
  13473. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13474. var child = _a[_i];
  13475. if (!child.mesh) {
  13476. continue;
  13477. }
  13478. meshes.push(child.mesh);
  13479. }
  13480. for (var count = 0; count < this._iteration; count++) {
  13481. meshes.sort(function (a, b) {
  13482. var distance1 = a.position.lengthSquared();
  13483. var distance2 = b.position.lengthSquared();
  13484. if (distance1 < distance2) {
  13485. return 1;
  13486. }
  13487. else if (distance1 > distance2) {
  13488. return -1;
  13489. }
  13490. return 0;
  13491. });
  13492. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13493. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13494. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector2[0];
  13495. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13496. for (var i = 0; i < meshes.length - 1; i++) {
  13497. for (var j = i + 1; j < meshes.length; j++) {
  13498. if (i != j) {
  13499. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13500. // Ignore Z axis
  13501. difference2D.x = difference.x;
  13502. difference2D.y = difference.y;
  13503. var combinedRadius = cellSize;
  13504. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13505. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13506. distance -= minSeparation;
  13507. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13508. difference2D.normalize();
  13509. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13510. meshes[j].position.addInPlace(difference);
  13511. meshes[i].position.subtractInPlace(difference);
  13512. }
  13513. }
  13514. }
  13515. }
  13516. }
  13517. };
  13518. return ScatterPanel;
  13519. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13520. /***/ }),
  13521. /***/ "./3D/controls/spherePanel.ts":
  13522. /*!************************************!*\
  13523. !*** ./3D/controls/spherePanel.ts ***!
  13524. \************************************/
  13525. /*! exports provided: SpherePanel */
  13526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13527. "use strict";
  13528. __webpack_require__.r(__webpack_exports__);
  13529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13530. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13531. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13532. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13533. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13534. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13535. /**
  13536. * Class used to create a container panel deployed on the surface of a sphere
  13537. */
  13538. var SpherePanel = /** @class */ (function (_super) {
  13539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13540. function SpherePanel() {
  13541. var _this = _super !== null && _super.apply(this, arguments) || this;
  13542. _this._radius = 5.0;
  13543. return _this;
  13544. }
  13545. Object.defineProperty(SpherePanel.prototype, "radius", {
  13546. /**
  13547. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13548. */
  13549. get: function () {
  13550. return this._radius;
  13551. },
  13552. set: function (value) {
  13553. var _this = this;
  13554. if (this._radius === value) {
  13555. return;
  13556. }
  13557. this._radius = value;
  13558. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13559. _this._arrangeChildren();
  13560. });
  13561. },
  13562. enumerable: true,
  13563. configurable: true
  13564. });
  13565. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13566. var mesh = control.mesh;
  13567. if (!mesh) {
  13568. return;
  13569. }
  13570. var newPos = this._sphericalMapping(nodePosition);
  13571. control.position = newPos;
  13572. switch (this.orientation) {
  13573. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13574. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13575. break;
  13576. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13577. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13578. break;
  13579. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13580. break;
  13581. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13582. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13583. break;
  13584. }
  13585. };
  13586. SpherePanel.prototype._sphericalMapping = function (source) {
  13587. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13588. var xAngle = (source.y / this._radius);
  13589. var yAngle = -(source.x / this._radius);
  13590. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13591. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13592. };
  13593. return SpherePanel;
  13594. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13595. /***/ }),
  13596. /***/ "./3D/controls/stackPanel3D.ts":
  13597. /*!*************************************!*\
  13598. !*** ./3D/controls/stackPanel3D.ts ***!
  13599. \*************************************/
  13600. /*! exports provided: StackPanel3D */
  13601. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13602. "use strict";
  13603. __webpack_require__.r(__webpack_exports__);
  13604. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13605. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13606. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13607. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13608. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13609. /**
  13610. * Class used to create a stack panel in 3D on XY plane
  13611. */
  13612. var StackPanel3D = /** @class */ (function (_super) {
  13613. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13614. /**
  13615. * Creates new StackPanel
  13616. * @param isVertical
  13617. */
  13618. function StackPanel3D(isVertical) {
  13619. if (isVertical === void 0) { isVertical = false; }
  13620. var _this = _super.call(this) || this;
  13621. _this._isVertical = false;
  13622. /**
  13623. * Gets or sets the distance between elements
  13624. */
  13625. _this.margin = 0.1;
  13626. _this._isVertical = isVertical;
  13627. return _this;
  13628. }
  13629. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13630. /**
  13631. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13632. */
  13633. get: function () {
  13634. return this._isVertical;
  13635. },
  13636. set: function (value) {
  13637. var _this = this;
  13638. if (this._isVertical === value) {
  13639. return;
  13640. }
  13641. this._isVertical = value;
  13642. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13643. _this._arrangeChildren();
  13644. });
  13645. },
  13646. enumerable: true,
  13647. configurable: true
  13648. });
  13649. StackPanel3D.prototype._arrangeChildren = function () {
  13650. var width = 0;
  13651. var height = 0;
  13652. var controlCount = 0;
  13653. var extendSizes = [];
  13654. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13655. // Measure
  13656. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13657. var child = _a[_i];
  13658. if (!child.mesh) {
  13659. continue;
  13660. }
  13661. controlCount++;
  13662. child.mesh.computeWorldMatrix(true);
  13663. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13664. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13665. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0]);
  13666. extendSizes.push(extendSize);
  13667. if (this._isVertical) {
  13668. height += extendSize.y;
  13669. }
  13670. else {
  13671. width += extendSize.x;
  13672. }
  13673. }
  13674. if (this._isVertical) {
  13675. height += (controlCount - 1) * this.margin / 2;
  13676. }
  13677. else {
  13678. width += (controlCount - 1) * this.margin / 2;
  13679. }
  13680. // Arrange
  13681. var offset;
  13682. if (this._isVertical) {
  13683. offset = -height;
  13684. }
  13685. else {
  13686. offset = -width;
  13687. }
  13688. var index = 0;
  13689. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13690. var child = _c[_b];
  13691. if (!child.mesh) {
  13692. continue;
  13693. }
  13694. controlCount--;
  13695. var extendSize = extendSizes[index++];
  13696. if (this._isVertical) {
  13697. child.position.y = offset + extendSize.y;
  13698. child.position.x = 0;
  13699. offset += extendSize.y * 2;
  13700. }
  13701. else {
  13702. child.position.x = offset + extendSize.x;
  13703. child.position.y = 0;
  13704. offset += extendSize.x * 2;
  13705. }
  13706. offset += (controlCount > 0 ? this.margin : 0);
  13707. }
  13708. };
  13709. return StackPanel3D;
  13710. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13711. /***/ }),
  13712. /***/ "./3D/controls/volumeBasedPanel.ts":
  13713. /*!*****************************************!*\
  13714. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13715. \*****************************************/
  13716. /*! exports provided: VolumeBasedPanel */
  13717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13718. "use strict";
  13719. __webpack_require__.r(__webpack_exports__);
  13720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13722. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  13723. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13724. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13725. /**
  13726. * Abstract class used to create a container panel deployed on the surface of a volume
  13727. */
  13728. var VolumeBasedPanel = /** @class */ (function (_super) {
  13729. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13730. /**
  13731. * Creates new VolumeBasedPanel
  13732. */
  13733. function VolumeBasedPanel() {
  13734. var _this = _super.call(this) || this;
  13735. _this._columns = 10;
  13736. _this._rows = 0;
  13737. _this._rowThenColum = true;
  13738. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13739. /**
  13740. * Gets or sets the distance between elements
  13741. */
  13742. _this.margin = 0;
  13743. return _this;
  13744. }
  13745. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13746. /**
  13747. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13748. * | Value | Type | Description |
  13749. * | ----- | ----------------------------------- | ----------- |
  13750. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13751. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13752. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13753. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13754. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13755. */
  13756. get: function () {
  13757. return this._orientation;
  13758. },
  13759. set: function (value) {
  13760. var _this = this;
  13761. if (this._orientation === value) {
  13762. return;
  13763. }
  13764. this._orientation = value;
  13765. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13766. _this._arrangeChildren();
  13767. });
  13768. },
  13769. enumerable: true,
  13770. configurable: true
  13771. });
  13772. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13773. /**
  13774. * Gets or sets the number of columns requested (10 by default).
  13775. * The panel will automatically compute the number of rows based on number of child controls.
  13776. */
  13777. get: function () {
  13778. return this._columns;
  13779. },
  13780. set: function (value) {
  13781. var _this = this;
  13782. if (this._columns === value) {
  13783. return;
  13784. }
  13785. this._columns = value;
  13786. this._rowThenColum = true;
  13787. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13788. _this._arrangeChildren();
  13789. });
  13790. },
  13791. enumerable: true,
  13792. configurable: true
  13793. });
  13794. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  13795. /**
  13796. * Gets or sets a the number of rows requested.
  13797. * The panel will automatically compute the number of columns based on number of child controls.
  13798. */
  13799. get: function () {
  13800. return this._rows;
  13801. },
  13802. set: function (value) {
  13803. var _this = this;
  13804. if (this._rows === value) {
  13805. return;
  13806. }
  13807. this._rows = value;
  13808. this._rowThenColum = false;
  13809. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13810. _this._arrangeChildren();
  13811. });
  13812. },
  13813. enumerable: true,
  13814. configurable: true
  13815. });
  13816. VolumeBasedPanel.prototype._arrangeChildren = function () {
  13817. this._cellWidth = 0;
  13818. this._cellHeight = 0;
  13819. var rows = 0;
  13820. var columns = 0;
  13821. var controlCount = 0;
  13822. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13823. // Measure
  13824. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13825. var child = _a[_i];
  13826. if (!child.mesh) {
  13827. continue;
  13828. }
  13829. controlCount++;
  13830. child.mesh.computeWorldMatrix(true);
  13831. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  13832. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  13833. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  13834. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  13835. boundingBox.max.subtractToRef(boundingBox.min, diff);
  13836. diff.scaleInPlace(0.5);
  13837. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  13838. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  13839. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  13840. }
  13841. this._cellWidth += this.margin * 2;
  13842. this._cellHeight += this.margin * 2;
  13843. // Arrange
  13844. if (this._rowThenColum) {
  13845. columns = this._columns;
  13846. rows = Math.ceil(controlCount / this._columns);
  13847. }
  13848. else {
  13849. rows = this._rows;
  13850. columns = Math.ceil(controlCount / this._rows);
  13851. }
  13852. var startOffsetX = (columns * 0.5) * this._cellWidth;
  13853. var startOffsetY = (rows * 0.5) * this._cellHeight;
  13854. var nodeGrid = [];
  13855. var cellCounter = 0;
  13856. if (this._rowThenColum) {
  13857. for (var r = 0; r < rows; r++) {
  13858. for (var c = 0; c < columns; c++) {
  13859. 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));
  13860. cellCounter++;
  13861. if (cellCounter > controlCount) {
  13862. break;
  13863. }
  13864. }
  13865. }
  13866. }
  13867. else {
  13868. for (var c = 0; c < columns; c++) {
  13869. for (var r = 0; r < rows; r++) {
  13870. 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));
  13871. cellCounter++;
  13872. if (cellCounter > controlCount) {
  13873. break;
  13874. }
  13875. }
  13876. }
  13877. }
  13878. cellCounter = 0;
  13879. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13880. var child = _c[_b];
  13881. if (!child.mesh) {
  13882. continue;
  13883. }
  13884. this._mapGridNode(child, nodeGrid[cellCounter]);
  13885. cellCounter++;
  13886. }
  13887. this._finalProcessing();
  13888. };
  13889. /** Child classes can implement this function to provide additional processing */
  13890. VolumeBasedPanel.prototype._finalProcessing = function () {
  13891. };
  13892. return VolumeBasedPanel;
  13893. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13894. /***/ }),
  13895. /***/ "./3D/gui3DManager.ts":
  13896. /*!****************************!*\
  13897. !*** ./3D/gui3DManager.ts ***!
  13898. \****************************/
  13899. /*! exports provided: GUI3DManager */
  13900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13901. "use strict";
  13902. __webpack_require__.r(__webpack_exports__);
  13903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  13904. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13905. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13906. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  13907. /**
  13908. * Class used to manage 3D user interface
  13909. * @see http://doc.babylonjs.com/how_to/gui3d
  13910. */
  13911. var GUI3DManager = /** @class */ (function () {
  13912. /**
  13913. * Creates a new GUI3DManager
  13914. * @param scene
  13915. */
  13916. function GUI3DManager(scene) {
  13917. var _this = this;
  13918. /** @hidden */
  13919. this._lastControlOver = {};
  13920. /** @hidden */
  13921. this._lastControlDown = {};
  13922. /**
  13923. * Observable raised when the point picked by the pointer events changed
  13924. */
  13925. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13926. // Shared resources
  13927. /** @hidden */
  13928. this._sharedMaterials = {};
  13929. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  13930. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  13931. _this._sceneDisposeObserver = null;
  13932. _this._utilityLayer = null;
  13933. _this.dispose();
  13934. });
  13935. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  13936. this._utilityLayer.onlyCheckPointerDownEvents = false;
  13937. this._utilityLayer.pickUtilitySceneFirst = false;
  13938. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  13939. return mesh && mesh.metadata && mesh.metadata._node;
  13940. };
  13941. // Root
  13942. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  13943. this._rootContainer._host = this;
  13944. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  13945. // Events
  13946. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  13947. _this._handlePointerOut(pointerId, true);
  13948. });
  13949. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  13950. _this._doPicking(pi);
  13951. });
  13952. // Scene
  13953. this._utilityLayer.utilityLayerScene.autoClear = false;
  13954. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  13955. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  13956. }
  13957. Object.defineProperty(GUI3DManager.prototype, "scene", {
  13958. /** Gets the hosting scene */
  13959. get: function () {
  13960. return this._scene;
  13961. },
  13962. enumerable: true,
  13963. configurable: true
  13964. });
  13965. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  13966. /** Gets associated utility layer */
  13967. get: function () {
  13968. return this._utilityLayer;
  13969. },
  13970. enumerable: true,
  13971. configurable: true
  13972. });
  13973. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  13974. var previousControlOver = this._lastControlOver[pointerId];
  13975. if (previousControlOver) {
  13976. previousControlOver._onPointerOut(previousControlOver);
  13977. delete this._lastControlOver[pointerId];
  13978. }
  13979. if (isPointerUp) {
  13980. if (this._lastControlDown[pointerId]) {
  13981. this._lastControlDown[pointerId].forcePointerUp();
  13982. delete this._lastControlDown[pointerId];
  13983. }
  13984. }
  13985. this.onPickedPointChangedObservable.notifyObservers(null);
  13986. };
  13987. GUI3DManager.prototype._doPicking = function (pi) {
  13988. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  13989. return false;
  13990. }
  13991. var pointerEvent = (pi.event);
  13992. var pointerId = pointerEvent.pointerId || 0;
  13993. var buttonIndex = pointerEvent.button;
  13994. var pickingInfo = pi.pickInfo;
  13995. if (!pickingInfo || !pickingInfo.hit) {
  13996. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  13997. return false;
  13998. }
  13999. var control = (pickingInfo.pickedMesh.metadata);
  14000. if (pickingInfo.pickedPoint) {
  14001. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14002. }
  14003. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14004. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14005. if (this._lastControlOver[pointerId]) {
  14006. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14007. }
  14008. delete this._lastControlOver[pointerId];
  14009. }
  14010. }
  14011. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14012. if (this._lastControlDown[pointerEvent.pointerId]) {
  14013. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14014. delete this._lastControlDown[pointerEvent.pointerId];
  14015. }
  14016. if (pointerEvent.pointerType === "touch") {
  14017. this._handlePointerOut(pointerId, false);
  14018. }
  14019. }
  14020. return true;
  14021. };
  14022. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14023. /**
  14024. * Gets the root container
  14025. */
  14026. get: function () {
  14027. return this._rootContainer;
  14028. },
  14029. enumerable: true,
  14030. configurable: true
  14031. });
  14032. /**
  14033. * Gets a boolean indicating if the given control is in the root child list
  14034. * @param control defines the control to check
  14035. * @returns true if the control is in the root child list
  14036. */
  14037. GUI3DManager.prototype.containsControl = function (control) {
  14038. return this._rootContainer.containsControl(control);
  14039. };
  14040. /**
  14041. * Adds a control to the root child list
  14042. * @param control defines the control to add
  14043. * @returns the current manager
  14044. */
  14045. GUI3DManager.prototype.addControl = function (control) {
  14046. this._rootContainer.addControl(control);
  14047. return this;
  14048. };
  14049. /**
  14050. * Removes a control from the root child list
  14051. * @param control defines the control to remove
  14052. * @returns the current container
  14053. */
  14054. GUI3DManager.prototype.removeControl = function (control) {
  14055. this._rootContainer.removeControl(control);
  14056. return this;
  14057. };
  14058. /**
  14059. * Releases all associated resources
  14060. */
  14061. GUI3DManager.prototype.dispose = function () {
  14062. this._rootContainer.dispose();
  14063. for (var materialName in this._sharedMaterials) {
  14064. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14065. continue;
  14066. }
  14067. this._sharedMaterials[materialName].dispose();
  14068. }
  14069. this._sharedMaterials = {};
  14070. if (this._pointerOutObserver && this._utilityLayer) {
  14071. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14072. this._pointerOutObserver = null;
  14073. }
  14074. this.onPickedPointChangedObservable.clear();
  14075. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14076. if (utilityLayerScene) {
  14077. if (this._pointerObserver) {
  14078. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14079. this._pointerObserver = null;
  14080. }
  14081. }
  14082. if (this._scene) {
  14083. if (this._sceneDisposeObserver) {
  14084. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14085. this._sceneDisposeObserver = null;
  14086. }
  14087. }
  14088. if (this._utilityLayer) {
  14089. this._utilityLayer.dispose();
  14090. }
  14091. };
  14092. return GUI3DManager;
  14093. }());
  14094. /***/ }),
  14095. /***/ "./3D/index.ts":
  14096. /*!*********************!*\
  14097. !*** ./3D/index.ts ***!
  14098. \*********************/
  14099. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14101. "use strict";
  14102. __webpack_require__.r(__webpack_exports__);
  14103. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14116. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14119. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14121. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14123. /***/ }),
  14124. /***/ "./3D/materials/fluentMaterial.ts":
  14125. /*!****************************************!*\
  14126. !*** ./3D/materials/fluentMaterial.ts ***!
  14127. \****************************************/
  14128. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14130. "use strict";
  14131. __webpack_require__.r(__webpack_exports__);
  14132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14134. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14135. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  14136. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14137. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14138. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14139. /** @hidden */
  14140. var FluentMaterialDefines = /** @class */ (function (_super) {
  14141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14142. function FluentMaterialDefines() {
  14143. var _this = _super.call(this) || this;
  14144. _this.INNERGLOW = false;
  14145. _this.BORDER = false;
  14146. _this.HOVERLIGHT = false;
  14147. _this.TEXTURE = false;
  14148. _this.rebuild();
  14149. return _this;
  14150. }
  14151. return FluentMaterialDefines;
  14152. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14153. /**
  14154. * Class used to render controls with fluent desgin
  14155. */
  14156. var FluentMaterial = /** @class */ (function (_super) {
  14157. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14158. /**
  14159. * Creates a new Fluent material
  14160. * @param name defines the name of the material
  14161. * @param scene defines the hosting scene
  14162. */
  14163. function FluentMaterial(name, scene) {
  14164. var _this = _super.call(this, name, scene) || this;
  14165. /**
  14166. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14167. */
  14168. _this.innerGlowColorIntensity = 0.5;
  14169. /**
  14170. * Gets or sets the inner glow color (white by default)
  14171. */
  14172. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14173. /**
  14174. * Gets or sets alpha value (default is 1.0)
  14175. */
  14176. _this.alpha = 1.0;
  14177. /**
  14178. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14179. */
  14180. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14181. /**
  14182. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14183. */
  14184. _this.renderBorders = false;
  14185. /**
  14186. * Gets or sets border width (default is 0.5)
  14187. */
  14188. _this.borderWidth = 0.5;
  14189. /**
  14190. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14191. */
  14192. _this.edgeSmoothingValue = 0.02;
  14193. /**
  14194. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14195. */
  14196. _this.borderMinValue = 0.1;
  14197. /**
  14198. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14199. */
  14200. _this.renderHoverLight = false;
  14201. /**
  14202. * Gets or sets the radius used to render the hover light (default is 1.0)
  14203. */
  14204. _this.hoverRadius = 1.0;
  14205. /**
  14206. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14207. */
  14208. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14209. /**
  14210. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14211. */
  14212. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14213. return _this;
  14214. }
  14215. FluentMaterial.prototype.needAlphaBlending = function () {
  14216. return this.alpha !== 1.0;
  14217. };
  14218. FluentMaterial.prototype.needAlphaTesting = function () {
  14219. return false;
  14220. };
  14221. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14222. return null;
  14223. };
  14224. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14225. if (this.isFrozen) {
  14226. if (this._wasPreviouslyReady && subMesh.effect) {
  14227. return true;
  14228. }
  14229. }
  14230. if (!subMesh._materialDefines) {
  14231. subMesh._materialDefines = new FluentMaterialDefines();
  14232. }
  14233. var scene = this.getScene();
  14234. var defines = subMesh._materialDefines;
  14235. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14236. if (defines._renderId === scene.getRenderId()) {
  14237. return true;
  14238. }
  14239. }
  14240. if (defines._areTexturesDirty) {
  14241. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14242. defines.BORDER = this.renderBorders;
  14243. defines.HOVERLIGHT = this.renderHoverLight;
  14244. if (this._albedoTexture) {
  14245. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14246. return false;
  14247. }
  14248. else {
  14249. defines.TEXTURE = true;
  14250. }
  14251. }
  14252. else {
  14253. defines.TEXTURE = false;
  14254. }
  14255. }
  14256. var engine = scene.getEngine();
  14257. // Get correct effect
  14258. if (defines.isDirty) {
  14259. defines.markAsProcessed();
  14260. scene.resetCachedMaterial();
  14261. //Attributes
  14262. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14263. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14264. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14265. var shaderName = "fluent";
  14266. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14267. "hoverColor", "hoverPosition", "hoverRadius"
  14268. ];
  14269. var samplers = ["albedoSampler"];
  14270. var uniformBuffers = new Array();
  14271. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14272. uniformsNames: uniforms,
  14273. uniformBuffersNames: uniformBuffers,
  14274. samplers: samplers,
  14275. defines: defines,
  14276. maxSimultaneousLights: 4
  14277. });
  14278. var join = defines.toString();
  14279. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14280. attributes: attribs,
  14281. uniformsNames: uniforms,
  14282. uniformBuffersNames: uniformBuffers,
  14283. samplers: samplers,
  14284. defines: join,
  14285. fallbacks: null,
  14286. onCompiled: this.onCompiled,
  14287. onError: this.onError,
  14288. indexParameters: { maxSimultaneousLights: 4 }
  14289. }, engine));
  14290. }
  14291. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14292. return false;
  14293. }
  14294. defines._renderId = scene.getRenderId();
  14295. this._wasPreviouslyReady = true;
  14296. return true;
  14297. };
  14298. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14299. var scene = this.getScene();
  14300. var defines = subMesh._materialDefines;
  14301. if (!defines) {
  14302. return;
  14303. }
  14304. var effect = subMesh.effect;
  14305. if (!effect) {
  14306. return;
  14307. }
  14308. this._activeEffect = effect;
  14309. // Matrices
  14310. this.bindOnlyWorldMatrix(world);
  14311. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14312. if (this._mustRebind(scene, effect)) {
  14313. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14314. if (defines.INNERGLOW) {
  14315. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14316. }
  14317. if (defines.BORDER) {
  14318. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14319. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14320. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14321. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14322. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0]);
  14323. }
  14324. if (defines.HOVERLIGHT) {
  14325. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14326. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14327. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14328. }
  14329. if (defines.TEXTURE) {
  14330. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14331. }
  14332. }
  14333. this._afterBind(mesh, this._activeEffect);
  14334. };
  14335. FluentMaterial.prototype.getActiveTextures = function () {
  14336. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14337. return activeTextures;
  14338. };
  14339. FluentMaterial.prototype.hasTexture = function (texture) {
  14340. if (_super.prototype.hasTexture.call(this, texture)) {
  14341. return true;
  14342. }
  14343. return false;
  14344. };
  14345. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14346. _super.prototype.dispose.call(this, forceDisposeEffect);
  14347. };
  14348. FluentMaterial.prototype.clone = function (name) {
  14349. var _this = this;
  14350. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14351. };
  14352. FluentMaterial.prototype.serialize = function () {
  14353. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14354. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14355. return serializationObject;
  14356. };
  14357. FluentMaterial.prototype.getClassName = function () {
  14358. return "FluentMaterial";
  14359. };
  14360. // Statics
  14361. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14362. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14363. };
  14364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14365. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14366. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14367. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14369. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14370. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14372. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14373. ], FluentMaterial.prototype, "alpha", void 0);
  14374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14375. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14376. ], FluentMaterial.prototype, "albedoColor", void 0);
  14377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14378. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14379. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14380. ], FluentMaterial.prototype, "renderBorders", void 0);
  14381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14382. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14383. ], FluentMaterial.prototype, "borderWidth", void 0);
  14384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14385. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14386. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14388. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14389. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14391. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14392. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14393. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14395. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14396. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14398. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14399. ], FluentMaterial.prototype, "hoverColor", void 0);
  14400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14401. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14402. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14404. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14405. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14407. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14408. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14409. return FluentMaterial;
  14410. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14411. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14412. /***/ }),
  14413. /***/ "./3D/materials/index.ts":
  14414. /*!*******************************!*\
  14415. !*** ./3D/materials/index.ts ***!
  14416. \*******************************/
  14417. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14419. "use strict";
  14420. __webpack_require__.r(__webpack_exports__);
  14421. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14424. /***/ }),
  14425. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14426. /*!*************************************************!*\
  14427. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14428. \*************************************************/
  14429. /*! exports provided: fluentPixelShader */
  14430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14431. "use strict";
  14432. __webpack_require__.r(__webpack_exports__);
  14433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14434. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14435. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14436. var name = 'fluentPixelShader';
  14437. 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}";
  14438. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14439. /** @hidden */
  14440. var fluentPixelShader = { name: name, shader: shader };
  14441. /***/ }),
  14442. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14443. /*!***********************************************!*\
  14444. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14445. \***********************************************/
  14446. /*! exports provided: fluentVertexShader */
  14447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14448. "use strict";
  14449. __webpack_require__.r(__webpack_exports__);
  14450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14451. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  14452. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14453. var name = 'fluentVertexShader';
  14454. 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";
  14455. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14456. /** @hidden */
  14457. var fluentVertexShader = { name: name, shader: shader };
  14458. /***/ }),
  14459. /***/ "./3D/vector3WithInfo.ts":
  14460. /*!*******************************!*\
  14461. !*** ./3D/vector3WithInfo.ts ***!
  14462. \*******************************/
  14463. /*! exports provided: Vector3WithInfo */
  14464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14465. "use strict";
  14466. __webpack_require__.r(__webpack_exports__);
  14467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14469. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/observable");
  14470. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14471. /**
  14472. * Class used to transport Vector3 information for pointer events
  14473. */
  14474. var Vector3WithInfo = /** @class */ (function (_super) {
  14475. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14476. /**
  14477. * Creates a new Vector3WithInfo
  14478. * @param source defines the vector3 data to transport
  14479. * @param buttonIndex defines the current mouse button index
  14480. */
  14481. function Vector3WithInfo(source,
  14482. /** defines the current mouse button index */
  14483. buttonIndex) {
  14484. if (buttonIndex === void 0) { buttonIndex = 0; }
  14485. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14486. _this.buttonIndex = buttonIndex;
  14487. return _this;
  14488. }
  14489. return Vector3WithInfo;
  14490. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14491. /***/ }),
  14492. /***/ "./index.ts":
  14493. /*!******************!*\
  14494. !*** ./index.ts ***!
  14495. \******************/
  14496. /*! 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 */
  14497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14498. "use strict";
  14499. __webpack_require__.r(__webpack_exports__);
  14500. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14539. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14556. /***/ }),
  14557. /***/ "./legacy/legacy.ts":
  14558. /*!**************************!*\
  14559. !*** ./legacy/legacy.ts ***!
  14560. \**************************/
  14561. /*! 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 */
  14562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14563. "use strict";
  14564. __webpack_require__.r(__webpack_exports__);
  14565. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14620. /**
  14621. * Legacy support, defining window.BABYLON.GUI (global variable).
  14622. *
  14623. * This is the entry point for the UMD module.
  14624. * The entry point for a future ESM package should be index.ts
  14625. */
  14626. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14627. if (typeof globalObject !== "undefined") {
  14628. globalObject.BABYLON = globalObject.BABYLON || {};
  14629. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14630. }
  14631. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14632. /***/ }),
  14633. /***/ "babylonjs/Misc/observable":
  14634. /*!****************************************************************************************************!*\
  14635. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14636. \****************************************************************************************************/
  14637. /*! no static exports found */
  14638. /***/ (function(module, exports) {
  14639. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  14640. /***/ })
  14641. /******/ });
  14642. });
  14643. //# sourceMappingURL=babylon.gui.js.map