babylon.gui.js 686 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804
  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. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__) {
  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. !*** C:/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, __spreadArrays, __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__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. 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;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. 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;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. 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); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. 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; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. 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);
  282. 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); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  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);
  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 ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  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._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  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._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootCanvas) {
  1064. this._rootCanvas.style.cursor = cursor;
  1065. this._cursorChanged = true;
  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. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /**
  1360. * Class used to create 2D buttons
  1361. */
  1362. var Button = /** @class */ (function (_super) {
  1363. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1364. /**
  1365. * Creates a new Button
  1366. * @param name defines the name of the button
  1367. */
  1368. function Button(name) {
  1369. var _this = _super.call(this, name) || this;
  1370. _this.name = name;
  1371. /**
  1372. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1373. */
  1374. _this.delegatePickingToChildren = false;
  1375. _this.thickness = 1;
  1376. _this.isPointerBlocker = true;
  1377. var alphaStore = null;
  1378. _this.pointerEnterAnimation = function () {
  1379. alphaStore = _this.alpha;
  1380. _this.alpha -= 0.1;
  1381. };
  1382. _this.pointerOutAnimation = function () {
  1383. if (alphaStore !== null) {
  1384. _this.alpha = alphaStore;
  1385. }
  1386. };
  1387. _this.pointerDownAnimation = function () {
  1388. _this.scaleX -= 0.05;
  1389. _this.scaleY -= 0.05;
  1390. };
  1391. _this.pointerUpAnimation = function () {
  1392. _this.scaleX += 0.05;
  1393. _this.scaleY += 0.05;
  1394. };
  1395. return _this;
  1396. }
  1397. Object.defineProperty(Button.prototype, "image", {
  1398. /**
  1399. * Returns the image part of the button (if any)
  1400. */
  1401. get: function () {
  1402. return this._image;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Object.defineProperty(Button.prototype, "textBlock", {
  1408. /**
  1409. * Returns the image part of the button (if any)
  1410. */
  1411. get: function () {
  1412. return this._textBlock;
  1413. },
  1414. enumerable: true,
  1415. configurable: true
  1416. });
  1417. Button.prototype._getTypeName = function () {
  1418. return "Button";
  1419. };
  1420. // While being a container, the button behaves like a control.
  1421. /** @hidden */
  1422. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1423. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1424. return false;
  1425. }
  1426. if (!_super.prototype.contains.call(this, x, y)) {
  1427. return false;
  1428. }
  1429. if (this.delegatePickingToChildren) {
  1430. var contains = false;
  1431. for (var index = this._children.length - 1; index >= 0; index--) {
  1432. var child = this._children[index];
  1433. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1434. contains = true;
  1435. break;
  1436. }
  1437. }
  1438. if (!contains) {
  1439. return false;
  1440. }
  1441. }
  1442. this._processObservables(type, x, y, pointerId, buttonIndex);
  1443. return true;
  1444. };
  1445. /** @hidden */
  1446. Button.prototype._onPointerEnter = function (target) {
  1447. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1448. return false;
  1449. }
  1450. if (this.pointerEnterAnimation) {
  1451. this.pointerEnterAnimation();
  1452. }
  1453. return true;
  1454. };
  1455. /** @hidden */
  1456. Button.prototype._onPointerOut = function (target, force) {
  1457. if (force === void 0) { force = false; }
  1458. if (this.pointerOutAnimation) {
  1459. this.pointerOutAnimation();
  1460. }
  1461. _super.prototype._onPointerOut.call(this, target, force);
  1462. };
  1463. /** @hidden */
  1464. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1465. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1466. return false;
  1467. }
  1468. if (this.pointerDownAnimation) {
  1469. this.pointerDownAnimation();
  1470. }
  1471. return true;
  1472. };
  1473. /** @hidden */
  1474. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1475. if (this.pointerUpAnimation) {
  1476. this.pointerUpAnimation();
  1477. }
  1478. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1479. };
  1480. // Statics
  1481. /**
  1482. * Creates a new button made with an image and a text
  1483. * @param name defines the name of the button
  1484. * @param text defines the text of the button
  1485. * @param imageUrl defines the url of the image
  1486. * @returns a new Button
  1487. */
  1488. Button.CreateImageButton = function (name, text, imageUrl) {
  1489. var result = new Button(name);
  1490. // Adding text
  1491. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1492. textBlock.textWrapping = true;
  1493. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1494. textBlock.paddingLeft = "20%";
  1495. result.addControl(textBlock);
  1496. // Adding image
  1497. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1498. iconImage.width = "20%";
  1499. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1500. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1501. result.addControl(iconImage);
  1502. // Store
  1503. result._image = iconImage;
  1504. result._textBlock = textBlock;
  1505. return result;
  1506. };
  1507. /**
  1508. * Creates a new button made with an image
  1509. * @param name defines the name of the button
  1510. * @param imageUrl defines the url of the image
  1511. * @returns a new Button
  1512. */
  1513. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1514. var result = new Button(name);
  1515. // Adding image
  1516. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1517. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1518. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1519. result.addControl(iconImage);
  1520. // Store
  1521. result._image = iconImage;
  1522. return result;
  1523. };
  1524. /**
  1525. * Creates a new button made with a text
  1526. * @param name defines the name of the button
  1527. * @param text defines the text of the button
  1528. * @returns a new Button
  1529. */
  1530. Button.CreateSimpleButton = function (name, text) {
  1531. var result = new Button(name);
  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._textBlock = textBlock;
  1539. return result;
  1540. };
  1541. /**
  1542. * Creates a new button made with an image and a centered text
  1543. * @param name defines the name of the button
  1544. * @param text defines the text of the button
  1545. * @param imageUrl defines the url of the image
  1546. * @returns a new Button
  1547. */
  1548. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1549. var result = new Button(name);
  1550. // Adding image
  1551. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1552. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1553. result.addControl(iconImage);
  1554. // Adding text
  1555. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1556. textBlock.textWrapping = true;
  1557. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1558. result.addControl(textBlock);
  1559. // Store
  1560. result._image = iconImage;
  1561. result._textBlock = textBlock;
  1562. return result;
  1563. };
  1564. return Button;
  1565. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1566. /***/ }),
  1567. /***/ "./2D/controls/checkbox.ts":
  1568. /*!*********************************!*\
  1569. !*** ./2D/controls/checkbox.ts ***!
  1570. \*********************************/
  1571. /*! exports provided: Checkbox */
  1572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1573. "use strict";
  1574. __webpack_require__.r(__webpack_exports__);
  1575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1579. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1580. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1581. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1582. /**
  1583. * Class used to represent a 2D checkbox
  1584. */
  1585. var Checkbox = /** @class */ (function (_super) {
  1586. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1587. /**
  1588. * Creates a new CheckBox
  1589. * @param name defines the control name
  1590. */
  1591. function Checkbox(name) {
  1592. var _this = _super.call(this, name) || this;
  1593. _this.name = name;
  1594. _this._isChecked = false;
  1595. _this._background = "black";
  1596. _this._checkSizeRatio = 0.8;
  1597. _this._thickness = 1;
  1598. /**
  1599. * Observable raised when isChecked property changes
  1600. */
  1601. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1602. _this.isPointerBlocker = true;
  1603. return _this;
  1604. }
  1605. Object.defineProperty(Checkbox.prototype, "thickness", {
  1606. /** Gets or sets border thickness */
  1607. get: function () {
  1608. return this._thickness;
  1609. },
  1610. set: function (value) {
  1611. if (this._thickness === value) {
  1612. return;
  1613. }
  1614. this._thickness = value;
  1615. this._markAsDirty();
  1616. },
  1617. enumerable: true,
  1618. configurable: true
  1619. });
  1620. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1621. /** Gets or sets a value indicating the ratio between overall size and check size */
  1622. get: function () {
  1623. return this._checkSizeRatio;
  1624. },
  1625. set: function (value) {
  1626. value = Math.max(Math.min(1, value), 0);
  1627. if (this._checkSizeRatio === value) {
  1628. return;
  1629. }
  1630. this._checkSizeRatio = value;
  1631. this._markAsDirty();
  1632. },
  1633. enumerable: true,
  1634. configurable: true
  1635. });
  1636. Object.defineProperty(Checkbox.prototype, "background", {
  1637. /** Gets or sets background color */
  1638. get: function () {
  1639. return this._background;
  1640. },
  1641. set: function (value) {
  1642. if (this._background === value) {
  1643. return;
  1644. }
  1645. this._background = value;
  1646. this._markAsDirty();
  1647. },
  1648. enumerable: true,
  1649. configurable: true
  1650. });
  1651. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1652. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1653. get: function () {
  1654. return this._isChecked;
  1655. },
  1656. set: function (value) {
  1657. if (this._isChecked === value) {
  1658. return;
  1659. }
  1660. this._isChecked = value;
  1661. this._markAsDirty();
  1662. this.onIsCheckedChangedObservable.notifyObservers(value);
  1663. },
  1664. enumerable: true,
  1665. configurable: true
  1666. });
  1667. Checkbox.prototype._getTypeName = function () {
  1668. return "Checkbox";
  1669. };
  1670. /** @hidden */
  1671. Checkbox.prototype._draw = function (context) {
  1672. context.save();
  1673. this._applyStates(context);
  1674. var actualWidth = this._currentMeasure.width - this._thickness;
  1675. var actualHeight = this._currentMeasure.height - this._thickness;
  1676. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1677. context.shadowColor = this.shadowColor;
  1678. context.shadowBlur = this.shadowBlur;
  1679. context.shadowOffsetX = this.shadowOffsetX;
  1680. context.shadowOffsetY = this.shadowOffsetY;
  1681. }
  1682. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1683. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1684. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1685. context.shadowBlur = 0;
  1686. context.shadowOffsetX = 0;
  1687. context.shadowOffsetY = 0;
  1688. }
  1689. if (this._isChecked) {
  1690. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1691. var offsetWidth = actualWidth * this._checkSizeRatio;
  1692. var offseHeight = actualHeight * this._checkSizeRatio;
  1693. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1694. }
  1695. context.strokeStyle = this.color;
  1696. context.lineWidth = this._thickness;
  1697. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1698. context.restore();
  1699. };
  1700. // Events
  1701. /** @hidden */
  1702. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1703. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1704. return false;
  1705. }
  1706. this.isChecked = !this.isChecked;
  1707. return true;
  1708. };
  1709. /**
  1710. * Utility function to easily create a checkbox with a header
  1711. * @param title defines the label to use for the header
  1712. * @param onValueChanged defines the callback to call when value changes
  1713. * @returns a StackPanel containing the checkbox and a textBlock
  1714. */
  1715. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1716. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1717. panel.isVertical = false;
  1718. panel.height = "30px";
  1719. var checkbox = new Checkbox();
  1720. checkbox.width = "20px";
  1721. checkbox.height = "20px";
  1722. checkbox.isChecked = true;
  1723. checkbox.color = "green";
  1724. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1725. panel.addControl(checkbox);
  1726. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1727. header.text = title;
  1728. header.width = "180px";
  1729. header.paddingLeft = "5px";
  1730. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1731. header.color = "white";
  1732. panel.addControl(header);
  1733. return panel;
  1734. };
  1735. return Checkbox;
  1736. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1737. /***/ }),
  1738. /***/ "./2D/controls/colorpicker.ts":
  1739. /*!************************************!*\
  1740. !*** ./2D/controls/colorpicker.ts ***!
  1741. \************************************/
  1742. /*! exports provided: ColorPicker */
  1743. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1744. "use strict";
  1745. __webpack_require__.r(__webpack_exports__);
  1746. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1747. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1748. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1749. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1750. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1751. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1752. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1753. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1754. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1755. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1756. /** Class used to create color pickers */
  1757. var ColorPicker = /** @class */ (function (_super) {
  1758. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1759. /**
  1760. * Creates a new ColorPicker
  1761. * @param name defines the control name
  1762. */
  1763. function ColorPicker(name) {
  1764. var _this = _super.call(this, name) || this;
  1765. _this.name = name;
  1766. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1767. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1768. _this._pointerStartedOnSquare = false;
  1769. _this._pointerStartedOnWheel = false;
  1770. _this._squareLeft = 0;
  1771. _this._squareTop = 0;
  1772. _this._squareSize = 0;
  1773. _this._h = 360;
  1774. _this._s = 1;
  1775. _this._v = 1;
  1776. _this._lastPointerDownID = -1;
  1777. /**
  1778. * Observable raised when the value changes
  1779. */
  1780. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1781. // Events
  1782. _this._pointerIsDown = false;
  1783. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1784. _this.size = "200px";
  1785. _this.isPointerBlocker = true;
  1786. return _this;
  1787. }
  1788. Object.defineProperty(ColorPicker.prototype, "value", {
  1789. /** Gets or sets the color of the color picker */
  1790. get: function () {
  1791. return this._value;
  1792. },
  1793. set: function (value) {
  1794. if (this._value.equals(value)) {
  1795. return;
  1796. }
  1797. this._value.copyFrom(value);
  1798. this._value.toHSVToRef(this._tmpColor);
  1799. this._h = this._tmpColor.r;
  1800. this._s = Math.max(this._tmpColor.g, 0.00001);
  1801. this._v = Math.max(this._tmpColor.b, 0.00001);
  1802. this._markAsDirty();
  1803. if (this._value.r <= ColorPicker._Epsilon) {
  1804. this._value.r = 0;
  1805. }
  1806. if (this._value.g <= ColorPicker._Epsilon) {
  1807. this._value.g = 0;
  1808. }
  1809. if (this._value.b <= ColorPicker._Epsilon) {
  1810. this._value.b = 0;
  1811. }
  1812. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1813. this._value.r = 1.0;
  1814. }
  1815. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1816. this._value.g = 1.0;
  1817. }
  1818. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1819. this._value.b = 1.0;
  1820. }
  1821. this.onValueChangedObservable.notifyObservers(this._value);
  1822. },
  1823. enumerable: true,
  1824. configurable: true
  1825. });
  1826. Object.defineProperty(ColorPicker.prototype, "width", {
  1827. /**
  1828. * Gets or sets control width
  1829. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1830. */
  1831. get: function () {
  1832. return this._width.toString(this._host);
  1833. },
  1834. set: function (value) {
  1835. if (this._width.toString(this._host) === value) {
  1836. return;
  1837. }
  1838. if (this._width.fromString(value)) {
  1839. this._height.fromString(value);
  1840. this._markAsDirty();
  1841. }
  1842. },
  1843. enumerable: true,
  1844. configurable: true
  1845. });
  1846. Object.defineProperty(ColorPicker.prototype, "height", {
  1847. /**
  1848. * Gets or sets control height
  1849. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1850. */
  1851. get: function () {
  1852. return this._height.toString(this._host);
  1853. },
  1854. /** Gets or sets control height */
  1855. set: function (value) {
  1856. if (this._height.toString(this._host) === value) {
  1857. return;
  1858. }
  1859. if (this._height.fromString(value)) {
  1860. this._width.fromString(value);
  1861. this._markAsDirty();
  1862. }
  1863. },
  1864. enumerable: true,
  1865. configurable: true
  1866. });
  1867. Object.defineProperty(ColorPicker.prototype, "size", {
  1868. /** Gets or sets control size */
  1869. get: function () {
  1870. return this.width;
  1871. },
  1872. set: function (value) {
  1873. this.width = value;
  1874. },
  1875. enumerable: true,
  1876. configurable: true
  1877. });
  1878. ColorPicker.prototype._getTypeName = function () {
  1879. return "ColorPicker";
  1880. };
  1881. /** @hidden */
  1882. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1883. if (parentMeasure.width < parentMeasure.height) {
  1884. this._currentMeasure.height = parentMeasure.width;
  1885. }
  1886. else {
  1887. this._currentMeasure.width = parentMeasure.height;
  1888. }
  1889. };
  1890. ColorPicker.prototype._updateSquareProps = function () {
  1891. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1892. var wheelThickness = radius * .2;
  1893. var innerDiameter = (radius - wheelThickness) * 2;
  1894. var squareSize = innerDiameter / (Math.sqrt(2));
  1895. var offset = radius - squareSize * .5;
  1896. this._squareLeft = this._currentMeasure.left + offset;
  1897. this._squareTop = this._currentMeasure.top + offset;
  1898. this._squareSize = squareSize;
  1899. };
  1900. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1901. var lgh = context.createLinearGradient(left, top, width + left, top);
  1902. lgh.addColorStop(0, '#fff');
  1903. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1904. context.fillStyle = lgh;
  1905. context.fillRect(left, top, width, height);
  1906. var lgv = context.createLinearGradient(left, top, left, height + top);
  1907. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1908. lgv.addColorStop(1, '#000');
  1909. context.fillStyle = lgv;
  1910. context.fillRect(left, top, width, height);
  1911. };
  1912. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1913. context.beginPath();
  1914. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1915. context.lineWidth = 3;
  1916. context.strokeStyle = '#333333';
  1917. context.stroke();
  1918. context.beginPath();
  1919. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1920. context.lineWidth = 3;
  1921. context.strokeStyle = '#ffffff';
  1922. context.stroke();
  1923. };
  1924. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1925. var canvas = document.createElement("canvas");
  1926. canvas.width = radius * 2;
  1927. canvas.height = radius * 2;
  1928. var context = canvas.getContext("2d");
  1929. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1930. var data = image.data;
  1931. var color = this._tmpColor;
  1932. var maxDistSq = radius * radius;
  1933. var innerRadius = radius - thickness;
  1934. var minDistSq = innerRadius * innerRadius;
  1935. for (var x = -radius; x < radius; x++) {
  1936. for (var y = -radius; y < radius; y++) {
  1937. var distSq = x * x + y * y;
  1938. if (distSq > maxDistSq || distSq < minDistSq) {
  1939. continue;
  1940. }
  1941. var dist = Math.sqrt(distSq);
  1942. var ang = Math.atan2(y, x);
  1943. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1944. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1945. data[index] = color.r * 255;
  1946. data[index + 1] = color.g * 255;
  1947. data[index + 2] = color.b * 255;
  1948. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1949. //apply less alpha to bigger color pickers
  1950. var alphaAmount = .2;
  1951. var maxAlpha = .2;
  1952. var minAlpha = .04;
  1953. var lowerRadius = 50;
  1954. var upperRadius = 150;
  1955. if (radius < lowerRadius) {
  1956. alphaAmount = maxAlpha;
  1957. }
  1958. else if (radius > upperRadius) {
  1959. alphaAmount = minAlpha;
  1960. }
  1961. else {
  1962. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1963. }
  1964. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1965. if (alphaRatio < alphaAmount) {
  1966. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1967. }
  1968. else if (alphaRatio > 1 - alphaAmount) {
  1969. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1970. }
  1971. else {
  1972. data[index + 3] = 255;
  1973. }
  1974. }
  1975. }
  1976. context.putImageData(image, 0, 0);
  1977. return canvas;
  1978. };
  1979. /** @hidden */
  1980. ColorPicker.prototype._draw = function (context) {
  1981. context.save();
  1982. this._applyStates(context);
  1983. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1984. var wheelThickness = radius * .2;
  1985. var left = this._currentMeasure.left;
  1986. var top = this._currentMeasure.top;
  1987. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1988. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1989. }
  1990. this._updateSquareProps();
  1991. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1992. context.shadowColor = this.shadowColor;
  1993. context.shadowBlur = this.shadowBlur;
  1994. context.shadowOffsetX = this.shadowOffsetX;
  1995. context.shadowOffsetY = this.shadowOffsetY;
  1996. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1997. }
  1998. context.drawImage(this._colorWheelCanvas, left, top);
  1999. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2000. context.shadowBlur = 0;
  2001. context.shadowOffsetX = 0;
  2002. context.shadowOffsetY = 0;
  2003. }
  2004. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2005. var cx = this._squareLeft + this._squareSize * this._s;
  2006. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2007. this._drawCircle(cx, cy, radius * .04, context);
  2008. var dist = radius - wheelThickness * .5;
  2009. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2010. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2011. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2012. context.restore();
  2013. };
  2014. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2015. if (this._pointerStartedOnWheel) {
  2016. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2017. var centerX = radius + this._currentMeasure.left;
  2018. var centerY = radius + this._currentMeasure.top;
  2019. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2020. }
  2021. else if (this._pointerStartedOnSquare) {
  2022. this._updateSquareProps();
  2023. this._s = (x - this._squareLeft) / this._squareSize;
  2024. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2025. this._s = Math.min(this._s, 1);
  2026. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2027. this._v = Math.min(this._v, 1);
  2028. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2029. }
  2030. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2031. this.value = this._tmpColor;
  2032. };
  2033. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2034. this._updateSquareProps();
  2035. var left = this._squareLeft;
  2036. var top = this._squareTop;
  2037. var size = this._squareSize;
  2038. if (x >= left && x <= left + size &&
  2039. y >= top && y <= top + size) {
  2040. return true;
  2041. }
  2042. return false;
  2043. };
  2044. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2045. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2046. var centerX = radius + this._currentMeasure.left;
  2047. var centerY = radius + this._currentMeasure.top;
  2048. var wheelThickness = radius * .2;
  2049. var innerRadius = radius - wheelThickness;
  2050. var radiusSq = radius * radius;
  2051. var innerRadiusSq = innerRadius * innerRadius;
  2052. var dx = x - centerX;
  2053. var dy = y - centerY;
  2054. var distSq = dx * dx + dy * dy;
  2055. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2056. return true;
  2057. }
  2058. return false;
  2059. };
  2060. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2061. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2062. return false;
  2063. }
  2064. this._pointerIsDown = true;
  2065. this._pointerStartedOnSquare = false;
  2066. this._pointerStartedOnWheel = false;
  2067. // Invert transform
  2068. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2069. var x = this._transformedPosition.x;
  2070. var y = this._transformedPosition.y;
  2071. if (this._isPointOnSquare(x, y)) {
  2072. this._pointerStartedOnSquare = true;
  2073. }
  2074. else if (this._isPointOnWheel(x, y)) {
  2075. this._pointerStartedOnWheel = true;
  2076. }
  2077. this._updateValueFromPointer(x, y);
  2078. this._host._capturingControl[pointerId] = this;
  2079. this._lastPointerDownID = pointerId;
  2080. return true;
  2081. };
  2082. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2083. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2084. if (pointerId != this._lastPointerDownID) {
  2085. return;
  2086. }
  2087. // Invert transform
  2088. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2089. var x = this._transformedPosition.x;
  2090. var y = this._transformedPosition.y;
  2091. if (this._pointerIsDown) {
  2092. this._updateValueFromPointer(x, y);
  2093. }
  2094. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2095. };
  2096. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2097. this._pointerIsDown = false;
  2098. delete this._host._capturingControl[pointerId];
  2099. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2100. };
  2101. /**
  2102. * This function expands the color picker by creating a color picker dialog with manual
  2103. * color value input and the ability to save colors into an array to be used later in
  2104. * subsequent launches of the dialogue.
  2105. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2106. * @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.
  2107. * @returns picked color as a hex string and the saved colors array as hex strings.
  2108. */
  2109. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2110. return new Promise(function (resolve, reject) {
  2111. // Default options
  2112. options.pickerWidth = options.pickerWidth || "640px";
  2113. options.pickerHeight = options.pickerHeight || "400px";
  2114. options.headerHeight = options.headerHeight || "35px";
  2115. options.lastColor = options.lastColor || "#000000";
  2116. options.swatchLimit = options.swatchLimit || 20;
  2117. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2118. // Window size settings
  2119. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2120. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2121. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2122. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2123. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2124. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2125. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2126. // Button Colors
  2127. var buttonColor = "#c0c0c0";
  2128. var buttonBackgroundColor = "#535353";
  2129. var buttonBackgroundHoverColor = "#414141";
  2130. var buttonBackgroundClickColor = "515151";
  2131. var buttonDisabledColor = "#555555";
  2132. var buttonDisabledBackgroundColor = "#454545";
  2133. var currentSwatchesOutlineColor = "#404040";
  2134. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2135. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2136. var iconColorDark = "#aaaaaa";
  2137. var iconColorLight = "#ffffff";
  2138. var closeIconColor;
  2139. // Button settings
  2140. var buttonFontSize;
  2141. var butEdit;
  2142. var buttonWidth;
  2143. var buttonHeight;
  2144. // Input Text Colors
  2145. var inputFieldLabels = ["R", "G", "B"];
  2146. var inputTextBackgroundColor = "#454545";
  2147. var inputTextColor = "#f0f0f0";
  2148. // This is the current color as set by either the picker or by entering a value
  2149. var currentColor;
  2150. // This int is used for naming swatches and serves as the index for calling them from the list
  2151. var swatchNumber;
  2152. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2153. var swatchDrawer;
  2154. var editSwatchMode = false;
  2155. // Color InputText fields that will be updated upon value change
  2156. var picker;
  2157. var rValInt;
  2158. var gValInt;
  2159. var bValInt;
  2160. var rValDec;
  2161. var gValDec;
  2162. var bValDec;
  2163. var hexVal;
  2164. var newSwatch;
  2165. var lastVal;
  2166. var activeField;
  2167. /**
  2168. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2169. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2170. * are will receive no update. This is to prevent the input from the user being overwritten.
  2171. */
  2172. function updateValues(value, inputField) {
  2173. activeField = inputField;
  2174. var pickedColor = value.toHexString();
  2175. newSwatch.background = pickedColor;
  2176. if (rValInt.name != activeField) {
  2177. rValInt.text = Math.floor(value.r * 255).toString();
  2178. }
  2179. if (gValInt.name != activeField) {
  2180. gValInt.text = Math.floor(value.g * 255).toString();
  2181. }
  2182. if (bValInt.name != activeField) {
  2183. bValInt.text = Math.floor(value.b * 255).toString();
  2184. }
  2185. if (rValDec.name != activeField) {
  2186. rValDec.text = value.r.toString();
  2187. }
  2188. if (gValDec.name != activeField) {
  2189. gValDec.text = value.g.toString();
  2190. }
  2191. if (bValDec.name != activeField) {
  2192. bValDec.text = value.b.toString();
  2193. }
  2194. if (hexVal.name != activeField) {
  2195. var minusPound = pickedColor.split("#");
  2196. hexVal.text = minusPound[1];
  2197. }
  2198. if (picker.name != activeField) {
  2199. picker.value = value;
  2200. }
  2201. }
  2202. // 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.
  2203. function updateInt(field, channel) {
  2204. var newValue = field.text;
  2205. var checkVal = /[^0-9]/g.test(newValue);
  2206. if (checkVal) {
  2207. field.text = lastVal;
  2208. return;
  2209. }
  2210. else {
  2211. if (newValue != "") {
  2212. if (Math.floor(parseInt(newValue)) < 0) {
  2213. newValue = "0";
  2214. }
  2215. else if (Math.floor(parseInt(newValue)) > 255) {
  2216. newValue = "255";
  2217. }
  2218. else if (isNaN(parseInt(newValue))) {
  2219. newValue = "0";
  2220. }
  2221. }
  2222. if (activeField == field.name) {
  2223. lastVal = newValue;
  2224. }
  2225. }
  2226. if (newValue != "") {
  2227. newValue = parseInt(newValue).toString();
  2228. field.text = newValue;
  2229. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2230. if (activeField == field.name) {
  2231. if (channel == "r") {
  2232. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2233. }
  2234. else if (channel == "g") {
  2235. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2236. }
  2237. else {
  2238. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2239. }
  2240. }
  2241. }
  2242. }
  2243. // 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.
  2244. function updateFloat(field, channel) {
  2245. var newValue = field.text;
  2246. var checkVal = /[^0-9\.]/g.test(newValue);
  2247. if (checkVal) {
  2248. field.text = lastVal;
  2249. return;
  2250. }
  2251. else {
  2252. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2253. if (parseFloat(newValue) < 0.0) {
  2254. newValue = "0.0";
  2255. }
  2256. else if (parseFloat(newValue) > 1.0) {
  2257. newValue = "1.0";
  2258. }
  2259. else if (isNaN(parseFloat(newValue))) {
  2260. newValue = "0.0";
  2261. }
  2262. }
  2263. if (activeField == field.name) {
  2264. lastVal = newValue;
  2265. }
  2266. }
  2267. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2268. newValue = parseFloat(newValue).toString();
  2269. field.text = newValue;
  2270. }
  2271. else {
  2272. newValue = "0.0";
  2273. }
  2274. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2275. if (activeField == field.name) {
  2276. if (channel == "r") {
  2277. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2278. }
  2279. else if (channel == "g") {
  2280. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2281. }
  2282. else {
  2283. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2284. }
  2285. }
  2286. }
  2287. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2288. function deleteSwatch(index) {
  2289. if (options.savedColors) {
  2290. options.savedColors.splice(index, 1);
  2291. }
  2292. if (options.savedColors && options.savedColors.length == 0) {
  2293. setEditButtonVisibility(false);
  2294. editSwatchMode = false;
  2295. }
  2296. }
  2297. // Creates and styles an individual swatch when updateSwatches is called.
  2298. function createSwatch() {
  2299. if (options.savedColors && options.savedColors[swatchNumber]) {
  2300. if (editSwatchMode) {
  2301. var icon = "b";
  2302. }
  2303. else {
  2304. var icon = "";
  2305. }
  2306. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2307. swatch.fontFamily = "BabylonJSglyphs";
  2308. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2309. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2310. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2311. if (swatchLuminence > luminanceLimit) {
  2312. swatch.color = iconColorDark;
  2313. }
  2314. else {
  2315. swatch.color = iconColorLight;
  2316. }
  2317. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2318. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2319. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2320. swatch.background = options.savedColors[swatchNumber];
  2321. swatch.thickness = 2;
  2322. var metadata_1 = swatchNumber;
  2323. swatch.pointerDownAnimation = function () {
  2324. swatch.thickness = 4;
  2325. };
  2326. swatch.pointerUpAnimation = function () {
  2327. swatch.thickness = 3;
  2328. };
  2329. swatch.pointerEnterAnimation = function () {
  2330. swatch.thickness = 3;
  2331. };
  2332. swatch.pointerOutAnimation = function () {
  2333. swatch.thickness = 2;
  2334. };
  2335. swatch.onPointerClickObservable.add(function () {
  2336. if (!editSwatchMode) {
  2337. if (options.savedColors) {
  2338. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2339. }
  2340. }
  2341. else {
  2342. deleteSwatch(metadata_1);
  2343. updateSwatches("", butSave);
  2344. }
  2345. });
  2346. return swatch;
  2347. }
  2348. else {
  2349. return null;
  2350. }
  2351. }
  2352. // Mode switch to render button text and close symbols on swatch controls
  2353. function editSwatches(mode) {
  2354. if (mode !== undefined) {
  2355. editSwatchMode = mode;
  2356. }
  2357. if (editSwatchMode) {
  2358. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2359. var thisButton = swatchDrawer.children[i];
  2360. thisButton.textBlock.text = "b";
  2361. }
  2362. if (butEdit !== undefined) {
  2363. butEdit.textBlock.text = "Done";
  2364. }
  2365. }
  2366. else {
  2367. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2368. var thisButton = swatchDrawer.children[i];
  2369. thisButton.textBlock.text = "";
  2370. }
  2371. if (butEdit !== undefined) {
  2372. butEdit.textBlock.text = "Edit";
  2373. }
  2374. }
  2375. }
  2376. /**
  2377. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2378. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2379. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2380. * saved colors there are and how many can be stored per row.
  2381. */
  2382. function updateSwatches(color, button) {
  2383. if (options.savedColors) {
  2384. if (color != "") {
  2385. options.savedColors.push(color);
  2386. }
  2387. swatchNumber = 0;
  2388. swatchDrawer.clearControls();
  2389. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2390. if (rowCount == 0) {
  2391. var gutterCount = 0;
  2392. }
  2393. else {
  2394. var gutterCount = rowCount + 1;
  2395. }
  2396. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2397. var currentRows = swatchDrawer.rowCount;
  2398. for (var i = 0; i < currentRows; i++) {
  2399. swatchDrawer.removeRowDefinition(0);
  2400. }
  2401. for (var i = 0; i < rowCount + gutterCount; i++) {
  2402. if (i % 2) {
  2403. swatchDrawer.addRowDefinition(swatchSize, true);
  2404. }
  2405. else {
  2406. swatchDrawer.addRowDefinition(gutterSize, true);
  2407. }
  2408. }
  2409. }
  2410. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2411. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2412. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2413. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2414. var totalButtonsThisRow = options.numSwatchesPerLine;
  2415. }
  2416. else {
  2417. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2418. }
  2419. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2420. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2421. if (x > options.numSwatchesPerLine) {
  2422. continue;
  2423. }
  2424. var swatch = createSwatch();
  2425. if (swatch != null) {
  2426. swatchDrawer.addControl(swatch, y, w);
  2427. w += 2;
  2428. swatchNumber++;
  2429. }
  2430. else {
  2431. continue;
  2432. }
  2433. }
  2434. }
  2435. if (options.savedColors.length >= options.swatchLimit) {
  2436. disableButton(button, true);
  2437. }
  2438. else {
  2439. disableButton(button, false);
  2440. }
  2441. }
  2442. }
  2443. // Shows or hides edit swatches button depending on if there are saved swatches
  2444. function setEditButtonVisibility(enableButton) {
  2445. if (enableButton) {
  2446. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2447. butEdit.width = buttonWidth;
  2448. butEdit.height = buttonHeight;
  2449. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2450. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2451. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2452. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2453. butEdit.thickness = 2;
  2454. butEdit.color = buttonColor;
  2455. butEdit.fontSize = buttonFontSize;
  2456. butEdit.background = buttonBackgroundColor;
  2457. butEdit.onPointerEnterObservable.add(function () {
  2458. butEdit.background = buttonBackgroundHoverColor;
  2459. });
  2460. butEdit.onPointerOutObservable.add(function () {
  2461. butEdit.background = buttonBackgroundColor;
  2462. });
  2463. butEdit.pointerDownAnimation = function () {
  2464. butEdit.background = buttonBackgroundClickColor;
  2465. };
  2466. butEdit.pointerUpAnimation = function () {
  2467. butEdit.background = buttonBackgroundHoverColor;
  2468. };
  2469. butEdit.onPointerClickObservable.add(function () {
  2470. if (editSwatchMode) {
  2471. editSwatchMode = false;
  2472. }
  2473. else {
  2474. editSwatchMode = true;
  2475. }
  2476. editSwatches();
  2477. });
  2478. pickerGrid.addControl(butEdit, 1, 0);
  2479. }
  2480. else {
  2481. pickerGrid.removeControl(butEdit);
  2482. }
  2483. }
  2484. // Called when the user hits the limit of saved colors in the drawer.
  2485. function disableButton(button, disabled) {
  2486. if (disabled) {
  2487. button.color = buttonDisabledColor;
  2488. button.background = buttonDisabledBackgroundColor;
  2489. }
  2490. else {
  2491. button.color = buttonColor;
  2492. button.background = buttonBackgroundColor;
  2493. }
  2494. }
  2495. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2496. function closePicker(color) {
  2497. if (options.savedColors && options.savedColors.length > 0) {
  2498. resolve({
  2499. savedColors: options.savedColors,
  2500. pickedColor: color
  2501. });
  2502. }
  2503. else {
  2504. resolve({
  2505. pickedColor: color
  2506. });
  2507. }
  2508. advancedTexture.removeControl(dialogContainer);
  2509. }
  2510. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2511. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2512. dialogContainer.name = "Dialog Container";
  2513. dialogContainer.width = options.pickerWidth;
  2514. if (options.savedColors) {
  2515. dialogContainer.height = containerSize;
  2516. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2517. dialogContainer.addRowDefinition(topRow, false);
  2518. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2519. }
  2520. else {
  2521. dialogContainer.height = options.pickerHeight;
  2522. dialogContainer.addRowDefinition(1.0, false);
  2523. }
  2524. advancedTexture.addControl(dialogContainer);
  2525. // Swatch drawer which contains all saved color buttons
  2526. if (options.savedColors) {
  2527. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2528. swatchDrawer.name = "Swatch Drawer";
  2529. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2530. swatchDrawer.background = buttonBackgroundColor;
  2531. swatchDrawer.width = options.pickerWidth;
  2532. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2533. if (initialRows == 0) {
  2534. var gutterCount = 0;
  2535. }
  2536. else {
  2537. var gutterCount = initialRows + 1;
  2538. }
  2539. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2540. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2541. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2542. if (i % 2 != 0) {
  2543. swatchDrawer.addRowDefinition(swatchSize, true);
  2544. }
  2545. else {
  2546. swatchDrawer.addRowDefinition(gutterSize, true);
  2547. }
  2548. }
  2549. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2550. if (i % 2 != 0) {
  2551. swatchDrawer.addColumnDefinition(swatchSize, true);
  2552. }
  2553. else {
  2554. swatchDrawer.addColumnDefinition(gutterSize, true);
  2555. }
  2556. }
  2557. dialogContainer.addControl(swatchDrawer, 1, 0);
  2558. }
  2559. // Picker container
  2560. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2561. pickerPanel.name = "Picker Panel";
  2562. pickerPanel.height = options.pickerHeight;
  2563. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2564. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2565. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2566. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2567. dialogContainer.addControl(pickerPanel, 0, 0);
  2568. // Picker container header
  2569. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2570. header.name = "Dialogue Header Bar";
  2571. header.background = "#cccccc";
  2572. header.thickness = 0;
  2573. pickerPanel.addControl(header, 0, 0);
  2574. // Header close button
  2575. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2576. closeButton.fontFamily = "BabylonJSglyphs";
  2577. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2578. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2579. closeButton.color = closeIconColor.toHexString();
  2580. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2581. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2582. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2583. closeButton.height = closeButton.width = options.headerHeight;
  2584. closeButton.background = header.background;
  2585. closeButton.thickness = 0;
  2586. closeButton.pointerDownAnimation = function () {
  2587. };
  2588. closeButton.pointerUpAnimation = function () {
  2589. closeButton.background = header.background;
  2590. };
  2591. closeButton.pointerEnterAnimation = function () {
  2592. closeButton.color = header.background;
  2593. closeButton.background = "red";
  2594. };
  2595. closeButton.pointerOutAnimation = function () {
  2596. closeButton.color = closeIconColor.toHexString();
  2597. closeButton.background = header.background;
  2598. };
  2599. closeButton.onPointerClickObservable.add(function () {
  2600. closePicker(currentSwatch.background);
  2601. });
  2602. pickerPanel.addControl(closeButton, 0, 0);
  2603. // Dialog container body
  2604. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2605. dialogBody.name = "Dialogue Body";
  2606. dialogBody.background = buttonBackgroundColor;
  2607. var dialogBodyCols = [0.4375, 0.5625];
  2608. dialogBody.addRowDefinition(1.0, false);
  2609. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2610. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2611. pickerPanel.addControl(dialogBody, 1, 0);
  2612. // Picker grid
  2613. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2614. pickerGrid.name = "Picker Grid";
  2615. pickerGrid.addRowDefinition(0.85, false);
  2616. pickerGrid.addRowDefinition(0.15, false);
  2617. dialogBody.addControl(pickerGrid, 0, 0);
  2618. // Picker control
  2619. picker = new ColorPicker();
  2620. picker.name = "GUI Color Picker";
  2621. if (options.pickerHeight < options.pickerWidth) {
  2622. picker.width = 0.89;
  2623. }
  2624. else {
  2625. picker.height = 0.89;
  2626. }
  2627. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2628. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2629. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2630. picker.onPointerDownObservable.add(function () {
  2631. activeField = picker.name;
  2632. lastVal = "";
  2633. editSwatches(false);
  2634. });
  2635. picker.onValueChangedObservable.add(function (value) {
  2636. if (activeField == picker.name) {
  2637. updateValues(value, picker.name);
  2638. }
  2639. });
  2640. pickerGrid.addControl(picker, 0, 0);
  2641. // Picker body right quarant
  2642. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. pickerBodyRight.name = "Dialogue Right Half";
  2644. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2645. var pickerBodyRightRows = [0.514, 0.486];
  2646. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2647. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2648. dialogBody.addControl(pickerBodyRight, 1, 1);
  2649. // Picker container swatches and buttons
  2650. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2651. pickerSwatchesButtons.name = "Swatches and Buttons";
  2652. var pickerButtonsCol = [0.417, 0.583];
  2653. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2654. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2655. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2656. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2657. // Picker Swatches quadrant
  2658. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. pickerSwatches.name = "New and Current Swatches";
  2660. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2661. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2662. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2663. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2664. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2665. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2666. // Active swatches
  2667. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. activeSwatches.name = "Active Swatches";
  2669. activeSwatches.width = 0.67;
  2670. activeSwatches.addRowDefinition(0.5, false);
  2671. activeSwatches.addRowDefinition(0.5, false);
  2672. pickerSwatches.addControl(activeSwatches, 2, 0);
  2673. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2674. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2675. if (options.pickerWidth > options.pickerHeight) {
  2676. var labelTextSize = labelHeight;
  2677. }
  2678. else {
  2679. var labelTextSize = labelWidth;
  2680. }
  2681. // New color swatch and previous color button
  2682. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2683. newText.text = "new";
  2684. newText.name = "New Color Label";
  2685. newText.color = buttonColor;
  2686. newText.fontSize = labelTextSize;
  2687. pickerSwatches.addControl(newText, 1, 0);
  2688. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2689. newSwatch.name = "New Color Swatch";
  2690. newSwatch.background = options.lastColor;
  2691. newSwatch.thickness = 0;
  2692. activeSwatches.addControl(newSwatch, 0, 0);
  2693. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2694. currentSwatch.background = options.lastColor;
  2695. currentSwatch.thickness = 0;
  2696. currentSwatch.onPointerClickObservable.add(function () {
  2697. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2698. updateValues(revertColor, currentSwatch.name);
  2699. editSwatches(false);
  2700. });
  2701. currentSwatch.pointerDownAnimation = function () { };
  2702. currentSwatch.pointerUpAnimation = function () { };
  2703. currentSwatch.pointerEnterAnimation = function () { };
  2704. currentSwatch.pointerOutAnimation = function () { };
  2705. activeSwatches.addControl(currentSwatch, 1, 0);
  2706. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2707. swatchOutline.name = "Swatch Outline";
  2708. swatchOutline.width = 0.67;
  2709. swatchOutline.thickness = 2;
  2710. swatchOutline.color = currentSwatchesOutlineColor;
  2711. swatchOutline.isHitTestVisible = false;
  2712. pickerSwatches.addControl(swatchOutline, 2, 0);
  2713. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2714. currentText.name = "Current Color Label";
  2715. currentText.text = "current";
  2716. currentText.color = buttonColor;
  2717. currentText.fontSize = labelTextSize;
  2718. pickerSwatches.addControl(currentText, 3, 0);
  2719. // Buttons grid
  2720. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2721. buttonGrid.name = "Button Grid";
  2722. buttonGrid.height = 0.8;
  2723. var buttonGridRows = 1 / 3;
  2724. buttonGrid.addRowDefinition(buttonGridRows, false);
  2725. buttonGrid.addRowDefinition(buttonGridRows, false);
  2726. buttonGrid.addRowDefinition(buttonGridRows, false);
  2727. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2728. // Determine pixel width and height for all buttons from overall panel dimensions
  2729. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2730. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2731. // Determine button type size
  2732. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2733. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2734. }
  2735. else {
  2736. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2737. }
  2738. // Panel Buttons
  2739. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2740. butOK.width = buttonWidth;
  2741. butOK.height = buttonHeight;
  2742. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2743. butOK.thickness = 2;
  2744. butOK.color = buttonColor;
  2745. butOK.fontSize = buttonFontSize;
  2746. butOK.background = buttonBackgroundColor;
  2747. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2748. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2749. butOK.pointerDownAnimation = function () {
  2750. butOK.background = buttonBackgroundClickColor;
  2751. };
  2752. butOK.pointerUpAnimation = function () {
  2753. butOK.background = buttonBackgroundHoverColor;
  2754. };
  2755. butOK.onPointerClickObservable.add(function () {
  2756. editSwatches(false);
  2757. closePicker(newSwatch.background);
  2758. });
  2759. buttonGrid.addControl(butOK, 0, 0);
  2760. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2761. butCancel.width = buttonWidth;
  2762. butCancel.height = buttonHeight;
  2763. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2764. butCancel.thickness = 2;
  2765. butCancel.color = buttonColor;
  2766. butCancel.fontSize = buttonFontSize;
  2767. butCancel.background = buttonBackgroundColor;
  2768. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2769. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2770. butCancel.pointerDownAnimation = function () {
  2771. butCancel.background = buttonBackgroundClickColor;
  2772. };
  2773. butCancel.pointerUpAnimation = function () {
  2774. butCancel.background = buttonBackgroundHoverColor;
  2775. };
  2776. butCancel.onPointerClickObservable.add(function () {
  2777. editSwatches(false);
  2778. closePicker(currentSwatch.background);
  2779. });
  2780. buttonGrid.addControl(butCancel, 1, 0);
  2781. if (options.savedColors) {
  2782. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2783. butSave.width = buttonWidth;
  2784. butSave.height = buttonHeight;
  2785. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2786. butSave.thickness = 2;
  2787. butSave.fontSize = buttonFontSize;
  2788. if (options.savedColors.length < options.swatchLimit) {
  2789. butSave.color = buttonColor;
  2790. butSave.background = buttonBackgroundColor;
  2791. }
  2792. else {
  2793. disableButton(butSave, true);
  2794. }
  2795. butSave.onPointerEnterObservable.add(function () {
  2796. if (options.savedColors) {
  2797. if (options.savedColors.length < options.swatchLimit) {
  2798. butSave.background = buttonBackgroundHoverColor;
  2799. }
  2800. }
  2801. });
  2802. butSave.onPointerOutObservable.add(function () {
  2803. if (options.savedColors) {
  2804. if (options.savedColors.length < options.swatchLimit) {
  2805. butSave.background = buttonBackgroundColor;
  2806. }
  2807. }
  2808. });
  2809. butSave.pointerDownAnimation = function () {
  2810. if (options.savedColors) {
  2811. if (options.savedColors.length < options.swatchLimit) {
  2812. butSave.background = buttonBackgroundClickColor;
  2813. }
  2814. }
  2815. };
  2816. butSave.pointerUpAnimation = function () {
  2817. if (options.savedColors) {
  2818. if (options.savedColors.length < options.swatchLimit) {
  2819. butSave.background = buttonBackgroundHoverColor;
  2820. }
  2821. }
  2822. };
  2823. butSave.onPointerClickObservable.add(function () {
  2824. if (options.savedColors) {
  2825. if (options.savedColors.length == 0) {
  2826. setEditButtonVisibility(true);
  2827. }
  2828. if (options.savedColors.length < options.swatchLimit) {
  2829. updateSwatches(newSwatch.background, butSave);
  2830. }
  2831. editSwatches(false);
  2832. }
  2833. });
  2834. if (options.savedColors.length > 0) {
  2835. setEditButtonVisibility(true);
  2836. }
  2837. buttonGrid.addControl(butSave, 2, 0);
  2838. }
  2839. // Picker color values input
  2840. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2841. pickerColorValues.name = "Dialog Lower Right";
  2842. pickerColorValues.addRowDefinition(0.02, false);
  2843. pickerColorValues.addRowDefinition(0.63, false);
  2844. pickerColorValues.addRowDefinition(0.21, false);
  2845. pickerColorValues.addRowDefinition(0.14, false);
  2846. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2847. // RGB values text boxes
  2848. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2849. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2850. rgbValuesQuadrant.name = "RGB Values";
  2851. rgbValuesQuadrant.width = 0.82;
  2852. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2853. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2854. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2855. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2856. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2857. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2858. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2859. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2860. for (var i = 0; i < inputFieldLabels.length; i++) {
  2861. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2862. labelText.text = inputFieldLabels[i];
  2863. labelText.color = buttonColor;
  2864. labelText.fontSize = buttonFontSize;
  2865. rgbValuesQuadrant.addControl(labelText, i, 0);
  2866. }
  2867. // Input fields for RGB values
  2868. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2869. rValInt.width = 0.83;
  2870. rValInt.height = 0.72;
  2871. rValInt.name = "rIntField";
  2872. rValInt.fontSize = buttonFontSize;
  2873. rValInt.text = (currentColor.r * 255).toString();
  2874. rValInt.color = inputTextColor;
  2875. rValInt.background = inputTextBackgroundColor;
  2876. rValInt.onFocusObservable.add(function () {
  2877. activeField = rValInt.name;
  2878. lastVal = rValInt.text;
  2879. editSwatches(false);
  2880. });
  2881. rValInt.onBlurObservable.add(function () {
  2882. if (rValInt.text == "") {
  2883. rValInt.text = "0";
  2884. }
  2885. updateInt(rValInt, "r");
  2886. if (activeField == rValInt.name) {
  2887. activeField = "";
  2888. }
  2889. });
  2890. rValInt.onTextChangedObservable.add(function () {
  2891. if (activeField == rValInt.name) {
  2892. updateInt(rValInt, "r");
  2893. }
  2894. });
  2895. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2896. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2897. gValInt.width = 0.83;
  2898. gValInt.height = 0.72;
  2899. gValInt.name = "gIntField";
  2900. gValInt.fontSize = buttonFontSize;
  2901. gValInt.text = (currentColor.g * 255).toString();
  2902. gValInt.color = inputTextColor;
  2903. gValInt.background = inputTextBackgroundColor;
  2904. gValInt.onFocusObservable.add(function () {
  2905. activeField = gValInt.name;
  2906. lastVal = gValInt.text;
  2907. editSwatches(false);
  2908. });
  2909. gValInt.onBlurObservable.add(function () {
  2910. if (gValInt.text == "") {
  2911. gValInt.text = "0";
  2912. }
  2913. updateInt(gValInt, "g");
  2914. if (activeField == gValInt.name) {
  2915. activeField = "";
  2916. }
  2917. });
  2918. gValInt.onTextChangedObservable.add(function () {
  2919. if (activeField == gValInt.name) {
  2920. updateInt(gValInt, "g");
  2921. }
  2922. });
  2923. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2924. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2925. bValInt.width = 0.83;
  2926. bValInt.height = 0.72;
  2927. bValInt.name = "bIntField";
  2928. bValInt.fontSize = buttonFontSize;
  2929. bValInt.text = (currentColor.b * 255).toString();
  2930. bValInt.color = inputTextColor;
  2931. bValInt.background = inputTextBackgroundColor;
  2932. bValInt.onFocusObservable.add(function () {
  2933. activeField = bValInt.name;
  2934. lastVal = bValInt.text;
  2935. editSwatches(false);
  2936. });
  2937. bValInt.onBlurObservable.add(function () {
  2938. if (bValInt.text == "") {
  2939. bValInt.text = "0";
  2940. }
  2941. updateInt(bValInt, "b");
  2942. if (activeField == bValInt.name) {
  2943. activeField = "";
  2944. }
  2945. });
  2946. bValInt.onTextChangedObservable.add(function () {
  2947. if (activeField == bValInt.name) {
  2948. updateInt(bValInt, "b");
  2949. }
  2950. });
  2951. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2952. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2953. rValDec.width = 0.95;
  2954. rValDec.height = 0.72;
  2955. rValDec.name = "rDecField";
  2956. rValDec.fontSize = buttonFontSize;
  2957. rValDec.text = currentColor.r.toString();
  2958. rValDec.color = inputTextColor;
  2959. rValDec.background = inputTextBackgroundColor;
  2960. rValDec.onFocusObservable.add(function () {
  2961. activeField = rValDec.name;
  2962. lastVal = rValDec.text;
  2963. editSwatches(false);
  2964. });
  2965. rValDec.onBlurObservable.add(function () {
  2966. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2967. rValDec.text = "0";
  2968. updateFloat(rValDec, "r");
  2969. }
  2970. if (activeField == rValDec.name) {
  2971. activeField = "";
  2972. }
  2973. });
  2974. rValDec.onTextChangedObservable.add(function () {
  2975. if (activeField == rValDec.name) {
  2976. updateFloat(rValDec, "r");
  2977. }
  2978. });
  2979. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2980. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2981. gValDec.width = 0.95;
  2982. gValDec.height = 0.72;
  2983. gValDec.name = "gDecField";
  2984. gValDec.fontSize = buttonFontSize;
  2985. gValDec.text = currentColor.g.toString();
  2986. gValDec.color = inputTextColor;
  2987. gValDec.background = inputTextBackgroundColor;
  2988. gValDec.onFocusObservable.add(function () {
  2989. activeField = gValDec.name;
  2990. lastVal = gValDec.text;
  2991. editSwatches(false);
  2992. });
  2993. gValDec.onBlurObservable.add(function () {
  2994. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2995. gValDec.text = "0";
  2996. updateFloat(gValDec, "g");
  2997. }
  2998. if (activeField == gValDec.name) {
  2999. activeField = "";
  3000. }
  3001. });
  3002. gValDec.onTextChangedObservable.add(function () {
  3003. if (activeField == gValDec.name) {
  3004. updateFloat(gValDec, "g");
  3005. }
  3006. });
  3007. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3008. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3009. bValDec.width = 0.95;
  3010. bValDec.height = 0.72;
  3011. bValDec.name = "bDecField";
  3012. bValDec.fontSize = buttonFontSize;
  3013. bValDec.text = currentColor.b.toString();
  3014. bValDec.color = inputTextColor;
  3015. bValDec.background = inputTextBackgroundColor;
  3016. bValDec.onFocusObservable.add(function () {
  3017. activeField = bValDec.name;
  3018. lastVal = bValDec.text;
  3019. editSwatches(false);
  3020. });
  3021. bValDec.onBlurObservable.add(function () {
  3022. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3023. bValDec.text = "0";
  3024. updateFloat(bValDec, "b");
  3025. }
  3026. if (activeField == bValDec.name) {
  3027. activeField = "";
  3028. }
  3029. });
  3030. bValDec.onTextChangedObservable.add(function () {
  3031. if (activeField == bValDec.name) {
  3032. updateFloat(bValDec, "b");
  3033. }
  3034. });
  3035. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3036. // Hex value input
  3037. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3038. hexValueQuadrant.name = "Hex Value";
  3039. hexValueQuadrant.width = 0.82;
  3040. hexValueQuadrant.addRowDefinition(1.0, false);
  3041. hexValueQuadrant.addColumnDefinition(0.1, false);
  3042. hexValueQuadrant.addColumnDefinition(0.9, false);
  3043. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3044. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3045. labelText.text = "#";
  3046. labelText.color = buttonColor;
  3047. labelText.fontSize = buttonFontSize;
  3048. hexValueQuadrant.addControl(labelText, 0, 0);
  3049. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3050. hexVal.width = 0.96;
  3051. hexVal.height = 0.72;
  3052. hexVal.name = "hexField";
  3053. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3054. hexVal.fontSize = buttonFontSize;
  3055. var minusPound = options.lastColor.split("#");
  3056. hexVal.text = minusPound[1];
  3057. hexVal.color = inputTextColor;
  3058. hexVal.background = inputTextBackgroundColor;
  3059. hexVal.onFocusObservable.add(function () {
  3060. activeField = hexVal.name;
  3061. lastVal = hexVal.text;
  3062. editSwatches(false);
  3063. });
  3064. hexVal.onBlurObservable.add(function () {
  3065. if (hexVal.text.length == 3) {
  3066. var val = hexVal.text.split("");
  3067. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3068. }
  3069. if (hexVal.text == "") {
  3070. hexVal.text = "000000";
  3071. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3072. }
  3073. if (activeField == hexVal.name) {
  3074. activeField = "";
  3075. }
  3076. });
  3077. hexVal.onTextChangedObservable.add(function () {
  3078. var newHexValue = hexVal.text;
  3079. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3080. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3081. hexVal.text = lastVal;
  3082. }
  3083. else {
  3084. if (hexVal.text.length < 6) {
  3085. var leadingZero = 6 - hexVal.text.length;
  3086. for (var i = 0; i < leadingZero; i++) {
  3087. newHexValue = "0" + newHexValue;
  3088. }
  3089. }
  3090. if (hexVal.text.length == 3) {
  3091. var val = hexVal.text.split("");
  3092. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3093. }
  3094. newHexValue = "#" + newHexValue;
  3095. if (activeField == hexVal.name) {
  3096. lastVal = hexVal.text;
  3097. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3098. }
  3099. }
  3100. });
  3101. hexValueQuadrant.addControl(hexVal, 0, 1);
  3102. if (options.savedColors && options.savedColors.length > 0) {
  3103. updateSwatches("", butSave);
  3104. }
  3105. });
  3106. };
  3107. ColorPicker._Epsilon = 0.000001;
  3108. return ColorPicker;
  3109. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3110. /***/ }),
  3111. /***/ "./2D/controls/container.ts":
  3112. /*!**********************************!*\
  3113. !*** ./2D/controls/container.ts ***!
  3114. \**********************************/
  3115. /*! exports provided: Container */
  3116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3117. "use strict";
  3118. __webpack_require__.r(__webpack_exports__);
  3119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3121. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3122. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3123. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3124. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3125. /**
  3126. * Root class for 2D containers
  3127. * @see http://doc.babylonjs.com/how_to/gui#containers
  3128. */
  3129. var Container = /** @class */ (function (_super) {
  3130. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3131. /**
  3132. * Creates a new Container
  3133. * @param name defines the name of the container
  3134. */
  3135. function Container(name) {
  3136. var _this = _super.call(this, name) || this;
  3137. _this.name = name;
  3138. /** @hidden */
  3139. _this._children = new Array();
  3140. /** @hidden */
  3141. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3142. /** @hidden */
  3143. _this._background = "";
  3144. /** @hidden */
  3145. _this._adaptWidthToChildren = false;
  3146. /** @hidden */
  3147. _this._adaptHeightToChildren = false;
  3148. /**
  3149. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3150. */
  3151. _this.logLayoutCycleErrors = false;
  3152. /**
  3153. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3154. */
  3155. _this.maxLayoutCycle = 3;
  3156. return _this;
  3157. }
  3158. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3159. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3160. get: function () {
  3161. return this._adaptHeightToChildren;
  3162. },
  3163. set: function (value) {
  3164. if (this._adaptHeightToChildren === value) {
  3165. return;
  3166. }
  3167. this._adaptHeightToChildren = value;
  3168. if (value) {
  3169. this.height = "100%";
  3170. }
  3171. this._markAsDirty();
  3172. },
  3173. enumerable: true,
  3174. configurable: true
  3175. });
  3176. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3177. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3178. get: function () {
  3179. return this._adaptWidthToChildren;
  3180. },
  3181. set: function (value) {
  3182. if (this._adaptWidthToChildren === value) {
  3183. return;
  3184. }
  3185. this._adaptWidthToChildren = value;
  3186. if (value) {
  3187. this.width = "100%";
  3188. }
  3189. this._markAsDirty();
  3190. },
  3191. enumerable: true,
  3192. configurable: true
  3193. });
  3194. Object.defineProperty(Container.prototype, "background", {
  3195. /** Gets or sets background color */
  3196. get: function () {
  3197. return this._background;
  3198. },
  3199. set: function (value) {
  3200. if (this._background === value) {
  3201. return;
  3202. }
  3203. this._background = value;
  3204. this._markAsDirty();
  3205. },
  3206. enumerable: true,
  3207. configurable: true
  3208. });
  3209. Object.defineProperty(Container.prototype, "children", {
  3210. /** Gets the list of children */
  3211. get: function () {
  3212. return this._children;
  3213. },
  3214. enumerable: true,
  3215. configurable: true
  3216. });
  3217. Container.prototype._getTypeName = function () {
  3218. return "Container";
  3219. };
  3220. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3221. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3222. var child = _a[_i];
  3223. child._markMatrixAsDirty();
  3224. }
  3225. };
  3226. /**
  3227. * Gets a child using its name
  3228. * @param name defines the child name to look for
  3229. * @returns the child control if found
  3230. */
  3231. Container.prototype.getChildByName = function (name) {
  3232. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3233. var child = _a[_i];
  3234. if (child.name === name) {
  3235. return child;
  3236. }
  3237. }
  3238. return null;
  3239. };
  3240. /**
  3241. * Gets a child using its type and its name
  3242. * @param name defines the child name to look for
  3243. * @param type defines the child type to look for
  3244. * @returns the child control if found
  3245. */
  3246. Container.prototype.getChildByType = function (name, type) {
  3247. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3248. var child = _a[_i];
  3249. if (child.typeName === type) {
  3250. return child;
  3251. }
  3252. }
  3253. return null;
  3254. };
  3255. /**
  3256. * Search for a specific control in children
  3257. * @param control defines the control to look for
  3258. * @returns true if the control is in child list
  3259. */
  3260. Container.prototype.containsControl = function (control) {
  3261. return this.children.indexOf(control) !== -1;
  3262. };
  3263. /**
  3264. * Adds a new control to the current container
  3265. * @param control defines the control to add
  3266. * @returns the current container
  3267. */
  3268. Container.prototype.addControl = function (control) {
  3269. if (!control) {
  3270. return this;
  3271. }
  3272. var index = this._children.indexOf(control);
  3273. if (index !== -1) {
  3274. return this;
  3275. }
  3276. control._link(this._host);
  3277. control._markAllAsDirty();
  3278. this._reOrderControl(control);
  3279. this._markAsDirty();
  3280. return this;
  3281. };
  3282. /**
  3283. * Removes all controls from the current container
  3284. * @returns the current container
  3285. */
  3286. Container.prototype.clearControls = function () {
  3287. var children = this.children.slice();
  3288. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3289. var child = children_1[_i];
  3290. this.removeControl(child);
  3291. }
  3292. return this;
  3293. };
  3294. /**
  3295. * Removes a control from the current container
  3296. * @param control defines the control to remove
  3297. * @returns the current container
  3298. */
  3299. Container.prototype.removeControl = function (control) {
  3300. var index = this._children.indexOf(control);
  3301. if (index !== -1) {
  3302. this._children.splice(index, 1);
  3303. control.parent = null;
  3304. }
  3305. control.linkWithMesh(null);
  3306. if (this._host) {
  3307. this._host._cleanControlAfterRemoval(control);
  3308. }
  3309. this._markAsDirty();
  3310. return this;
  3311. };
  3312. /** @hidden */
  3313. Container.prototype._reOrderControl = function (control) {
  3314. this.removeControl(control);
  3315. var wasAdded = false;
  3316. for (var index = 0; index < this._children.length; index++) {
  3317. if (this._children[index].zIndex > control.zIndex) {
  3318. this._children.splice(index, 0, control);
  3319. wasAdded = true;
  3320. break;
  3321. }
  3322. }
  3323. if (!wasAdded) {
  3324. this._children.push(control);
  3325. }
  3326. control.parent = this;
  3327. this._markAsDirty();
  3328. };
  3329. /** @hidden */
  3330. Container.prototype._offsetLeft = function (offset) {
  3331. _super.prototype._offsetLeft.call(this, offset);
  3332. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3333. var child = _a[_i];
  3334. child._offsetLeft(offset);
  3335. }
  3336. };
  3337. /** @hidden */
  3338. Container.prototype._offsetTop = function (offset) {
  3339. _super.prototype._offsetTop.call(this, offset);
  3340. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3341. var child = _a[_i];
  3342. child._offsetTop(offset);
  3343. }
  3344. };
  3345. /** @hidden */
  3346. Container.prototype._markAllAsDirty = function () {
  3347. _super.prototype._markAllAsDirty.call(this);
  3348. for (var index = 0; index < this._children.length; index++) {
  3349. this._children[index]._markAllAsDirty();
  3350. }
  3351. };
  3352. /** @hidden */
  3353. Container.prototype._localDraw = function (context) {
  3354. if (this._background) {
  3355. context.save();
  3356. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3357. context.shadowColor = this.shadowColor;
  3358. context.shadowBlur = this.shadowBlur;
  3359. context.shadowOffsetX = this.shadowOffsetX;
  3360. context.shadowOffsetY = this.shadowOffsetY;
  3361. }
  3362. context.fillStyle = this._background;
  3363. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3364. context.restore();
  3365. }
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._link = function (host) {
  3369. _super.prototype._link.call(this, host);
  3370. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3371. var child = _a[_i];
  3372. child._link(host);
  3373. }
  3374. };
  3375. /** @hidden */
  3376. Container.prototype._beforeLayout = function () {
  3377. // Do nothing
  3378. };
  3379. /** @hidden */
  3380. Container.prototype._processMeasures = function (parentMeasure, context) {
  3381. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3382. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3383. this._evaluateClippingState(parentMeasure);
  3384. }
  3385. };
  3386. /** @hidden */
  3387. Container.prototype._layout = function (parentMeasure, context) {
  3388. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3389. return false;
  3390. }
  3391. if (this._isDirty) {
  3392. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3393. }
  3394. var rebuildCount = 0;
  3395. context.save();
  3396. this._applyStates(context);
  3397. this._beforeLayout();
  3398. do {
  3399. var computedWidth = -1;
  3400. var computedHeight = -1;
  3401. this._rebuildLayout = false;
  3402. this._processMeasures(parentMeasure, context);
  3403. if (!this._isClipped) {
  3404. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3405. var child = _a[_i];
  3406. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3407. if (child._layout(this._measureForChildren, context)) {
  3408. if (this.adaptWidthToChildren && child._width.isPixel) {
  3409. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3410. }
  3411. if (this.adaptHeightToChildren && child._height.isPixel) {
  3412. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3413. }
  3414. }
  3415. }
  3416. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3417. if (this.width !== computedWidth + "px") {
  3418. this.width = computedWidth + "px";
  3419. this._rebuildLayout = true;
  3420. }
  3421. }
  3422. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3423. if (this.height !== computedHeight + "px") {
  3424. this.height = computedHeight + "px";
  3425. this._rebuildLayout = true;
  3426. }
  3427. }
  3428. this._postMeasure();
  3429. }
  3430. rebuildCount++;
  3431. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3432. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3433. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3434. }
  3435. context.restore();
  3436. if (this._isDirty) {
  3437. this.invalidateRect();
  3438. this._isDirty = false;
  3439. }
  3440. return true;
  3441. };
  3442. Container.prototype._postMeasure = function () {
  3443. // Do nothing by default
  3444. };
  3445. /** @hidden */
  3446. Container.prototype._draw = function (context, invalidatedRectangle) {
  3447. this._localDraw(context);
  3448. if (this.clipChildren) {
  3449. this._clipForChildren(context);
  3450. }
  3451. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3452. var child = _a[_i];
  3453. // Only redraw parts of the screen that are invalidated
  3454. if (invalidatedRectangle) {
  3455. if (!child._intersectsRect(invalidatedRectangle)) {
  3456. continue;
  3457. }
  3458. }
  3459. child._render(context, invalidatedRectangle);
  3460. }
  3461. };
  3462. /** @hidden */
  3463. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3464. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3465. if (!this.children) {
  3466. return;
  3467. }
  3468. for (var index = 0; index < this.children.length; index++) {
  3469. var item = this.children[index];
  3470. if (!predicate || predicate(item)) {
  3471. results.push(item);
  3472. }
  3473. if (!directDescendantsOnly) {
  3474. item._getDescendants(results, false, predicate);
  3475. }
  3476. }
  3477. };
  3478. /** @hidden */
  3479. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3480. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3481. return false;
  3482. }
  3483. if (!_super.prototype.contains.call(this, x, y)) {
  3484. return false;
  3485. }
  3486. // Checking backwards to pick closest first
  3487. for (var index = this._children.length - 1; index >= 0; index--) {
  3488. var child = this._children[index];
  3489. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3490. if (child.hoverCursor) {
  3491. this._host._changeCursor(child.hoverCursor);
  3492. }
  3493. return true;
  3494. }
  3495. }
  3496. if (!this.isHitTestVisible) {
  3497. return false;
  3498. }
  3499. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3500. };
  3501. /** @hidden */
  3502. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3503. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3504. this._measureForChildren.copyFrom(this._currentMeasure);
  3505. };
  3506. /** Releases associated resources */
  3507. Container.prototype.dispose = function () {
  3508. _super.prototype.dispose.call(this);
  3509. for (var index = this.children.length - 1; index >= 0; index--) {
  3510. this.children[index].dispose();
  3511. }
  3512. };
  3513. return Container;
  3514. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3515. /***/ }),
  3516. /***/ "./2D/controls/control.ts":
  3517. /*!********************************!*\
  3518. !*** ./2D/controls/control.ts ***!
  3519. \********************************/
  3520. /*! exports provided: Control */
  3521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3522. "use strict";
  3523. __webpack_require__.r(__webpack_exports__);
  3524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3525. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3526. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3527. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3528. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3529. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3530. /**
  3531. * Root class used for all 2D controls
  3532. * @see http://doc.babylonjs.com/how_to/gui#controls
  3533. */
  3534. var Control = /** @class */ (function () {
  3535. // Functions
  3536. /**
  3537. * Creates a new control
  3538. * @param name defines the name of the control
  3539. */
  3540. function Control(
  3541. /** defines the name of the control */
  3542. name) {
  3543. this.name = name;
  3544. this._alpha = 1;
  3545. this._alphaSet = false;
  3546. this._zIndex = 0;
  3547. /** @hidden */
  3548. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3549. this._fontFamily = "Arial";
  3550. this._fontStyle = "";
  3551. this._fontWeight = "";
  3552. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3553. /** @hidden */
  3554. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3555. /** @hidden */
  3556. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3557. this._color = "";
  3558. this._style = null;
  3559. /** @hidden */
  3560. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3561. /** @hidden */
  3562. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3563. /** @hidden */
  3564. this._isDirty = true;
  3565. /** @hidden */
  3566. this._wasDirty = false;
  3567. /** @hidden */
  3568. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3569. /** @hidden */
  3570. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3571. /** @hidden */
  3572. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3573. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3574. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3575. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3576. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3577. /** @hidden */
  3578. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. /** @hidden */
  3580. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._scaleX = 1.0;
  3582. this._scaleY = 1.0;
  3583. this._rotation = 0;
  3584. this._transformCenterX = 0.5;
  3585. this._transformCenterY = 0.5;
  3586. /** @hidden */
  3587. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3588. /** @hidden */
  3589. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3590. /** @hidden */
  3591. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3592. this._isMatrixDirty = true;
  3593. this._isVisible = true;
  3594. this._isHighlighted = false;
  3595. this._fontSet = false;
  3596. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._downCount = 0;
  3598. this._enterCount = -1;
  3599. this._doNotRender = false;
  3600. this._downPointerIds = {};
  3601. this._isEnabled = true;
  3602. this._disabledColor = "#9a9a9a";
  3603. /** @hidden */
  3604. this._rebuildLayout = false;
  3605. /** @hidden */
  3606. this._isClipped = false;
  3607. /**
  3608. * Gets or sets an object used to store user defined information for the node
  3609. */
  3610. this.metadata = null;
  3611. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3612. this.isHitTestVisible = true;
  3613. /** Gets or sets a boolean indicating if the control can block pointer events */
  3614. this.isPointerBlocker = false;
  3615. /** Gets or sets a boolean indicating if the control can be focusable */
  3616. this.isFocusInvisible = false;
  3617. /**
  3618. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3619. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3620. */
  3621. this.clipChildren = true;
  3622. /**
  3623. * Gets or sets a boolean indicating that control content must be clipped
  3624. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3625. */
  3626. this.clipContent = true;
  3627. /**
  3628. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3629. */
  3630. this.useBitmapCache = false;
  3631. this._shadowOffsetX = 0;
  3632. this._shadowOffsetY = 0;
  3633. this._shadowBlur = 0;
  3634. this._shadowColor = 'black';
  3635. /** Gets or sets the cursor to use when the control is hovered */
  3636. this.hoverCursor = "";
  3637. /** @hidden */
  3638. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3639. /** @hidden */
  3640. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3641. /**
  3642. * An event triggered when the pointer move over the control.
  3643. */
  3644. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3645. /**
  3646. * An event triggered when the pointer move out of the control.
  3647. */
  3648. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3649. /**
  3650. * An event triggered when the pointer taps the control
  3651. */
  3652. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3653. /**
  3654. * An event triggered when pointer up
  3655. */
  3656. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3657. /**
  3658. * An event triggered when a control is clicked on
  3659. */
  3660. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3661. /**
  3662. * An event triggered when pointer enters the control
  3663. */
  3664. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3665. /**
  3666. * An event triggered when the control is marked as dirty
  3667. */
  3668. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3669. /**
  3670. * An event triggered before drawing the control
  3671. */
  3672. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3673. /**
  3674. * An event triggered after the control was drawn
  3675. */
  3676. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3677. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3678. }
  3679. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3680. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3681. get: function () {
  3682. return this._shadowOffsetX;
  3683. },
  3684. set: function (value) {
  3685. if (this._shadowOffsetX === value) {
  3686. return;
  3687. }
  3688. this._shadowOffsetX = value;
  3689. this._markAsDirty();
  3690. },
  3691. enumerable: true,
  3692. configurable: true
  3693. });
  3694. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3695. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3696. get: function () {
  3697. return this._shadowOffsetY;
  3698. },
  3699. set: function (value) {
  3700. if (this._shadowOffsetY === value) {
  3701. return;
  3702. }
  3703. this._shadowOffsetY = value;
  3704. this._markAsDirty();
  3705. },
  3706. enumerable: true,
  3707. configurable: true
  3708. });
  3709. Object.defineProperty(Control.prototype, "shadowBlur", {
  3710. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3711. get: function () {
  3712. return this._shadowBlur;
  3713. },
  3714. set: function (value) {
  3715. if (this._shadowBlur === value) {
  3716. return;
  3717. }
  3718. this._shadowBlur = value;
  3719. this._markAsDirty();
  3720. },
  3721. enumerable: true,
  3722. configurable: true
  3723. });
  3724. Object.defineProperty(Control.prototype, "shadowColor", {
  3725. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3726. get: function () {
  3727. return this._shadowColor;
  3728. },
  3729. set: function (value) {
  3730. if (this._shadowColor === value) {
  3731. return;
  3732. }
  3733. this._shadowColor = value;
  3734. this._markAsDirty();
  3735. },
  3736. enumerable: true,
  3737. configurable: true
  3738. });
  3739. Object.defineProperty(Control.prototype, "typeName", {
  3740. // Properties
  3741. /** Gets the control type name */
  3742. get: function () {
  3743. return this._getTypeName();
  3744. },
  3745. enumerable: true,
  3746. configurable: true
  3747. });
  3748. /**
  3749. * Get the current class name of the control.
  3750. * @returns current class name
  3751. */
  3752. Control.prototype.getClassName = function () {
  3753. return this._getTypeName();
  3754. };
  3755. Object.defineProperty(Control.prototype, "host", {
  3756. /**
  3757. * Get the hosting AdvancedDynamicTexture
  3758. */
  3759. get: function () {
  3760. return this._host;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Control.prototype, "fontOffset", {
  3766. /** Gets or set information about font offsets (used to render and align text) */
  3767. get: function () {
  3768. return this._fontOffset;
  3769. },
  3770. set: function (offset) {
  3771. this._fontOffset = offset;
  3772. },
  3773. enumerable: true,
  3774. configurable: true
  3775. });
  3776. Object.defineProperty(Control.prototype, "alpha", {
  3777. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3778. get: function () {
  3779. return this._alpha;
  3780. },
  3781. set: function (value) {
  3782. if (this._alpha === value) {
  3783. return;
  3784. }
  3785. this._alphaSet = true;
  3786. this._alpha = value;
  3787. this._markAsDirty();
  3788. },
  3789. enumerable: true,
  3790. configurable: true
  3791. });
  3792. Object.defineProperty(Control.prototype, "isHighlighted", {
  3793. /**
  3794. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3795. */
  3796. get: function () {
  3797. return this._isHighlighted;
  3798. },
  3799. set: function (value) {
  3800. if (this._isHighlighted === value) {
  3801. return;
  3802. }
  3803. this._isHighlighted = value;
  3804. this._markAsDirty();
  3805. },
  3806. enumerable: true,
  3807. configurable: true
  3808. });
  3809. Object.defineProperty(Control.prototype, "scaleX", {
  3810. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3811. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3812. */
  3813. get: function () {
  3814. return this._scaleX;
  3815. },
  3816. set: function (value) {
  3817. if (this._scaleX === value) {
  3818. return;
  3819. }
  3820. this._scaleX = value;
  3821. this._markAsDirty();
  3822. this._markMatrixAsDirty();
  3823. },
  3824. enumerable: true,
  3825. configurable: true
  3826. });
  3827. Object.defineProperty(Control.prototype, "scaleY", {
  3828. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3829. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3830. */
  3831. get: function () {
  3832. return this._scaleY;
  3833. },
  3834. set: function (value) {
  3835. if (this._scaleY === value) {
  3836. return;
  3837. }
  3838. this._scaleY = value;
  3839. this._markAsDirty();
  3840. this._markMatrixAsDirty();
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. Object.defineProperty(Control.prototype, "rotation", {
  3846. /** Gets or sets the rotation angle (0 by default)
  3847. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3848. */
  3849. get: function () {
  3850. return this._rotation;
  3851. },
  3852. set: function (value) {
  3853. if (this._rotation === value) {
  3854. return;
  3855. }
  3856. this._rotation = value;
  3857. this._markAsDirty();
  3858. this._markMatrixAsDirty();
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(Control.prototype, "transformCenterY", {
  3864. /** Gets or sets the transformation center on Y axis (0 by default)
  3865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3866. */
  3867. get: function () {
  3868. return this._transformCenterY;
  3869. },
  3870. set: function (value) {
  3871. if (this._transformCenterY === value) {
  3872. return;
  3873. }
  3874. this._transformCenterY = value;
  3875. this._markAsDirty();
  3876. this._markMatrixAsDirty();
  3877. },
  3878. enumerable: true,
  3879. configurable: true
  3880. });
  3881. Object.defineProperty(Control.prototype, "transformCenterX", {
  3882. /** Gets or sets the transformation center on X axis (0 by default)
  3883. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3884. */
  3885. get: function () {
  3886. return this._transformCenterX;
  3887. },
  3888. set: function (value) {
  3889. if (this._transformCenterX === value) {
  3890. return;
  3891. }
  3892. this._transformCenterX = value;
  3893. this._markAsDirty();
  3894. this._markMatrixAsDirty();
  3895. },
  3896. enumerable: true,
  3897. configurable: true
  3898. });
  3899. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3900. /**
  3901. * Gets or sets the horizontal alignment
  3902. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3903. */
  3904. get: function () {
  3905. return this._horizontalAlignment;
  3906. },
  3907. set: function (value) {
  3908. if (this._horizontalAlignment === value) {
  3909. return;
  3910. }
  3911. this._horizontalAlignment = value;
  3912. this._markAsDirty();
  3913. },
  3914. enumerable: true,
  3915. configurable: true
  3916. });
  3917. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3918. /**
  3919. * Gets or sets the vertical alignment
  3920. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3921. */
  3922. get: function () {
  3923. return this._verticalAlignment;
  3924. },
  3925. set: function (value) {
  3926. if (this._verticalAlignment === value) {
  3927. return;
  3928. }
  3929. this._verticalAlignment = value;
  3930. this._markAsDirty();
  3931. },
  3932. enumerable: true,
  3933. configurable: true
  3934. });
  3935. Object.defineProperty(Control.prototype, "width", {
  3936. /**
  3937. * Gets or sets control width
  3938. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3939. */
  3940. get: function () {
  3941. return this._width.toString(this._host);
  3942. },
  3943. set: function (value) {
  3944. if (this._width.toString(this._host) === value) {
  3945. return;
  3946. }
  3947. if (this._width.fromString(value)) {
  3948. this._markAsDirty();
  3949. }
  3950. },
  3951. enumerable: true,
  3952. configurable: true
  3953. });
  3954. Object.defineProperty(Control.prototype, "widthInPixels", {
  3955. /**
  3956. * Gets or sets the control width in pixel
  3957. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3958. */
  3959. get: function () {
  3960. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3961. },
  3962. set: function (value) {
  3963. if (isNaN(value)) {
  3964. return;
  3965. }
  3966. this.width = value + "px";
  3967. },
  3968. enumerable: true,
  3969. configurable: true
  3970. });
  3971. Object.defineProperty(Control.prototype, "height", {
  3972. /**
  3973. * Gets or sets control height
  3974. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3975. */
  3976. get: function () {
  3977. return this._height.toString(this._host);
  3978. },
  3979. set: function (value) {
  3980. if (this._height.toString(this._host) === value) {
  3981. return;
  3982. }
  3983. if (this._height.fromString(value)) {
  3984. this._markAsDirty();
  3985. }
  3986. },
  3987. enumerable: true,
  3988. configurable: true
  3989. });
  3990. Object.defineProperty(Control.prototype, "heightInPixels", {
  3991. /**
  3992. * Gets or sets control height in pixel
  3993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3994. */
  3995. get: function () {
  3996. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3997. },
  3998. set: function (value) {
  3999. if (isNaN(value)) {
  4000. return;
  4001. }
  4002. this.height = value + "px";
  4003. },
  4004. enumerable: true,
  4005. configurable: true
  4006. });
  4007. Object.defineProperty(Control.prototype, "fontFamily", {
  4008. /** Gets or set font family */
  4009. get: function () {
  4010. if (!this._fontSet) {
  4011. return "";
  4012. }
  4013. return this._fontFamily;
  4014. },
  4015. set: function (value) {
  4016. if (this._fontFamily === value) {
  4017. return;
  4018. }
  4019. this._fontFamily = value;
  4020. this._resetFontCache();
  4021. },
  4022. enumerable: true,
  4023. configurable: true
  4024. });
  4025. Object.defineProperty(Control.prototype, "fontStyle", {
  4026. /** Gets or sets font style */
  4027. get: function () {
  4028. return this._fontStyle;
  4029. },
  4030. set: function (value) {
  4031. if (this._fontStyle === value) {
  4032. return;
  4033. }
  4034. this._fontStyle = value;
  4035. this._resetFontCache();
  4036. },
  4037. enumerable: true,
  4038. configurable: true
  4039. });
  4040. Object.defineProperty(Control.prototype, "fontWeight", {
  4041. /** Gets or sets font weight */
  4042. get: function () {
  4043. return this._fontWeight;
  4044. },
  4045. set: function (value) {
  4046. if (this._fontWeight === value) {
  4047. return;
  4048. }
  4049. this._fontWeight = value;
  4050. this._resetFontCache();
  4051. },
  4052. enumerable: true,
  4053. configurable: true
  4054. });
  4055. Object.defineProperty(Control.prototype, "style", {
  4056. /**
  4057. * Gets or sets style
  4058. * @see http://doc.babylonjs.com/how_to/gui#styles
  4059. */
  4060. get: function () {
  4061. return this._style;
  4062. },
  4063. set: function (value) {
  4064. var _this = this;
  4065. if (this._style) {
  4066. this._style.onChangedObservable.remove(this._styleObserver);
  4067. this._styleObserver = null;
  4068. }
  4069. this._style = value;
  4070. if (this._style) {
  4071. this._styleObserver = this._style.onChangedObservable.add(function () {
  4072. _this._markAsDirty();
  4073. _this._resetFontCache();
  4074. });
  4075. }
  4076. this._markAsDirty();
  4077. this._resetFontCache();
  4078. },
  4079. enumerable: true,
  4080. configurable: true
  4081. });
  4082. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4083. /** @hidden */
  4084. get: function () {
  4085. return this._fontSize.isPercentage;
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4091. /** Gets or sets font size in pixels */
  4092. get: function () {
  4093. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4094. if (fontSizeToUse.isPixel) {
  4095. return fontSizeToUse.getValue(this._host);
  4096. }
  4097. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4098. },
  4099. set: function (value) {
  4100. if (isNaN(value)) {
  4101. return;
  4102. }
  4103. this.fontSize = value + "px";
  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 or sets 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. set: function (value) {
  4230. if (isNaN(value)) {
  4231. return;
  4232. }
  4233. this.paddingLeft = value + "px";
  4234. },
  4235. enumerable: true,
  4236. configurable: true
  4237. });
  4238. Object.defineProperty(Control.prototype, "paddingRight", {
  4239. /**
  4240. * Gets or sets a value indicating the padding to use on the right of the control
  4241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4242. */
  4243. get: function () {
  4244. return this._paddingRight.toString(this._host);
  4245. },
  4246. set: function (value) {
  4247. if (this._paddingRight.fromString(value)) {
  4248. this._markAsDirty();
  4249. }
  4250. },
  4251. enumerable: true,
  4252. configurable: true
  4253. });
  4254. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4255. /**
  4256. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4257. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4258. */
  4259. get: function () {
  4260. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4261. },
  4262. set: function (value) {
  4263. if (isNaN(value)) {
  4264. return;
  4265. }
  4266. this.paddingRight = value + "px";
  4267. },
  4268. enumerable: true,
  4269. configurable: true
  4270. });
  4271. Object.defineProperty(Control.prototype, "paddingTop", {
  4272. /**
  4273. * Gets or sets a value indicating the padding to use on the top of the control
  4274. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4275. */
  4276. get: function () {
  4277. return this._paddingTop.toString(this._host);
  4278. },
  4279. set: function (value) {
  4280. if (this._paddingTop.fromString(value)) {
  4281. this._markAsDirty();
  4282. }
  4283. },
  4284. enumerable: true,
  4285. configurable: true
  4286. });
  4287. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4288. /**
  4289. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4291. */
  4292. get: function () {
  4293. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4294. },
  4295. set: function (value) {
  4296. if (isNaN(value)) {
  4297. return;
  4298. }
  4299. this.paddingTop = value + "px";
  4300. },
  4301. enumerable: true,
  4302. configurable: true
  4303. });
  4304. Object.defineProperty(Control.prototype, "paddingBottom", {
  4305. /**
  4306. * Gets or sets a value indicating the padding to use on the bottom of the control
  4307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4308. */
  4309. get: function () {
  4310. return this._paddingBottom.toString(this._host);
  4311. },
  4312. set: function (value) {
  4313. if (this._paddingBottom.fromString(value)) {
  4314. this._markAsDirty();
  4315. }
  4316. },
  4317. enumerable: true,
  4318. configurable: true
  4319. });
  4320. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4321. /**
  4322. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4323. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4324. */
  4325. get: function () {
  4326. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4327. },
  4328. set: function (value) {
  4329. if (isNaN(value)) {
  4330. return;
  4331. }
  4332. this.paddingBottom = value + "px";
  4333. },
  4334. enumerable: true,
  4335. configurable: true
  4336. });
  4337. Object.defineProperty(Control.prototype, "left", {
  4338. /**
  4339. * Gets or sets a value indicating the left coordinate of the control
  4340. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4341. */
  4342. get: function () {
  4343. return this._left.toString(this._host);
  4344. },
  4345. set: function (value) {
  4346. if (this._left.fromString(value)) {
  4347. this._markAsDirty();
  4348. }
  4349. },
  4350. enumerable: true,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "leftInPixels", {
  4354. /**
  4355. * Gets or sets a value indicating the left coordinate in pixels of the control
  4356. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4357. */
  4358. get: function () {
  4359. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4360. },
  4361. set: function (value) {
  4362. if (isNaN(value)) {
  4363. return;
  4364. }
  4365. this.left = value + "px";
  4366. },
  4367. enumerable: true,
  4368. configurable: true
  4369. });
  4370. Object.defineProperty(Control.prototype, "top", {
  4371. /**
  4372. * Gets or sets a value indicating the top coordinate of the control
  4373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4374. */
  4375. get: function () {
  4376. return this._top.toString(this._host);
  4377. },
  4378. set: function (value) {
  4379. if (this._top.fromString(value)) {
  4380. this._markAsDirty();
  4381. }
  4382. },
  4383. enumerable: true,
  4384. configurable: true
  4385. });
  4386. Object.defineProperty(Control.prototype, "topInPixels", {
  4387. /**
  4388. * Gets or sets a value indicating the top coordinate in pixels of the control
  4389. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4390. */
  4391. get: function () {
  4392. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4393. },
  4394. set: function (value) {
  4395. if (isNaN(value)) {
  4396. return;
  4397. }
  4398. this.top = value + "px";
  4399. },
  4400. enumerable: true,
  4401. configurable: true
  4402. });
  4403. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4404. /**
  4405. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4406. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4407. */
  4408. get: function () {
  4409. return this._linkOffsetX.toString(this._host);
  4410. },
  4411. set: function (value) {
  4412. if (this._linkOffsetX.fromString(value)) {
  4413. this._markAsDirty();
  4414. }
  4415. },
  4416. enumerable: true,
  4417. configurable: true
  4418. });
  4419. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4420. /**
  4421. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4422. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4423. */
  4424. get: function () {
  4425. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4426. },
  4427. set: function (value) {
  4428. if (isNaN(value)) {
  4429. return;
  4430. }
  4431. this.linkOffsetX = value + "px";
  4432. },
  4433. enumerable: true,
  4434. configurable: true
  4435. });
  4436. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4437. /**
  4438. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4439. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4440. */
  4441. get: function () {
  4442. return this._linkOffsetY.toString(this._host);
  4443. },
  4444. set: function (value) {
  4445. if (this._linkOffsetY.fromString(value)) {
  4446. this._markAsDirty();
  4447. }
  4448. },
  4449. enumerable: true,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4453. /**
  4454. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4455. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4456. */
  4457. get: function () {
  4458. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4459. },
  4460. set: function (value) {
  4461. if (isNaN(value)) {
  4462. return;
  4463. }
  4464. this.linkOffsetY = value + "px";
  4465. },
  4466. enumerable: true,
  4467. configurable: true
  4468. });
  4469. Object.defineProperty(Control.prototype, "centerX", {
  4470. /** Gets the center coordinate on X axis */
  4471. get: function () {
  4472. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4473. },
  4474. enumerable: true,
  4475. configurable: true
  4476. });
  4477. Object.defineProperty(Control.prototype, "centerY", {
  4478. /** Gets the center coordinate on Y axis */
  4479. get: function () {
  4480. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4481. },
  4482. enumerable: true,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "isEnabled", {
  4486. /** Gets or sets if control is Enabled*/
  4487. get: function () {
  4488. return this._isEnabled;
  4489. },
  4490. set: function (value) {
  4491. if (this._isEnabled === value) {
  4492. return;
  4493. }
  4494. this._isEnabled = value;
  4495. this._markAsDirty();
  4496. },
  4497. enumerable: true,
  4498. configurable: true
  4499. });
  4500. Object.defineProperty(Control.prototype, "disabledColor", {
  4501. /** Gets or sets background color of control if it's disabled*/
  4502. get: function () {
  4503. return this._disabledColor;
  4504. },
  4505. set: function (value) {
  4506. if (this._disabledColor === value) {
  4507. return;
  4508. }
  4509. this._disabledColor = value;
  4510. this._markAsDirty();
  4511. },
  4512. enumerable: true,
  4513. configurable: true
  4514. });
  4515. /** @hidden */
  4516. Control.prototype._getTypeName = function () {
  4517. return "Control";
  4518. };
  4519. /**
  4520. * Gets the first ascendant in the hierarchy of the given type
  4521. * @param className defines the required type
  4522. * @returns the ascendant or null if not found
  4523. */
  4524. Control.prototype.getAscendantOfClass = function (className) {
  4525. if (!this.parent) {
  4526. return null;
  4527. }
  4528. if (this.parent.getClassName() === className) {
  4529. return this.parent;
  4530. }
  4531. return this.parent.getAscendantOfClass(className);
  4532. };
  4533. /** @hidden */
  4534. Control.prototype._resetFontCache = function () {
  4535. this._fontSet = true;
  4536. this._markAsDirty();
  4537. };
  4538. /**
  4539. * Determines if a container is an ascendant of the current control
  4540. * @param container defines the container to look for
  4541. * @returns true if the container is one of the ascendant of the control
  4542. */
  4543. Control.prototype.isAscendant = function (container) {
  4544. if (!this.parent) {
  4545. return false;
  4546. }
  4547. if (this.parent === container) {
  4548. return true;
  4549. }
  4550. return this.parent.isAscendant(container);
  4551. };
  4552. /**
  4553. * Gets coordinates in local control space
  4554. * @param globalCoordinates defines the coordinates to transform
  4555. * @returns the new coordinates in local space
  4556. */
  4557. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4558. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4559. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4560. return result;
  4561. };
  4562. /**
  4563. * Gets coordinates in local control space
  4564. * @param globalCoordinates defines the coordinates to transform
  4565. * @param result defines the target vector2 where to store the result
  4566. * @returns the current control
  4567. */
  4568. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4569. result.x = globalCoordinates.x - this._currentMeasure.left;
  4570. result.y = globalCoordinates.y - this._currentMeasure.top;
  4571. return this;
  4572. };
  4573. /**
  4574. * Gets coordinates in parent local control space
  4575. * @param globalCoordinates defines the coordinates to transform
  4576. * @returns the new coordinates in parent local space
  4577. */
  4578. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4579. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4580. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4581. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4582. return result;
  4583. };
  4584. /**
  4585. * Move the current control to a vector3 position projected onto the screen.
  4586. * @param position defines the target position
  4587. * @param scene defines the hosting scene
  4588. */
  4589. Control.prototype.moveToVector3 = function (position, scene) {
  4590. if (!this._host || this.parent !== this._host._rootContainer) {
  4591. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4592. return;
  4593. }
  4594. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4595. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4596. var globalViewport = this._host._getGlobalViewport(scene);
  4597. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4598. this._moveToProjectedPosition(projectedPosition);
  4599. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4600. this.notRenderable = true;
  4601. return;
  4602. }
  4603. this.notRenderable = false;
  4604. };
  4605. /** @hidden */
  4606. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4607. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4608. // Do nothing by default
  4609. };
  4610. /**
  4611. * Will return all controls that have this control as ascendant
  4612. * @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
  4613. * @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
  4614. * @return all child controls
  4615. */
  4616. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4617. var results = new Array();
  4618. this._getDescendants(results, directDescendantsOnly, predicate);
  4619. return results;
  4620. };
  4621. /**
  4622. * Link current control with a target mesh
  4623. * @param mesh defines the mesh to link with
  4624. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4625. */
  4626. Control.prototype.linkWithMesh = function (mesh) {
  4627. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4628. if (mesh) {
  4629. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4630. }
  4631. return;
  4632. }
  4633. var index = this._host._linkedControls.indexOf(this);
  4634. if (index !== -1) {
  4635. this._linkedMesh = mesh;
  4636. if (!mesh) {
  4637. this._host._linkedControls.splice(index, 1);
  4638. }
  4639. return;
  4640. }
  4641. else if (!mesh) {
  4642. return;
  4643. }
  4644. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4645. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4646. this._linkedMesh = mesh;
  4647. this._host._linkedControls.push(this);
  4648. };
  4649. /** @hidden */
  4650. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4651. var oldLeft = this._left.getValue(this._host);
  4652. var oldTop = this._top.getValue(this._host);
  4653. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4654. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4655. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4656. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4657. newLeft = oldLeft;
  4658. }
  4659. if (Math.abs(newTop - oldTop) < 0.5) {
  4660. newTop = oldTop;
  4661. }
  4662. }
  4663. this.left = newLeft + "px";
  4664. this.top = newTop + "px";
  4665. this._left.ignoreAdaptiveScaling = true;
  4666. this._top.ignoreAdaptiveScaling = true;
  4667. this._markAsDirty();
  4668. };
  4669. /** @hidden */
  4670. Control.prototype._offsetLeft = function (offset) {
  4671. this._isDirty = true;
  4672. this._currentMeasure.left += offset;
  4673. };
  4674. /** @hidden */
  4675. Control.prototype._offsetTop = function (offset) {
  4676. this._isDirty = true;
  4677. this._currentMeasure.top += offset;
  4678. };
  4679. /** @hidden */
  4680. Control.prototype._markMatrixAsDirty = function () {
  4681. this._isMatrixDirty = true;
  4682. this._flagDescendantsAsMatrixDirty();
  4683. };
  4684. /** @hidden */
  4685. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4686. // No child
  4687. };
  4688. /** @hidden */
  4689. Control.prototype._intersectsRect = function (rect) {
  4690. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4691. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4692. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4693. return false;
  4694. }
  4695. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4696. return false;
  4697. }
  4698. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4699. return false;
  4700. }
  4701. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4702. return false;
  4703. }
  4704. return true;
  4705. };
  4706. /** @hidden */
  4707. Control.prototype.invalidateRect = function () {
  4708. this._transform();
  4709. if (this.host && this.host.useInvalidateRectOptimization) {
  4710. // Rotate by transform to get the measure transformed to global space
  4711. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4712. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4713. // the previous measure is used to properly clear a control that is scaled down
  4714. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4715. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4716. // Expand rect based on shadows
  4717. var shadowOffsetX = this.shadowOffsetX;
  4718. var shadowOffsetY = this.shadowOffsetY;
  4719. var shadowBlur = this.shadowBlur;
  4720. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4721. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4722. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4723. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4724. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4725. }
  4726. else {
  4727. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4728. }
  4729. }
  4730. };
  4731. /** @hidden */
  4732. Control.prototype._markAsDirty = function (force) {
  4733. if (force === void 0) { force = false; }
  4734. if (!this._isVisible && !force) {
  4735. return;
  4736. }
  4737. this._isDirty = true;
  4738. // Redraw only this rectangle
  4739. if (this._host) {
  4740. this._host.markAsDirty();
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAllAsDirty = function () {
  4745. this._markAsDirty();
  4746. if (this._font) {
  4747. this._prepareFont();
  4748. }
  4749. };
  4750. /** @hidden */
  4751. Control.prototype._link = function (host) {
  4752. this._host = host;
  4753. if (this._host) {
  4754. this.uniqueId = this._host.getScene().getUniqueId();
  4755. }
  4756. };
  4757. /** @hidden */
  4758. Control.prototype._transform = function (context) {
  4759. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4760. return;
  4761. }
  4762. // postTranslate
  4763. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4764. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4765. if (context) {
  4766. context.translate(offsetX, offsetY);
  4767. // rotate
  4768. context.rotate(this._rotation);
  4769. // scale
  4770. context.scale(this._scaleX, this._scaleY);
  4771. // preTranslate
  4772. context.translate(-offsetX, -offsetY);
  4773. }
  4774. // Need to update matrices?
  4775. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4776. this._cachedOffsetX = offsetX;
  4777. this._cachedOffsetY = offsetY;
  4778. this._isMatrixDirty = false;
  4779. this._flagDescendantsAsMatrixDirty();
  4780. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4781. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4782. }
  4783. };
  4784. /** @hidden */
  4785. Control.prototype._renderHighlight = function (context) {
  4786. if (!this.isHighlighted) {
  4787. return;
  4788. }
  4789. context.save();
  4790. context.strokeStyle = "#4affff";
  4791. context.lineWidth = 2;
  4792. this._renderHighlightSpecific(context);
  4793. context.restore();
  4794. };
  4795. /** @hidden */
  4796. Control.prototype._renderHighlightSpecific = function (context) {
  4797. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4798. };
  4799. /** @hidden */
  4800. Control.prototype._applyStates = function (context) {
  4801. if (this._isFontSizeInPercentage) {
  4802. this._fontSet = true;
  4803. }
  4804. if (this._fontSet) {
  4805. this._prepareFont();
  4806. this._fontSet = false;
  4807. }
  4808. if (this._font) {
  4809. context.font = this._font;
  4810. }
  4811. if (this._color) {
  4812. context.fillStyle = this._color;
  4813. }
  4814. if (Control.AllowAlphaInheritance) {
  4815. context.globalAlpha *= this._alpha;
  4816. }
  4817. else if (this._alphaSet) {
  4818. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4819. }
  4820. };
  4821. /** @hidden */
  4822. Control.prototype._layout = function (parentMeasure, context) {
  4823. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4824. return false;
  4825. }
  4826. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4827. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4828. context.save();
  4829. this._applyStates(context);
  4830. var rebuildCount = 0;
  4831. do {
  4832. this._rebuildLayout = false;
  4833. this._processMeasures(parentMeasure, context);
  4834. rebuildCount++;
  4835. } while (this._rebuildLayout && rebuildCount < 3);
  4836. if (rebuildCount >= 3) {
  4837. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4838. }
  4839. context.restore();
  4840. this.invalidateRect();
  4841. this._evaluateClippingState(parentMeasure);
  4842. }
  4843. this._wasDirty = this._isDirty;
  4844. this._isDirty = false;
  4845. return true;
  4846. };
  4847. /** @hidden */
  4848. Control.prototype._processMeasures = function (parentMeasure, context) {
  4849. this._currentMeasure.copyFrom(parentMeasure);
  4850. // Let children take some pre-measurement actions
  4851. this._preMeasure(parentMeasure, context);
  4852. this._measure();
  4853. this._computeAlignment(parentMeasure, context);
  4854. // Convert to int values
  4855. this._currentMeasure.left = this._currentMeasure.left | 0;
  4856. this._currentMeasure.top = this._currentMeasure.top | 0;
  4857. this._currentMeasure.width = this._currentMeasure.width | 0;
  4858. this._currentMeasure.height = this._currentMeasure.height | 0;
  4859. // Let children add more features
  4860. this._additionalProcessing(parentMeasure, context);
  4861. this._cachedParentMeasure.copyFrom(parentMeasure);
  4862. if (this.onDirtyObservable.hasObservers()) {
  4863. this.onDirtyObservable.notifyObservers(this);
  4864. }
  4865. };
  4866. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4867. if (this.parent && this.parent.clipChildren) {
  4868. // Early clip
  4869. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4870. this._isClipped = true;
  4871. return;
  4872. }
  4873. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4874. this._isClipped = true;
  4875. return;
  4876. }
  4877. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4878. this._isClipped = true;
  4879. return;
  4880. }
  4881. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. }
  4886. this._isClipped = false;
  4887. };
  4888. /** @hidden */
  4889. Control.prototype._measure = function () {
  4890. // Width / Height
  4891. if (this._width.isPixel) {
  4892. this._currentMeasure.width = this._width.getValue(this._host);
  4893. }
  4894. else {
  4895. this._currentMeasure.width *= this._width.getValue(this._host);
  4896. }
  4897. if (this._height.isPixel) {
  4898. this._currentMeasure.height = this._height.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.height *= this._height.getValue(this._host);
  4902. }
  4903. };
  4904. /** @hidden */
  4905. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4906. var width = this._currentMeasure.width;
  4907. var height = this._currentMeasure.height;
  4908. var parentWidth = parentMeasure.width;
  4909. var parentHeight = parentMeasure.height;
  4910. // Left / top
  4911. var x = 0;
  4912. var y = 0;
  4913. switch (this.horizontalAlignment) {
  4914. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4915. x = 0;
  4916. break;
  4917. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4918. x = parentWidth - width;
  4919. break;
  4920. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4921. x = (parentWidth - width) / 2;
  4922. break;
  4923. }
  4924. switch (this.verticalAlignment) {
  4925. case Control.VERTICAL_ALIGNMENT_TOP:
  4926. y = 0;
  4927. break;
  4928. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4929. y = parentHeight - height;
  4930. break;
  4931. case Control.VERTICAL_ALIGNMENT_CENTER:
  4932. y = (parentHeight - height) / 2;
  4933. break;
  4934. }
  4935. if (this._paddingLeft.isPixel) {
  4936. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4937. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4938. }
  4939. else {
  4940. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4941. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4942. }
  4943. if (this._paddingRight.isPixel) {
  4944. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4945. }
  4946. else {
  4947. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4948. }
  4949. if (this._paddingTop.isPixel) {
  4950. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4951. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4952. }
  4953. else {
  4954. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4955. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4956. }
  4957. if (this._paddingBottom.isPixel) {
  4958. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4959. }
  4960. else {
  4961. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4962. }
  4963. if (this._left.isPixel) {
  4964. this._currentMeasure.left += this._left.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4968. }
  4969. if (this._top.isPixel) {
  4970. this._currentMeasure.top += this._top.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4974. }
  4975. this._currentMeasure.left += x;
  4976. this._currentMeasure.top += y;
  4977. };
  4978. /** @hidden */
  4979. Control.prototype._preMeasure = function (parentMeasure, context) {
  4980. // Do nothing
  4981. };
  4982. /** @hidden */
  4983. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4984. // Do nothing
  4985. };
  4986. /** @hidden */
  4987. Control.prototype._clipForChildren = function (context) {
  4988. // DO nothing
  4989. };
  4990. Control.prototype._clip = function (context, invalidatedRectangle) {
  4991. context.beginPath();
  4992. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4993. if (invalidatedRectangle) {
  4994. // Rotate the invalidated rect into the control's space
  4995. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4996. // Get the intersection of the rect in context space and the current context
  4997. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4998. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4999. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5000. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5001. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5002. Control._ClipMeasure.copyFrom(intersection);
  5003. }
  5004. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5005. var shadowOffsetX = this.shadowOffsetX;
  5006. var shadowOffsetY = this.shadowOffsetY;
  5007. var shadowBlur = this.shadowBlur;
  5008. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5009. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5010. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5011. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5012. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5013. }
  5014. else {
  5015. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5016. }
  5017. context.clip();
  5018. };
  5019. /** @hidden */
  5020. Control.prototype._render = function (context, invalidatedRectangle) {
  5021. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5022. this._isDirty = false;
  5023. return false;
  5024. }
  5025. context.save();
  5026. this._applyStates(context);
  5027. // Transform
  5028. this._transform(context);
  5029. // Clip
  5030. if (this.clipContent) {
  5031. this._clip(context, invalidatedRectangle);
  5032. }
  5033. if (this.onBeforeDrawObservable.hasObservers()) {
  5034. this.onBeforeDrawObservable.notifyObservers(this);
  5035. }
  5036. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5037. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5038. }
  5039. else {
  5040. this._draw(context, invalidatedRectangle);
  5041. }
  5042. if (this.useBitmapCache && this._wasDirty) {
  5043. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5044. }
  5045. this._renderHighlight(context);
  5046. if (this.onAfterDrawObservable.hasObservers()) {
  5047. this.onAfterDrawObservable.notifyObservers(this);
  5048. }
  5049. context.restore();
  5050. return true;
  5051. };
  5052. /** @hidden */
  5053. Control.prototype._draw = function (context, invalidatedRectangle) {
  5054. // Do nothing
  5055. };
  5056. /**
  5057. * Tests if a given coordinates belong to the current control
  5058. * @param x defines x coordinate to test
  5059. * @param y defines y coordinate to test
  5060. * @returns true if the coordinates are inside the control
  5061. */
  5062. Control.prototype.contains = function (x, y) {
  5063. // Invert transform
  5064. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5065. x = this._transformedPosition.x;
  5066. y = this._transformedPosition.y;
  5067. // Check
  5068. if (x < this._currentMeasure.left) {
  5069. return false;
  5070. }
  5071. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5072. return false;
  5073. }
  5074. if (y < this._currentMeasure.top) {
  5075. return false;
  5076. }
  5077. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5078. return false;
  5079. }
  5080. if (this.isPointerBlocker) {
  5081. this._host._shouldBlockPointer = true;
  5082. }
  5083. return true;
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5087. if (!this._isEnabled) {
  5088. return false;
  5089. }
  5090. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5091. return false;
  5092. }
  5093. if (!this.contains(x, y)) {
  5094. return false;
  5095. }
  5096. this._processObservables(type, x, y, pointerId, buttonIndex);
  5097. return true;
  5098. };
  5099. /** @hidden */
  5100. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5101. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5102. if (canNotify && this.parent != null) {
  5103. this.parent._onPointerMove(target, coordinates, pointerId);
  5104. }
  5105. };
  5106. /** @hidden */
  5107. Control.prototype._onPointerEnter = function (target) {
  5108. if (!this._isEnabled) {
  5109. return false;
  5110. }
  5111. if (this._enterCount > 0) {
  5112. return false;
  5113. }
  5114. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5115. this._enterCount = 0;
  5116. }
  5117. this._enterCount++;
  5118. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5119. if (canNotify && this.parent != null) {
  5120. this.parent._onPointerEnter(target);
  5121. }
  5122. return true;
  5123. };
  5124. /** @hidden */
  5125. Control.prototype._onPointerOut = function (target, force) {
  5126. if (force === void 0) { force = false; }
  5127. if (!force && (!this._isEnabled || target === this)) {
  5128. return;
  5129. }
  5130. this._enterCount = 0;
  5131. var canNotify = true;
  5132. if (!target.isAscendant(this)) {
  5133. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5134. }
  5135. if (canNotify && this.parent != null) {
  5136. this.parent._onPointerOut(target, force);
  5137. }
  5138. };
  5139. /** @hidden */
  5140. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5141. // Prevent pointerout to lose control context.
  5142. // Event redundancy is checked inside the function.
  5143. this._onPointerEnter(this);
  5144. if (this._downCount !== 0) {
  5145. return false;
  5146. }
  5147. this._downCount++;
  5148. this._downPointerIds[pointerId] = true;
  5149. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5150. if (canNotify && this.parent != null) {
  5151. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5152. }
  5153. return true;
  5154. };
  5155. /** @hidden */
  5156. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5157. if (!this._isEnabled) {
  5158. return;
  5159. }
  5160. this._downCount = 0;
  5161. delete this._downPointerIds[pointerId];
  5162. var canNotifyClick = notifyClick;
  5163. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5164. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5165. }
  5166. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5167. if (canNotify && this.parent != null) {
  5168. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5169. }
  5170. };
  5171. /** @hidden */
  5172. Control.prototype._forcePointerUp = function (pointerId) {
  5173. if (pointerId === void 0) { pointerId = null; }
  5174. if (pointerId !== null) {
  5175. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5176. }
  5177. else {
  5178. for (var key in this._downPointerIds) {
  5179. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5180. }
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5185. if (!this._isEnabled) {
  5186. return false;
  5187. }
  5188. this._dummyVector2.copyFromFloats(x, y);
  5189. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5190. this._onPointerMove(this, this._dummyVector2, pointerId);
  5191. var previousControlOver = this._host._lastControlOver[pointerId];
  5192. if (previousControlOver && previousControlOver !== this) {
  5193. previousControlOver._onPointerOut(this);
  5194. }
  5195. if (previousControlOver !== this) {
  5196. this._onPointerEnter(this);
  5197. }
  5198. this._host._lastControlOver[pointerId] = this;
  5199. return true;
  5200. }
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5202. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5203. this._host._registerLastControlDown(this, pointerId);
  5204. this._host._lastPickedControl = this;
  5205. return true;
  5206. }
  5207. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5208. if (this._host._lastControlDown[pointerId]) {
  5209. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5210. }
  5211. delete this._host._lastControlDown[pointerId];
  5212. return true;
  5213. }
  5214. return false;
  5215. };
  5216. Control.prototype._prepareFont = function () {
  5217. if (!this._font && !this._fontSet) {
  5218. return;
  5219. }
  5220. if (this._style) {
  5221. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5222. }
  5223. else {
  5224. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5225. }
  5226. this._fontOffset = Control._GetFontOffset(this._font);
  5227. };
  5228. /** Releases associated resources */
  5229. Control.prototype.dispose = function () {
  5230. this.onDirtyObservable.clear();
  5231. this.onBeforeDrawObservable.clear();
  5232. this.onAfterDrawObservable.clear();
  5233. this.onPointerDownObservable.clear();
  5234. this.onPointerEnterObservable.clear();
  5235. this.onPointerMoveObservable.clear();
  5236. this.onPointerOutObservable.clear();
  5237. this.onPointerUpObservable.clear();
  5238. this.onPointerClickObservable.clear();
  5239. if (this._styleObserver && this._style) {
  5240. this._style.onChangedObservable.remove(this._styleObserver);
  5241. this._styleObserver = null;
  5242. }
  5243. if (this.parent) {
  5244. this.parent.removeControl(this);
  5245. this.parent = null;
  5246. }
  5247. if (this._host) {
  5248. var index = this._host._linkedControls.indexOf(this);
  5249. if (index > -1) {
  5250. this.linkWithMesh(null);
  5251. }
  5252. }
  5253. };
  5254. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5255. /** HORIZONTAL_ALIGNMENT_LEFT */
  5256. get: function () {
  5257. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5258. },
  5259. enumerable: true,
  5260. configurable: true
  5261. });
  5262. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5263. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5264. get: function () {
  5265. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5266. },
  5267. enumerable: true,
  5268. configurable: true
  5269. });
  5270. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5271. /** HORIZONTAL_ALIGNMENT_CENTER */
  5272. get: function () {
  5273. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5274. },
  5275. enumerable: true,
  5276. configurable: true
  5277. });
  5278. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5279. /** VERTICAL_ALIGNMENT_TOP */
  5280. get: function () {
  5281. return Control._VERTICAL_ALIGNMENT_TOP;
  5282. },
  5283. enumerable: true,
  5284. configurable: true
  5285. });
  5286. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5287. /** VERTICAL_ALIGNMENT_BOTTOM */
  5288. get: function () {
  5289. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5290. },
  5291. enumerable: true,
  5292. configurable: true
  5293. });
  5294. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5295. /** VERTICAL_ALIGNMENT_CENTER */
  5296. get: function () {
  5297. return Control._VERTICAL_ALIGNMENT_CENTER;
  5298. },
  5299. enumerable: true,
  5300. configurable: true
  5301. });
  5302. /** @hidden */
  5303. Control._GetFontOffset = function (font) {
  5304. if (Control._FontHeightSizes[font]) {
  5305. return Control._FontHeightSizes[font];
  5306. }
  5307. var text = document.createElement("span");
  5308. text.innerHTML = "Hg";
  5309. text.style.font = font;
  5310. var block = document.createElement("div");
  5311. block.style.display = "inline-block";
  5312. block.style.width = "1px";
  5313. block.style.height = "0px";
  5314. block.style.verticalAlign = "bottom";
  5315. var div = document.createElement("div");
  5316. div.appendChild(text);
  5317. div.appendChild(block);
  5318. document.body.appendChild(div);
  5319. var fontAscent = 0;
  5320. var fontHeight = 0;
  5321. try {
  5322. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5323. block.style.verticalAlign = "baseline";
  5324. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5325. }
  5326. finally {
  5327. document.body.removeChild(div);
  5328. }
  5329. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5330. Control._FontHeightSizes[font] = result;
  5331. return result;
  5332. };
  5333. /** @hidden */
  5334. Control.drawEllipse = function (x, y, width, height, context) {
  5335. context.translate(x, y);
  5336. context.scale(width, height);
  5337. context.beginPath();
  5338. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5339. context.closePath();
  5340. context.scale(1 / width, 1 / height);
  5341. context.translate(-x, -y);
  5342. };
  5343. /**
  5344. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5345. */
  5346. Control.AllowAlphaInheritance = false;
  5347. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5348. // Statics
  5349. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5350. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5351. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5352. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5353. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5354. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5355. Control._FontHeightSizes = {};
  5356. /**
  5357. * Creates a stack panel that can be used to render headers
  5358. * @param control defines the control to associate with the header
  5359. * @param text defines the text of the header
  5360. * @param size defines the size of the header
  5361. * @param options defines options used to configure the header
  5362. * @returns a new StackPanel
  5363. * @ignore
  5364. * @hidden
  5365. */
  5366. Control.AddHeader = function () { };
  5367. return Control;
  5368. }());
  5369. /***/ }),
  5370. /***/ "./2D/controls/displayGrid.ts":
  5371. /*!************************************!*\
  5372. !*** ./2D/controls/displayGrid.ts ***!
  5373. \************************************/
  5374. /*! exports provided: DisplayGrid */
  5375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5376. "use strict";
  5377. __webpack_require__.r(__webpack_exports__);
  5378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5380. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5381. /** Class used to render a grid */
  5382. var DisplayGrid = /** @class */ (function (_super) {
  5383. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5384. /**
  5385. * Creates a new GridDisplayRectangle
  5386. * @param name defines the control name
  5387. */
  5388. function DisplayGrid(name) {
  5389. var _this = _super.call(this, name) || this;
  5390. _this.name = name;
  5391. _this._cellWidth = 20;
  5392. _this._cellHeight = 20;
  5393. _this._minorLineTickness = 1;
  5394. _this._minorLineColor = "DarkGray";
  5395. _this._majorLineTickness = 2;
  5396. _this._majorLineColor = "White";
  5397. _this._majorLineFrequency = 5;
  5398. _this._background = "Black";
  5399. _this._displayMajorLines = true;
  5400. _this._displayMinorLines = true;
  5401. return _this;
  5402. }
  5403. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5404. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5405. get: function () {
  5406. return this._displayMinorLines;
  5407. },
  5408. set: function (value) {
  5409. if (this._displayMinorLines === value) {
  5410. return;
  5411. }
  5412. this._displayMinorLines = value;
  5413. this._markAsDirty();
  5414. },
  5415. enumerable: true,
  5416. configurable: true
  5417. });
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5419. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMajorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMajorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMajorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "background", {
  5434. /** Gets or sets background color (Black by default) */
  5435. get: function () {
  5436. return this._background;
  5437. },
  5438. set: function (value) {
  5439. if (this._background === value) {
  5440. return;
  5441. }
  5442. this._background = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5449. /** Gets or sets the width of each cell (20 by default) */
  5450. get: function () {
  5451. return this._cellWidth;
  5452. },
  5453. set: function (value) {
  5454. this._cellWidth = value;
  5455. this._markAsDirty();
  5456. },
  5457. enumerable: true,
  5458. configurable: true
  5459. });
  5460. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5461. /** Gets or sets the height of each cell (20 by default) */
  5462. get: function () {
  5463. return this._cellHeight;
  5464. },
  5465. set: function (value) {
  5466. this._cellHeight = value;
  5467. this._markAsDirty();
  5468. },
  5469. enumerable: true,
  5470. configurable: true
  5471. });
  5472. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5473. /** Gets or sets the tickness of minor lines (1 by default) */
  5474. get: function () {
  5475. return this._minorLineTickness;
  5476. },
  5477. set: function (value) {
  5478. this._minorLineTickness = value;
  5479. this._markAsDirty();
  5480. },
  5481. enumerable: true,
  5482. configurable: true
  5483. });
  5484. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5485. /** Gets or sets the color of minor lines (DarkGray by default) */
  5486. get: function () {
  5487. return this._minorLineColor;
  5488. },
  5489. set: function (value) {
  5490. this._minorLineColor = value;
  5491. this._markAsDirty();
  5492. },
  5493. enumerable: true,
  5494. configurable: true
  5495. });
  5496. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5497. /** Gets or sets the tickness of major lines (2 by default) */
  5498. get: function () {
  5499. return this._majorLineTickness;
  5500. },
  5501. set: function (value) {
  5502. this._majorLineTickness = value;
  5503. this._markAsDirty();
  5504. },
  5505. enumerable: true,
  5506. configurable: true
  5507. });
  5508. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5509. /** Gets or sets the color of major lines (White by default) */
  5510. get: function () {
  5511. return this._majorLineColor;
  5512. },
  5513. set: function (value) {
  5514. this._majorLineColor = value;
  5515. this._markAsDirty();
  5516. },
  5517. enumerable: true,
  5518. configurable: true
  5519. });
  5520. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5521. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5522. get: function () {
  5523. return this._majorLineFrequency;
  5524. },
  5525. set: function (value) {
  5526. this._majorLineFrequency = value;
  5527. this._markAsDirty();
  5528. },
  5529. enumerable: true,
  5530. configurable: true
  5531. });
  5532. DisplayGrid.prototype._draw = function (context) {
  5533. context.save();
  5534. this._applyStates(context);
  5535. if (this._isEnabled) {
  5536. if (this._background) {
  5537. context.fillStyle = this._background;
  5538. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5539. }
  5540. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5541. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5542. // Minor lines
  5543. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5544. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5545. if (this._displayMinorLines) {
  5546. context.strokeStyle = this._minorLineColor;
  5547. context.lineWidth = this._minorLineTickness;
  5548. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5549. var cellX = left + x * this.cellWidth;
  5550. context.beginPath();
  5551. context.moveTo(cellX, this._currentMeasure.top);
  5552. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5553. context.stroke();
  5554. }
  5555. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5556. var cellY = top_1 + y * this.cellHeight;
  5557. context.beginPath();
  5558. context.moveTo(this._currentMeasure.left, cellY);
  5559. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5560. context.stroke();
  5561. }
  5562. }
  5563. // Major lines
  5564. if (this._displayMajorLines) {
  5565. context.strokeStyle = this._majorLineColor;
  5566. context.lineWidth = this._majorLineTickness;
  5567. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5568. var cellX = left + x * this.cellWidth;
  5569. context.beginPath();
  5570. context.moveTo(cellX, this._currentMeasure.top);
  5571. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5572. context.stroke();
  5573. }
  5574. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5575. var cellY = top_1 + y * this.cellHeight;
  5576. context.moveTo(this._currentMeasure.left, cellY);
  5577. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5578. context.closePath();
  5579. context.stroke();
  5580. }
  5581. }
  5582. }
  5583. context.restore();
  5584. };
  5585. DisplayGrid.prototype._getTypeName = function () {
  5586. return "DisplayGrid";
  5587. };
  5588. return DisplayGrid;
  5589. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5590. /***/ }),
  5591. /***/ "./2D/controls/ellipse.ts":
  5592. /*!********************************!*\
  5593. !*** ./2D/controls/ellipse.ts ***!
  5594. \********************************/
  5595. /*! exports provided: Ellipse */
  5596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5597. "use strict";
  5598. __webpack_require__.r(__webpack_exports__);
  5599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5600. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5601. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5602. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5603. /** Class used to create 2D ellipse containers */
  5604. var Ellipse = /** @class */ (function (_super) {
  5605. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5606. /**
  5607. * Creates a new Ellipse
  5608. * @param name defines the control name
  5609. */
  5610. function Ellipse(name) {
  5611. var _this = _super.call(this, name) || this;
  5612. _this.name = name;
  5613. _this._thickness = 1;
  5614. return _this;
  5615. }
  5616. Object.defineProperty(Ellipse.prototype, "thickness", {
  5617. /** Gets or sets border thickness */
  5618. get: function () {
  5619. return this._thickness;
  5620. },
  5621. set: function (value) {
  5622. if (this._thickness === value) {
  5623. return;
  5624. }
  5625. this._thickness = value;
  5626. this._markAsDirty();
  5627. },
  5628. enumerable: true,
  5629. configurable: true
  5630. });
  5631. Ellipse.prototype._getTypeName = function () {
  5632. return "Ellipse";
  5633. };
  5634. Ellipse.prototype._localDraw = function (context) {
  5635. context.save();
  5636. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5637. context.shadowColor = this.shadowColor;
  5638. context.shadowBlur = this.shadowBlur;
  5639. context.shadowOffsetX = this.shadowOffsetX;
  5640. context.shadowOffsetY = this.shadowOffsetY;
  5641. }
  5642. _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);
  5643. if (this._background) {
  5644. context.fillStyle = this._background;
  5645. context.fill();
  5646. }
  5647. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5648. context.shadowBlur = 0;
  5649. context.shadowOffsetX = 0;
  5650. context.shadowOffsetY = 0;
  5651. }
  5652. if (this._thickness) {
  5653. if (this.color) {
  5654. context.strokeStyle = this.color;
  5655. }
  5656. context.lineWidth = this._thickness;
  5657. context.stroke();
  5658. }
  5659. context.restore();
  5660. };
  5661. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5662. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5663. this._measureForChildren.width -= 2 * this._thickness;
  5664. this._measureForChildren.height -= 2 * this._thickness;
  5665. this._measureForChildren.left += this._thickness;
  5666. this._measureForChildren.top += this._thickness;
  5667. };
  5668. Ellipse.prototype._clipForChildren = function (context) {
  5669. _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);
  5670. context.clip();
  5671. };
  5672. return Ellipse;
  5673. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5674. /***/ }),
  5675. /***/ "./2D/controls/grid.ts":
  5676. /*!*****************************!*\
  5677. !*** ./2D/controls/grid.ts ***!
  5678. \*****************************/
  5679. /*! exports provided: Grid */
  5680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5681. "use strict";
  5682. __webpack_require__.r(__webpack_exports__);
  5683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5685. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5686. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5687. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5688. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5689. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5690. /**
  5691. * Class used to create a 2D grid container
  5692. */
  5693. var Grid = /** @class */ (function (_super) {
  5694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5695. /**
  5696. * Creates a new Grid
  5697. * @param name defines control name
  5698. */
  5699. function Grid(name) {
  5700. var _this = _super.call(this, name) || this;
  5701. _this.name = name;
  5702. _this._rowDefinitions = new Array();
  5703. _this._columnDefinitions = new Array();
  5704. _this._cells = {};
  5705. _this._childControls = new Array();
  5706. return _this;
  5707. }
  5708. Object.defineProperty(Grid.prototype, "columnCount", {
  5709. /**
  5710. * Gets the number of columns
  5711. */
  5712. get: function () {
  5713. return this._columnDefinitions.length;
  5714. },
  5715. enumerable: true,
  5716. configurable: true
  5717. });
  5718. Object.defineProperty(Grid.prototype, "rowCount", {
  5719. /**
  5720. * Gets the number of rows
  5721. */
  5722. get: function () {
  5723. return this._rowDefinitions.length;
  5724. },
  5725. enumerable: true,
  5726. configurable: true
  5727. });
  5728. Object.defineProperty(Grid.prototype, "children", {
  5729. /** Gets the list of children */
  5730. get: function () {
  5731. return this._childControls;
  5732. },
  5733. enumerable: true,
  5734. configurable: true
  5735. });
  5736. Object.defineProperty(Grid.prototype, "cells", {
  5737. /** Gets the list of cells (e.g. the containers) */
  5738. get: function () {
  5739. return this._cells;
  5740. },
  5741. enumerable: true,
  5742. configurable: true
  5743. });
  5744. /**
  5745. * Gets the definition of a specific row
  5746. * @param index defines the index of the row
  5747. * @returns the row definition
  5748. */
  5749. Grid.prototype.getRowDefinition = function (index) {
  5750. if (index < 0 || index >= this._rowDefinitions.length) {
  5751. return null;
  5752. }
  5753. return this._rowDefinitions[index];
  5754. };
  5755. /**
  5756. * Gets the definition of a specific column
  5757. * @param index defines the index of the column
  5758. * @returns the column definition
  5759. */
  5760. Grid.prototype.getColumnDefinition = function (index) {
  5761. if (index < 0 || index >= this._columnDefinitions.length) {
  5762. return null;
  5763. }
  5764. return this._columnDefinitions[index];
  5765. };
  5766. /**
  5767. * Adds a new row to the grid
  5768. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5769. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5770. * @returns the current grid
  5771. */
  5772. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5773. if (isPixel === void 0) { isPixel = false; }
  5774. 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));
  5775. this._markAsDirty();
  5776. return this;
  5777. };
  5778. /**
  5779. * Adds a new column to the grid
  5780. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5781. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5782. * @returns the current grid
  5783. */
  5784. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5785. if (isPixel === void 0) { isPixel = false; }
  5786. 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));
  5787. this._markAsDirty();
  5788. return this;
  5789. };
  5790. /**
  5791. * Update a row definition
  5792. * @param index defines the index of the row to update
  5793. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5794. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5795. * @returns the current grid
  5796. */
  5797. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5798. if (isPixel === void 0) { isPixel = false; }
  5799. if (index < 0 || index >= this._rowDefinitions.length) {
  5800. return this;
  5801. }
  5802. var current = this._rowDefinitions[index];
  5803. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5804. return this;
  5805. }
  5806. 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);
  5807. this._markAsDirty();
  5808. return this;
  5809. };
  5810. /**
  5811. * Update a column definition
  5812. * @param index defines the index of the column to update
  5813. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5814. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5815. * @returns the current grid
  5816. */
  5817. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5818. if (isPixel === void 0) { isPixel = false; }
  5819. if (index < 0 || index >= this._columnDefinitions.length) {
  5820. return this;
  5821. }
  5822. var current = this._columnDefinitions[index];
  5823. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5824. return this;
  5825. }
  5826. 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);
  5827. this._markAsDirty();
  5828. return this;
  5829. };
  5830. /**
  5831. * Gets the list of children stored in a specific cell
  5832. * @param row defines the row to check
  5833. * @param column defines the column to check
  5834. * @returns the list of controls
  5835. */
  5836. Grid.prototype.getChildrenAt = function (row, column) {
  5837. var cell = this._cells[row + ":" + column];
  5838. if (!cell) {
  5839. return null;
  5840. }
  5841. return cell.children;
  5842. };
  5843. /**
  5844. * Gets a string representing the child cell info (row x column)
  5845. * @param child defines the control to get info from
  5846. * @returns a string containing the child cell info (row x column)
  5847. */
  5848. Grid.prototype.getChildCellInfo = function (child) {
  5849. return child._tag;
  5850. };
  5851. Grid.prototype._removeCell = function (cell, key) {
  5852. if (!cell) {
  5853. return;
  5854. }
  5855. _super.prototype.removeControl.call(this, cell);
  5856. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5857. var control = _a[_i];
  5858. var childIndex = this._childControls.indexOf(control);
  5859. if (childIndex !== -1) {
  5860. this._childControls.splice(childIndex, 1);
  5861. }
  5862. }
  5863. delete this._cells[key];
  5864. };
  5865. Grid.prototype._offsetCell = function (previousKey, key) {
  5866. if (!this._cells[key]) {
  5867. return;
  5868. }
  5869. this._cells[previousKey] = this._cells[key];
  5870. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5871. var control = _a[_i];
  5872. control._tag = previousKey;
  5873. }
  5874. delete this._cells[key];
  5875. };
  5876. /**
  5877. * Remove a column definition at specified index
  5878. * @param index defines the index of the column to remove
  5879. * @returns the current grid
  5880. */
  5881. Grid.prototype.removeColumnDefinition = function (index) {
  5882. if (index < 0 || index >= this._columnDefinitions.length) {
  5883. return this;
  5884. }
  5885. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5886. var key = x + ":" + index;
  5887. var cell = this._cells[key];
  5888. this._removeCell(cell, key);
  5889. }
  5890. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5891. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5892. var previousKey = x + ":" + (y - 1);
  5893. var key = x + ":" + y;
  5894. this._offsetCell(previousKey, key);
  5895. }
  5896. }
  5897. this._columnDefinitions.splice(index, 1);
  5898. this._markAsDirty();
  5899. return this;
  5900. };
  5901. /**
  5902. * Remove a row definition at specified index
  5903. * @param index defines the index of the row to remove
  5904. * @returns the current grid
  5905. */
  5906. Grid.prototype.removeRowDefinition = function (index) {
  5907. if (index < 0 || index >= this._rowDefinitions.length) {
  5908. return this;
  5909. }
  5910. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5911. var key = index + ":" + y;
  5912. var cell = this._cells[key];
  5913. this._removeCell(cell, key);
  5914. }
  5915. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5916. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5917. var previousKey = x - 1 + ":" + y;
  5918. var key = x + ":" + y;
  5919. this._offsetCell(previousKey, key);
  5920. }
  5921. }
  5922. this._rowDefinitions.splice(index, 1);
  5923. this._markAsDirty();
  5924. return this;
  5925. };
  5926. /**
  5927. * Adds a new control to the current grid
  5928. * @param control defines the control to add
  5929. * @param row defines the row where to add the control (0 by default)
  5930. * @param column defines the column where to add the control (0 by default)
  5931. * @returns the current grid
  5932. */
  5933. Grid.prototype.addControl = function (control, row, column) {
  5934. if (row === void 0) { row = 0; }
  5935. if (column === void 0) { column = 0; }
  5936. if (this._rowDefinitions.length === 0) {
  5937. // Add default row definition
  5938. this.addRowDefinition(1, false);
  5939. }
  5940. if (this._columnDefinitions.length === 0) {
  5941. // Add default column definition
  5942. this.addColumnDefinition(1, false);
  5943. }
  5944. if (this._childControls.indexOf(control) !== -1) {
  5945. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  5946. return this;
  5947. }
  5948. var x = Math.min(row, this._rowDefinitions.length - 1);
  5949. var y = Math.min(column, this._columnDefinitions.length - 1);
  5950. var key = x + ":" + y;
  5951. var goodContainer = this._cells[key];
  5952. if (!goodContainer) {
  5953. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5954. this._cells[key] = goodContainer;
  5955. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5956. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5957. _super.prototype.addControl.call(this, goodContainer);
  5958. }
  5959. goodContainer.addControl(control);
  5960. this._childControls.push(control);
  5961. control._tag = key;
  5962. control.parent = this;
  5963. this._markAsDirty();
  5964. return this;
  5965. };
  5966. /**
  5967. * Removes a control from the current container
  5968. * @param control defines the control to remove
  5969. * @returns the current container
  5970. */
  5971. Grid.prototype.removeControl = function (control) {
  5972. var index = this._childControls.indexOf(control);
  5973. if (index !== -1) {
  5974. this._childControls.splice(index, 1);
  5975. }
  5976. var cell = this._cells[control._tag];
  5977. if (cell) {
  5978. cell.removeControl(control);
  5979. control._tag = null;
  5980. }
  5981. this._markAsDirty();
  5982. return this;
  5983. };
  5984. Grid.prototype._getTypeName = function () {
  5985. return "Grid";
  5986. };
  5987. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5988. var widths = [];
  5989. var heights = [];
  5990. var lefts = [];
  5991. var tops = [];
  5992. var availableWidth = this._currentMeasure.width;
  5993. var globalWidthPercentage = 0;
  5994. var availableHeight = this._currentMeasure.height;
  5995. var globalHeightPercentage = 0;
  5996. // Heights
  5997. var index = 0;
  5998. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5999. var value = _a[_i];
  6000. if (value.isPixel) {
  6001. var height = value.getValue(this._host);
  6002. availableHeight -= height;
  6003. heights[index] = height;
  6004. }
  6005. else {
  6006. globalHeightPercentage += value.internalValue;
  6007. }
  6008. index++;
  6009. }
  6010. var top = 0;
  6011. index = 0;
  6012. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6013. var value = _c[_b];
  6014. tops.push(top);
  6015. if (!value.isPixel) {
  6016. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6017. top += height;
  6018. heights[index] = height;
  6019. }
  6020. else {
  6021. top += value.getValue(this._host);
  6022. }
  6023. index++;
  6024. }
  6025. // Widths
  6026. index = 0;
  6027. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6028. var value = _e[_d];
  6029. if (value.isPixel) {
  6030. var width = value.getValue(this._host);
  6031. availableWidth -= width;
  6032. widths[index] = width;
  6033. }
  6034. else {
  6035. globalWidthPercentage += value.internalValue;
  6036. }
  6037. index++;
  6038. }
  6039. var left = 0;
  6040. index = 0;
  6041. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6042. var value = _g[_f];
  6043. lefts.push(left);
  6044. if (!value.isPixel) {
  6045. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6046. left += width;
  6047. widths[index] = width;
  6048. }
  6049. else {
  6050. left += value.getValue(this._host);
  6051. }
  6052. index++;
  6053. }
  6054. definitionCallback(lefts, tops, widths, heights);
  6055. };
  6056. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6057. var _this = this;
  6058. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6059. // Setting child sizes
  6060. for (var key in _this._cells) {
  6061. if (!_this._cells.hasOwnProperty(key)) {
  6062. continue;
  6063. }
  6064. var split = key.split(":");
  6065. var x = parseInt(split[0]);
  6066. var y = parseInt(split[1]);
  6067. var cell = _this._cells[key];
  6068. cell.left = lefts[y] + "px";
  6069. cell.top = tops[x] + "px";
  6070. cell.width = widths[y] + "px";
  6071. cell.height = heights[x] + "px";
  6072. cell._left.ignoreAdaptiveScaling = true;
  6073. cell._top.ignoreAdaptiveScaling = true;
  6074. cell._width.ignoreAdaptiveScaling = true;
  6075. cell._height.ignoreAdaptiveScaling = true;
  6076. }
  6077. });
  6078. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6079. };
  6080. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6081. for (var key in this._cells) {
  6082. if (!this._cells.hasOwnProperty(key)) {
  6083. continue;
  6084. }
  6085. var child = this._cells[key];
  6086. child._markMatrixAsDirty();
  6087. }
  6088. };
  6089. Grid.prototype._renderHighlightSpecific = function (context) {
  6090. var _this = this;
  6091. _super.prototype._renderHighlightSpecific.call(this, context);
  6092. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6093. // Columns
  6094. for (var index = 0; index < lefts.length; index++) {
  6095. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6096. context.beginPath();
  6097. context.moveTo(left, _this._currentMeasure.top);
  6098. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6099. context.stroke();
  6100. }
  6101. // Rows
  6102. for (var index = 0; index < tops.length; index++) {
  6103. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6104. context.beginPath();
  6105. context.moveTo(_this._currentMeasure.left, top_1);
  6106. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6107. context.stroke();
  6108. }
  6109. });
  6110. context.restore();
  6111. };
  6112. /** Releases associated resources */
  6113. Grid.prototype.dispose = function () {
  6114. _super.prototype.dispose.call(this);
  6115. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6116. var control = _a[_i];
  6117. control.dispose();
  6118. }
  6119. this._childControls = [];
  6120. };
  6121. return Grid;
  6122. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6123. /***/ }),
  6124. /***/ "./2D/controls/image.ts":
  6125. /*!******************************!*\
  6126. !*** ./2D/controls/image.ts ***!
  6127. \******************************/
  6128. /*! exports provided: Image */
  6129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6130. "use strict";
  6131. __webpack_require__.r(__webpack_exports__);
  6132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6134. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6135. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6136. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6137. /**
  6138. * Class used to create 2D images
  6139. */
  6140. var Image = /** @class */ (function (_super) {
  6141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6142. /**
  6143. * Creates a new Image
  6144. * @param name defines the control name
  6145. * @param url defines the image url
  6146. */
  6147. function Image(name, url) {
  6148. if (url === void 0) { url = null; }
  6149. var _this = _super.call(this, name) || this;
  6150. _this.name = name;
  6151. _this._loaded = false;
  6152. _this._stretch = Image.STRETCH_FILL;
  6153. _this._autoScale = false;
  6154. _this._sourceLeft = 0;
  6155. _this._sourceTop = 0;
  6156. _this._sourceWidth = 0;
  6157. _this._sourceHeight = 0;
  6158. _this._cellWidth = 0;
  6159. _this._cellHeight = 0;
  6160. _this._cellId = -1;
  6161. _this._populateNinePatchSlicesFromImage = false;
  6162. /**
  6163. * Observable notified when the content is loaded
  6164. */
  6165. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6166. /**
  6167. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6168. */
  6169. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6170. _this.source = url;
  6171. return _this;
  6172. }
  6173. Object.defineProperty(Image.prototype, "isLoaded", {
  6174. /**
  6175. * Gets a boolean indicating that the content is loaded
  6176. */
  6177. get: function () {
  6178. return this._loaded;
  6179. },
  6180. enumerable: true,
  6181. configurable: true
  6182. });
  6183. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6184. /**
  6185. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6186. */
  6187. get: function () {
  6188. return this._populateNinePatchSlicesFromImage;
  6189. },
  6190. set: function (value) {
  6191. if (this._populateNinePatchSlicesFromImage === value) {
  6192. return;
  6193. }
  6194. this._populateNinePatchSlicesFromImage = value;
  6195. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6196. this._extractNinePatchSliceDataFromImage();
  6197. }
  6198. },
  6199. enumerable: true,
  6200. configurable: true
  6201. });
  6202. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6203. /**
  6204. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6205. * Beware using this as this will comsume more memory as the image has to be stored twice
  6206. */
  6207. get: function () {
  6208. return this._detectPointerOnOpaqueOnly;
  6209. },
  6210. set: function (value) {
  6211. if (this._detectPointerOnOpaqueOnly === value) {
  6212. return;
  6213. }
  6214. this._detectPointerOnOpaqueOnly = value;
  6215. },
  6216. enumerable: true,
  6217. configurable: true
  6218. });
  6219. Object.defineProperty(Image.prototype, "sliceLeft", {
  6220. /**
  6221. * Gets or sets the left value for slicing (9-patch)
  6222. */
  6223. get: function () {
  6224. return this._sliceLeft;
  6225. },
  6226. set: function (value) {
  6227. if (this._sliceLeft === value) {
  6228. return;
  6229. }
  6230. this._sliceLeft = value;
  6231. this._markAsDirty();
  6232. },
  6233. enumerable: true,
  6234. configurable: true
  6235. });
  6236. Object.defineProperty(Image.prototype, "sliceRight", {
  6237. /**
  6238. * Gets or sets the right value for slicing (9-patch)
  6239. */
  6240. get: function () {
  6241. return this._sliceRight;
  6242. },
  6243. set: function (value) {
  6244. if (this._sliceRight === value) {
  6245. return;
  6246. }
  6247. this._sliceRight = value;
  6248. this._markAsDirty();
  6249. },
  6250. enumerable: true,
  6251. configurable: true
  6252. });
  6253. Object.defineProperty(Image.prototype, "sliceTop", {
  6254. /**
  6255. * Gets or sets the top value for slicing (9-patch)
  6256. */
  6257. get: function () {
  6258. return this._sliceTop;
  6259. },
  6260. set: function (value) {
  6261. if (this._sliceTop === value) {
  6262. return;
  6263. }
  6264. this._sliceTop = value;
  6265. this._markAsDirty();
  6266. },
  6267. enumerable: true,
  6268. configurable: true
  6269. });
  6270. Object.defineProperty(Image.prototype, "sliceBottom", {
  6271. /**
  6272. * Gets or sets the bottom value for slicing (9-patch)
  6273. */
  6274. get: function () {
  6275. return this._sliceBottom;
  6276. },
  6277. set: function (value) {
  6278. if (this._sliceBottom === value) {
  6279. return;
  6280. }
  6281. this._sliceBottom = value;
  6282. this._markAsDirty();
  6283. },
  6284. enumerable: true,
  6285. configurable: true
  6286. });
  6287. Object.defineProperty(Image.prototype, "sourceLeft", {
  6288. /**
  6289. * Gets or sets the left coordinate in the source image
  6290. */
  6291. get: function () {
  6292. return this._sourceLeft;
  6293. },
  6294. set: function (value) {
  6295. if (this._sourceLeft === value) {
  6296. return;
  6297. }
  6298. this._sourceLeft = value;
  6299. this._markAsDirty();
  6300. },
  6301. enumerable: true,
  6302. configurable: true
  6303. });
  6304. Object.defineProperty(Image.prototype, "sourceTop", {
  6305. /**
  6306. * Gets or sets the top coordinate in the source image
  6307. */
  6308. get: function () {
  6309. return this._sourceTop;
  6310. },
  6311. set: function (value) {
  6312. if (this._sourceTop === value) {
  6313. return;
  6314. }
  6315. this._sourceTop = value;
  6316. this._markAsDirty();
  6317. },
  6318. enumerable: true,
  6319. configurable: true
  6320. });
  6321. Object.defineProperty(Image.prototype, "sourceWidth", {
  6322. /**
  6323. * Gets or sets the width to capture in the source image
  6324. */
  6325. get: function () {
  6326. return this._sourceWidth;
  6327. },
  6328. set: function (value) {
  6329. if (this._sourceWidth === value) {
  6330. return;
  6331. }
  6332. this._sourceWidth = value;
  6333. this._markAsDirty();
  6334. },
  6335. enumerable: true,
  6336. configurable: true
  6337. });
  6338. Object.defineProperty(Image.prototype, "sourceHeight", {
  6339. /**
  6340. * Gets or sets the height to capture in the source image
  6341. */
  6342. get: function () {
  6343. return this._sourceHeight;
  6344. },
  6345. set: function (value) {
  6346. if (this._sourceHeight === value) {
  6347. return;
  6348. }
  6349. this._sourceHeight = value;
  6350. this._markAsDirty();
  6351. },
  6352. enumerable: true,
  6353. configurable: true
  6354. });
  6355. Object.defineProperty(Image.prototype, "autoScale", {
  6356. /**
  6357. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6358. * @see http://doc.babylonjs.com/how_to/gui#image
  6359. */
  6360. get: function () {
  6361. return this._autoScale;
  6362. },
  6363. set: function (value) {
  6364. if (this._autoScale === value) {
  6365. return;
  6366. }
  6367. this._autoScale = value;
  6368. if (value && this._loaded) {
  6369. this.synchronizeSizeWithContent();
  6370. }
  6371. },
  6372. enumerable: true,
  6373. configurable: true
  6374. });
  6375. Object.defineProperty(Image.prototype, "stretch", {
  6376. /** Gets or sets the streching mode used by the image */
  6377. get: function () {
  6378. return this._stretch;
  6379. },
  6380. set: function (value) {
  6381. if (this._stretch === value) {
  6382. return;
  6383. }
  6384. this._stretch = value;
  6385. this._markAsDirty();
  6386. },
  6387. enumerable: true,
  6388. configurable: true
  6389. });
  6390. Object.defineProperty(Image.prototype, "domImage", {
  6391. get: function () {
  6392. return this._domImage;
  6393. },
  6394. /**
  6395. * Gets or sets the internal DOM image used to render the control
  6396. */
  6397. set: function (value) {
  6398. var _this = this;
  6399. this._domImage = value;
  6400. this._loaded = false;
  6401. if (this._domImage.width) {
  6402. this._onImageLoaded();
  6403. }
  6404. else {
  6405. this._domImage.onload = function () {
  6406. _this._onImageLoaded();
  6407. };
  6408. }
  6409. },
  6410. enumerable: true,
  6411. configurable: true
  6412. });
  6413. Image.prototype._onImageLoaded = function () {
  6414. this._imageWidth = this._domImage.width;
  6415. this._imageHeight = this._domImage.height;
  6416. this._loaded = true;
  6417. if (this._populateNinePatchSlicesFromImage) {
  6418. this._extractNinePatchSliceDataFromImage();
  6419. }
  6420. if (this._autoScale) {
  6421. this.synchronizeSizeWithContent();
  6422. }
  6423. this.onImageLoadedObservable.notifyObservers(this);
  6424. this._markAsDirty();
  6425. };
  6426. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6427. if (!Image._WorkingCanvas) {
  6428. Image._WorkingCanvas = document.createElement('canvas');
  6429. }
  6430. var canvas = Image._WorkingCanvas;
  6431. var context = canvas.getContext('2d');
  6432. var width = this._domImage.width;
  6433. var height = this._domImage.height;
  6434. canvas.width = width;
  6435. canvas.height = height;
  6436. context.drawImage(this._domImage, 0, 0, width, height);
  6437. var imageData = context.getImageData(0, 0, width, height);
  6438. // Left and right
  6439. this._sliceLeft = -1;
  6440. this._sliceRight = -1;
  6441. for (var x = 0; x < width; x++) {
  6442. var alpha = imageData.data[x * 4 + 3];
  6443. if (alpha > 127 && this._sliceLeft === -1) {
  6444. this._sliceLeft = x;
  6445. continue;
  6446. }
  6447. if (alpha < 127 && this._sliceLeft > -1) {
  6448. this._sliceRight = x;
  6449. break;
  6450. }
  6451. }
  6452. // top and bottom
  6453. this._sliceTop = -1;
  6454. this._sliceBottom = -1;
  6455. for (var y = 0; y < height; y++) {
  6456. var alpha = imageData.data[y * width * 4 + 3];
  6457. if (alpha > 127 && this._sliceTop === -1) {
  6458. this._sliceTop = y;
  6459. continue;
  6460. }
  6461. if (alpha < 127 && this._sliceTop > -1) {
  6462. this._sliceBottom = y;
  6463. break;
  6464. }
  6465. }
  6466. };
  6467. Object.defineProperty(Image.prototype, "source", {
  6468. /**
  6469. * Gets or sets image source url
  6470. */
  6471. set: function (value) {
  6472. var _this = this;
  6473. if (this._source === value) {
  6474. return;
  6475. }
  6476. this._loaded = false;
  6477. this._source = value;
  6478. if (value) {
  6479. this._svgCheck(value);
  6480. }
  6481. this._domImage = document.createElement("img");
  6482. this._domImage.onload = function () {
  6483. _this._onImageLoaded();
  6484. };
  6485. if (value) {
  6486. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6487. this._domImage.src = value;
  6488. }
  6489. },
  6490. enumerable: true,
  6491. configurable: true
  6492. });
  6493. /**
  6494. * Checks for svg document with icon id present
  6495. */
  6496. Image.prototype._svgCheck = function (value) {
  6497. var _this = this;
  6498. if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6499. var svgsrc = value.split('#')[0];
  6500. var elemid = value.split('#')[1];
  6501. // check if object alr exist in document
  6502. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6503. if (svgExist) {
  6504. if (svgExist.contentDocument) {
  6505. // svg object alr exists
  6506. this._getSVGAttribs(svgExist, elemid);
  6507. }
  6508. else {
  6509. // wait for object to load
  6510. svgExist.addEventListener("load", function () {
  6511. _this._getSVGAttribs(svgExist, elemid);
  6512. });
  6513. }
  6514. }
  6515. else {
  6516. // create document object
  6517. var svgImage = document.createElement("object");
  6518. svgImage.data = svgsrc;
  6519. svgImage.type = "image/svg+xml";
  6520. svgImage.width = "0%";
  6521. svgImage.height = "0%";
  6522. document.body.appendChild(svgImage);
  6523. // when the object has loaded, get the element attribs
  6524. svgImage.onload = function () {
  6525. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6526. if (svgobj) {
  6527. _this._getSVGAttribs(svgobj, elemid);
  6528. }
  6529. };
  6530. }
  6531. }
  6532. };
  6533. /**
  6534. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6535. * given external svg file and icon id
  6536. */
  6537. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6538. var svgDoc = svgsrc.contentDocument;
  6539. // get viewbox width and height, get svg document width and height in px
  6540. if (svgDoc && svgDoc.documentElement) {
  6541. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6542. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6543. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6544. // get element bbox and matrix transform
  6545. var elem = svgDoc.getElementById(elemid);
  6546. if (elem instanceof SVGElement && vb && docwidth && docheight) {
  6547. var vb_width = Number(vb.split(" ")[2]);
  6548. var vb_height = Number(vb.split(" ")[3]);
  6549. var elem_bbox = elem.getBBox();
  6550. var elem_matrix_a = 1;
  6551. var elem_matrix_d = 1;
  6552. var elem_matrix_e = 0;
  6553. var elem_matrix_f = 0;
  6554. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6555. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6556. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6557. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6558. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6559. }
  6560. // compute source coordinates and dimensions
  6561. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6562. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6563. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6564. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6565. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6566. }
  6567. }
  6568. };
  6569. Object.defineProperty(Image.prototype, "cellWidth", {
  6570. /**
  6571. * Gets or sets the cell width to use when animation sheet is enabled
  6572. * @see http://doc.babylonjs.com/how_to/gui#image
  6573. */
  6574. get: function () {
  6575. return this._cellWidth;
  6576. },
  6577. set: function (value) {
  6578. if (this._cellWidth === value) {
  6579. return;
  6580. }
  6581. this._cellWidth = value;
  6582. this._markAsDirty();
  6583. },
  6584. enumerable: true,
  6585. configurable: true
  6586. });
  6587. Object.defineProperty(Image.prototype, "cellHeight", {
  6588. /**
  6589. * Gets or sets the cell height to use when animation sheet is enabled
  6590. * @see http://doc.babylonjs.com/how_to/gui#image
  6591. */
  6592. get: function () {
  6593. return this._cellHeight;
  6594. },
  6595. set: function (value) {
  6596. if (this._cellHeight === value) {
  6597. return;
  6598. }
  6599. this._cellHeight = value;
  6600. this._markAsDirty();
  6601. },
  6602. enumerable: true,
  6603. configurable: true
  6604. });
  6605. Object.defineProperty(Image.prototype, "cellId", {
  6606. /**
  6607. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6608. * @see http://doc.babylonjs.com/how_to/gui#image
  6609. */
  6610. get: function () {
  6611. return this._cellId;
  6612. },
  6613. set: function (value) {
  6614. if (this._cellId === value) {
  6615. return;
  6616. }
  6617. this._cellId = value;
  6618. this._markAsDirty();
  6619. },
  6620. enumerable: true,
  6621. configurable: true
  6622. });
  6623. /**
  6624. * Tests if a given coordinates belong to the current control
  6625. * @param x defines x coordinate to test
  6626. * @param y defines y coordinate to test
  6627. * @returns true if the coordinates are inside the control
  6628. */
  6629. Image.prototype.contains = function (x, y) {
  6630. if (!_super.prototype.contains.call(this, x, y)) {
  6631. return false;
  6632. }
  6633. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6634. return true;
  6635. }
  6636. var canvas = Image._WorkingCanvas;
  6637. var context = canvas.getContext("2d");
  6638. var width = this._currentMeasure.width | 0;
  6639. var height = this._currentMeasure.height | 0;
  6640. var imageData = context.getImageData(0, 0, width, height).data;
  6641. x = (x - this._currentMeasure.left) | 0;
  6642. y = (y - this._currentMeasure.top) | 0;
  6643. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6644. return pickedPixel > 0;
  6645. };
  6646. Image.prototype._getTypeName = function () {
  6647. return "Image";
  6648. };
  6649. /** Force the control to synchronize with its content */
  6650. Image.prototype.synchronizeSizeWithContent = function () {
  6651. if (!this._loaded) {
  6652. return;
  6653. }
  6654. this.width = this._domImage.width + "px";
  6655. this.height = this._domImage.height + "px";
  6656. };
  6657. Image.prototype._processMeasures = function (parentMeasure, context) {
  6658. if (this._loaded) {
  6659. switch (this._stretch) {
  6660. case Image.STRETCH_NONE:
  6661. break;
  6662. case Image.STRETCH_FILL:
  6663. break;
  6664. case Image.STRETCH_UNIFORM:
  6665. break;
  6666. case Image.STRETCH_NINE_PATCH:
  6667. break;
  6668. case Image.STRETCH_EXTEND:
  6669. if (this._autoScale) {
  6670. this.synchronizeSizeWithContent();
  6671. }
  6672. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6673. this.parent.adaptWidthToChildren = true;
  6674. this.parent.adaptHeightToChildren = true;
  6675. }
  6676. break;
  6677. }
  6678. }
  6679. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6680. };
  6681. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6682. if (!this._detectPointerOnOpaqueOnly) {
  6683. return;
  6684. }
  6685. if (!Image._WorkingCanvas) {
  6686. Image._WorkingCanvas = document.createElement('canvas');
  6687. }
  6688. var canvas = Image._WorkingCanvas;
  6689. var width = this._currentMeasure.width;
  6690. var height = this._currentMeasure.height;
  6691. var context = canvas.getContext("2d");
  6692. canvas.width = width;
  6693. canvas.height = height;
  6694. context.clearRect(0, 0, width, height);
  6695. };
  6696. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6697. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6698. if (!this._detectPointerOnOpaqueOnly) {
  6699. return;
  6700. }
  6701. var canvas = Image._WorkingCanvas;
  6702. context = canvas.getContext("2d");
  6703. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6704. };
  6705. Image.prototype._draw = function (context) {
  6706. context.save();
  6707. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6708. context.shadowColor = this.shadowColor;
  6709. context.shadowBlur = this.shadowBlur;
  6710. context.shadowOffsetX = this.shadowOffsetX;
  6711. context.shadowOffsetY = this.shadowOffsetY;
  6712. }
  6713. var x, y, width, height;
  6714. if (this.cellId == -1) {
  6715. x = this._sourceLeft;
  6716. y = this._sourceTop;
  6717. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6718. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6719. }
  6720. else {
  6721. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6722. var column = (this.cellId / rowCount) >> 0;
  6723. var row = this.cellId % rowCount;
  6724. x = this.cellWidth * row;
  6725. y = this.cellHeight * column;
  6726. width = this.cellWidth;
  6727. height = this.cellHeight;
  6728. }
  6729. this._prepareWorkingCanvasForOpaqueDetection();
  6730. this._applyStates(context);
  6731. if (this._loaded) {
  6732. switch (this._stretch) {
  6733. case Image.STRETCH_NONE:
  6734. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6735. break;
  6736. case Image.STRETCH_FILL:
  6737. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6738. break;
  6739. case Image.STRETCH_UNIFORM:
  6740. var hRatio = this._currentMeasure.width / width;
  6741. var vRatio = this._currentMeasure.height / height;
  6742. var ratio = Math.min(hRatio, vRatio);
  6743. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6744. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6745. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6746. break;
  6747. case Image.STRETCH_EXTEND:
  6748. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6749. break;
  6750. case Image.STRETCH_NINE_PATCH:
  6751. this._renderNinePatch(context);
  6752. break;
  6753. }
  6754. }
  6755. context.restore();
  6756. };
  6757. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6758. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6759. };
  6760. Image.prototype._renderNinePatch = function (context) {
  6761. var height = this._imageHeight;
  6762. var leftWidth = this._sliceLeft;
  6763. var topHeight = this._sliceTop;
  6764. var bottomHeight = this._imageHeight - this._sliceBottom;
  6765. var rightWidth = this._imageWidth - this._sliceRight;
  6766. var left = 0;
  6767. var top = 0;
  6768. if (this._populateNinePatchSlicesFromImage) {
  6769. left = 1;
  6770. top = 1;
  6771. height -= 2;
  6772. leftWidth -= 1;
  6773. topHeight -= 1;
  6774. bottomHeight -= 1;
  6775. rightWidth -= 1;
  6776. }
  6777. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6778. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6779. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6780. // Corners
  6781. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6782. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6783. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6784. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6785. // Center
  6786. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6787. // Borders
  6788. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6789. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6790. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6791. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6792. };
  6793. Image.prototype.dispose = function () {
  6794. _super.prototype.dispose.call(this);
  6795. this.onImageLoadedObservable.clear();
  6796. this.onSVGAttributesComputedObservable.clear();
  6797. };
  6798. Image._WorkingCanvas = null;
  6799. // Static
  6800. /** STRETCH_NONE */
  6801. Image.STRETCH_NONE = 0;
  6802. /** STRETCH_FILL */
  6803. Image.STRETCH_FILL = 1;
  6804. /** STRETCH_UNIFORM */
  6805. Image.STRETCH_UNIFORM = 2;
  6806. /** STRETCH_EXTEND */
  6807. Image.STRETCH_EXTEND = 3;
  6808. /** NINE_PATCH */
  6809. Image.STRETCH_NINE_PATCH = 4;
  6810. return Image;
  6811. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6812. /***/ }),
  6813. /***/ "./2D/controls/index.ts":
  6814. /*!******************************!*\
  6815. !*** ./2D/controls/index.ts ***!
  6816. \******************************/
  6817. /*! 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, ScrollBar, name */
  6818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6819. "use strict";
  6820. __webpack_require__.r(__webpack_exports__);
  6821. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6823. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6825. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6827. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6829. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6831. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6833. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6835. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6837. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6839. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6841. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6843. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6845. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6847. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6849. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6855. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6857. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6860. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6863. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6865. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6867. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6869. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6871. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6873. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6875. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6877. /***/ }),
  6878. /***/ "./2D/controls/inputPassword.ts":
  6879. /*!**************************************!*\
  6880. !*** ./2D/controls/inputPassword.ts ***!
  6881. \**************************************/
  6882. /*! exports provided: InputPassword */
  6883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6884. "use strict";
  6885. __webpack_require__.r(__webpack_exports__);
  6886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6887. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6888. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6889. /**
  6890. * Class used to create a password control
  6891. */
  6892. var InputPassword = /** @class */ (function (_super) {
  6893. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6894. function InputPassword() {
  6895. return _super !== null && _super.apply(this, arguments) || this;
  6896. }
  6897. InputPassword.prototype._beforeRenderText = function (text) {
  6898. var txt = "";
  6899. for (var i = 0; i < text.length; i++) {
  6900. txt += "\u2022";
  6901. }
  6902. return txt;
  6903. };
  6904. return InputPassword;
  6905. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6906. /***/ }),
  6907. /***/ "./2D/controls/inputText.ts":
  6908. /*!**********************************!*\
  6909. !*** ./2D/controls/inputText.ts ***!
  6910. \**********************************/
  6911. /*! exports provided: InputText */
  6912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6913. "use strict";
  6914. __webpack_require__.r(__webpack_exports__);
  6915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6917. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6918. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6919. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6920. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6921. /**
  6922. * Class used to create input text control
  6923. */
  6924. var InputText = /** @class */ (function (_super) {
  6925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6926. /**
  6927. * Creates a new InputText
  6928. * @param name defines the control name
  6929. * @param text defines the text of the control
  6930. */
  6931. function InputText(name, text) {
  6932. if (text === void 0) { text = ""; }
  6933. var _this = _super.call(this, name) || this;
  6934. _this.name = name;
  6935. _this._text = "";
  6936. _this._placeholderText = "";
  6937. _this._background = "#222222";
  6938. _this._focusedBackground = "#000000";
  6939. _this._focusedColor = "white";
  6940. _this._placeholderColor = "gray";
  6941. _this._thickness = 1;
  6942. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6943. _this._autoStretchWidth = true;
  6944. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6945. _this._isFocused = false;
  6946. _this._blinkIsEven = false;
  6947. _this._cursorOffset = 0;
  6948. _this._deadKey = false;
  6949. _this._addKey = true;
  6950. _this._currentKey = "";
  6951. _this._isTextHighlightOn = false;
  6952. _this._textHighlightColor = "#d5e0ff";
  6953. _this._highligherOpacity = 0.4;
  6954. _this._highlightedText = "";
  6955. _this._startHighlightIndex = 0;
  6956. _this._endHighlightIndex = 0;
  6957. _this._cursorIndex = -1;
  6958. _this._onFocusSelectAll = false;
  6959. _this._isPointerDown = false;
  6960. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6961. _this.promptMessage = "Please enter text:";
  6962. /** Force disable prompt on mobile device */
  6963. _this.disableMobilePrompt = false;
  6964. /** Observable raised when the text changes */
  6965. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6966. /** Observable raised just before an entered character is to be added */
  6967. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6968. /** Observable raised when the control gets the focus */
  6969. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6970. /** Observable raised when the control loses the focus */
  6971. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6972. /**Observable raised when the text is highlighted */
  6973. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6974. /**Observable raised when copy event is triggered */
  6975. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6976. /** Observable raised when cut event is triggered */
  6977. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6978. /** Observable raised when paste event is triggered */
  6979. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6980. /** Observable raised when a key event was processed */
  6981. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6982. _this.text = text;
  6983. _this.isPointerBlocker = true;
  6984. return _this;
  6985. }
  6986. Object.defineProperty(InputText.prototype, "maxWidth", {
  6987. /** Gets or sets the maximum width allowed by the control */
  6988. get: function () {
  6989. return this._maxWidth.toString(this._host);
  6990. },
  6991. set: function (value) {
  6992. if (this._maxWidth.toString(this._host) === value) {
  6993. return;
  6994. }
  6995. if (this._maxWidth.fromString(value)) {
  6996. this._markAsDirty();
  6997. }
  6998. },
  6999. enumerable: true,
  7000. configurable: true
  7001. });
  7002. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7003. /** Gets the maximum width allowed by the control in pixels */
  7004. get: function () {
  7005. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7006. },
  7007. enumerable: true,
  7008. configurable: true
  7009. });
  7010. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7011. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7012. get: function () {
  7013. return this._highligherOpacity;
  7014. },
  7015. set: function (value) {
  7016. if (this._highligherOpacity === value) {
  7017. return;
  7018. }
  7019. this._highligherOpacity = value;
  7020. this._markAsDirty();
  7021. },
  7022. enumerable: true,
  7023. configurable: true
  7024. });
  7025. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7026. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7027. get: function () {
  7028. return this._onFocusSelectAll;
  7029. },
  7030. set: function (value) {
  7031. if (this._onFocusSelectAll === value) {
  7032. return;
  7033. }
  7034. this._onFocusSelectAll = value;
  7035. this._markAsDirty();
  7036. },
  7037. enumerable: true,
  7038. configurable: true
  7039. });
  7040. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7041. /** Gets or sets the text hightlight color */
  7042. get: function () {
  7043. return this._textHighlightColor;
  7044. },
  7045. set: function (value) {
  7046. if (this._textHighlightColor === value) {
  7047. return;
  7048. }
  7049. this._textHighlightColor = value;
  7050. this._markAsDirty();
  7051. },
  7052. enumerable: true,
  7053. configurable: true
  7054. });
  7055. Object.defineProperty(InputText.prototype, "margin", {
  7056. /** Gets or sets control margin */
  7057. get: function () {
  7058. return this._margin.toString(this._host);
  7059. },
  7060. set: function (value) {
  7061. if (this._margin.toString(this._host) === value) {
  7062. return;
  7063. }
  7064. if (this._margin.fromString(value)) {
  7065. this._markAsDirty();
  7066. }
  7067. },
  7068. enumerable: true,
  7069. configurable: true
  7070. });
  7071. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7072. /** Gets control margin in pixels */
  7073. get: function () {
  7074. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7080. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7081. get: function () {
  7082. return this._autoStretchWidth;
  7083. },
  7084. set: function (value) {
  7085. if (this._autoStretchWidth === value) {
  7086. return;
  7087. }
  7088. this._autoStretchWidth = value;
  7089. this._markAsDirty();
  7090. },
  7091. enumerable: true,
  7092. configurable: true
  7093. });
  7094. Object.defineProperty(InputText.prototype, "thickness", {
  7095. /** Gets or sets border thickness */
  7096. get: function () {
  7097. return this._thickness;
  7098. },
  7099. set: function (value) {
  7100. if (this._thickness === value) {
  7101. return;
  7102. }
  7103. this._thickness = value;
  7104. this._markAsDirty();
  7105. },
  7106. enumerable: true,
  7107. configurable: true
  7108. });
  7109. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7110. /** Gets or sets the background color when focused */
  7111. get: function () {
  7112. return this._focusedBackground;
  7113. },
  7114. set: function (value) {
  7115. if (this._focusedBackground === value) {
  7116. return;
  7117. }
  7118. this._focusedBackground = value;
  7119. this._markAsDirty();
  7120. },
  7121. enumerable: true,
  7122. configurable: true
  7123. });
  7124. Object.defineProperty(InputText.prototype, "focusedColor", {
  7125. /** Gets or sets the background color when focused */
  7126. get: function () {
  7127. return this._focusedColor;
  7128. },
  7129. set: function (value) {
  7130. if (this._focusedColor === value) {
  7131. return;
  7132. }
  7133. this._focusedColor = value;
  7134. this._markAsDirty();
  7135. },
  7136. enumerable: true,
  7137. configurable: true
  7138. });
  7139. Object.defineProperty(InputText.prototype, "background", {
  7140. /** Gets or sets the background color */
  7141. get: function () {
  7142. return this._background;
  7143. },
  7144. set: function (value) {
  7145. if (this._background === value) {
  7146. return;
  7147. }
  7148. this._background = value;
  7149. this._markAsDirty();
  7150. },
  7151. enumerable: true,
  7152. configurable: true
  7153. });
  7154. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7155. /** Gets or sets the placeholder color */
  7156. get: function () {
  7157. return this._placeholderColor;
  7158. },
  7159. set: function (value) {
  7160. if (this._placeholderColor === value) {
  7161. return;
  7162. }
  7163. this._placeholderColor = value;
  7164. this._markAsDirty();
  7165. },
  7166. enumerable: true,
  7167. configurable: true
  7168. });
  7169. Object.defineProperty(InputText.prototype, "placeholderText", {
  7170. /** Gets or sets the text displayed when the control is empty */
  7171. get: function () {
  7172. return this._placeholderText;
  7173. },
  7174. set: function (value) {
  7175. if (this._placeholderText === value) {
  7176. return;
  7177. }
  7178. this._placeholderText = value;
  7179. this._markAsDirty();
  7180. },
  7181. enumerable: true,
  7182. configurable: true
  7183. });
  7184. Object.defineProperty(InputText.prototype, "deadKey", {
  7185. /** Gets or sets the dead key flag */
  7186. get: function () {
  7187. return this._deadKey;
  7188. },
  7189. set: function (flag) {
  7190. this._deadKey = flag;
  7191. },
  7192. enumerable: true,
  7193. configurable: true
  7194. });
  7195. Object.defineProperty(InputText.prototype, "highlightedText", {
  7196. /** Gets or sets the highlight text */
  7197. get: function () {
  7198. return this._highlightedText;
  7199. },
  7200. set: function (text) {
  7201. if (this._highlightedText === text) {
  7202. return;
  7203. }
  7204. this._highlightedText = text;
  7205. this._markAsDirty();
  7206. },
  7207. enumerable: true,
  7208. configurable: true
  7209. });
  7210. Object.defineProperty(InputText.prototype, "addKey", {
  7211. /** Gets or sets if the current key should be added */
  7212. get: function () {
  7213. return this._addKey;
  7214. },
  7215. set: function (flag) {
  7216. this._addKey = flag;
  7217. },
  7218. enumerable: true,
  7219. configurable: true
  7220. });
  7221. Object.defineProperty(InputText.prototype, "currentKey", {
  7222. /** Gets or sets the value of the current key being entered */
  7223. get: function () {
  7224. return this._currentKey;
  7225. },
  7226. set: function (key) {
  7227. this._currentKey = key;
  7228. },
  7229. enumerable: true,
  7230. configurable: true
  7231. });
  7232. Object.defineProperty(InputText.prototype, "text", {
  7233. /** Gets or sets the text displayed in the control */
  7234. get: function () {
  7235. return this._text;
  7236. },
  7237. set: function (value) {
  7238. var valueAsString = value.toString(); // Forcing convertion
  7239. if (this._text === valueAsString) {
  7240. return;
  7241. }
  7242. this._text = valueAsString;
  7243. this._markAsDirty();
  7244. this.onTextChangedObservable.notifyObservers(this);
  7245. },
  7246. enumerable: true,
  7247. configurable: true
  7248. });
  7249. Object.defineProperty(InputText.prototype, "width", {
  7250. /** Gets or sets control width */
  7251. get: function () {
  7252. return this._width.toString(this._host);
  7253. },
  7254. set: function (value) {
  7255. if (this._width.toString(this._host) === value) {
  7256. return;
  7257. }
  7258. if (this._width.fromString(value)) {
  7259. this._markAsDirty();
  7260. }
  7261. this.autoStretchWidth = false;
  7262. },
  7263. enumerable: true,
  7264. configurable: true
  7265. });
  7266. /** @hidden */
  7267. InputText.prototype.onBlur = function () {
  7268. this._isFocused = false;
  7269. this._scrollLeft = null;
  7270. this._cursorOffset = 0;
  7271. clearTimeout(this._blinkTimeout);
  7272. this._markAsDirty();
  7273. this.onBlurObservable.notifyObservers(this);
  7274. this._host.unRegisterClipboardEvents();
  7275. if (this._onClipboardObserver) {
  7276. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7277. }
  7278. var scene = this._host.getScene();
  7279. if (this._onPointerDblTapObserver && scene) {
  7280. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7281. }
  7282. };
  7283. /** @hidden */
  7284. InputText.prototype.onFocus = function () {
  7285. var _this = this;
  7286. if (!this._isEnabled) {
  7287. return;
  7288. }
  7289. this._scrollLeft = null;
  7290. this._isFocused = true;
  7291. this._blinkIsEven = false;
  7292. this._cursorOffset = 0;
  7293. this._markAsDirty();
  7294. this.onFocusObservable.notifyObservers(this);
  7295. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7296. var value = prompt(this.promptMessage);
  7297. if (value !== null) {
  7298. this.text = value;
  7299. }
  7300. this._host.focusedControl = null;
  7301. return;
  7302. }
  7303. this._host.registerClipboardEvents();
  7304. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7305. // process clipboard event, can be configured.
  7306. switch (clipboardInfo.type) {
  7307. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7308. _this._onCopyText(clipboardInfo.event);
  7309. _this.onTextCopyObservable.notifyObservers(_this);
  7310. break;
  7311. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7312. _this._onCutText(clipboardInfo.event);
  7313. _this.onTextCutObservable.notifyObservers(_this);
  7314. break;
  7315. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7316. _this._onPasteText(clipboardInfo.event);
  7317. _this.onTextPasteObservable.notifyObservers(_this);
  7318. break;
  7319. default: return;
  7320. }
  7321. });
  7322. var scene = this._host.getScene();
  7323. if (scene) {
  7324. //register the pointer double tap event
  7325. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7326. if (!_this._isFocused) {
  7327. return;
  7328. }
  7329. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7330. _this._processDblClick(pointerInfo);
  7331. }
  7332. });
  7333. }
  7334. if (this._onFocusSelectAll) {
  7335. this._selectAllText();
  7336. }
  7337. };
  7338. InputText.prototype._getTypeName = function () {
  7339. return "InputText";
  7340. };
  7341. /**
  7342. * Function called to get the list of controls that should not steal the focus from this control
  7343. * @returns an array of controls
  7344. */
  7345. InputText.prototype.keepsFocusWith = function () {
  7346. if (!this._connectedVirtualKeyboard) {
  7347. return null;
  7348. }
  7349. return [this._connectedVirtualKeyboard];
  7350. };
  7351. /** @hidden */
  7352. InputText.prototype.processKey = function (keyCode, key, evt) {
  7353. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7354. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7355. return;
  7356. }
  7357. //select all
  7358. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7359. this._selectAllText();
  7360. evt.preventDefault();
  7361. return;
  7362. }
  7363. // Specific cases
  7364. switch (keyCode) {
  7365. case 32: //SPACE
  7366. key = " "; //ie11 key for space is "Spacebar"
  7367. break;
  7368. case 191: //SLASH
  7369. if (evt) {
  7370. evt.preventDefault();
  7371. }
  7372. break;
  7373. case 8: // BACKSPACE
  7374. if (this._text && this._text.length > 0) {
  7375. //delete the highlighted text
  7376. if (this._isTextHighlightOn) {
  7377. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7378. this._isTextHighlightOn = false;
  7379. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7380. this._blinkIsEven = false;
  7381. if (evt) {
  7382. evt.preventDefault();
  7383. }
  7384. return;
  7385. }
  7386. //delete single character
  7387. if (this._cursorOffset === 0) {
  7388. this.text = this._text.substr(0, this._text.length - 1);
  7389. }
  7390. else {
  7391. var deletePosition = this._text.length - this._cursorOffset;
  7392. if (deletePosition > 0) {
  7393. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7394. }
  7395. }
  7396. }
  7397. if (evt) {
  7398. evt.preventDefault();
  7399. }
  7400. return;
  7401. case 46: // DELETE
  7402. if (this._isTextHighlightOn) {
  7403. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7404. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7405. while (decrementor > 0 && this._cursorOffset > 0) {
  7406. this._cursorOffset--;
  7407. }
  7408. this._isTextHighlightOn = false;
  7409. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7410. if (evt) {
  7411. evt.preventDefault();
  7412. }
  7413. return;
  7414. }
  7415. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7416. var deletePosition = this._text.length - this._cursorOffset;
  7417. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7418. this._cursorOffset--;
  7419. }
  7420. if (evt) {
  7421. evt.preventDefault();
  7422. }
  7423. return;
  7424. case 13: // RETURN
  7425. this._host.focusedControl = null;
  7426. this._isTextHighlightOn = false;
  7427. return;
  7428. case 35: // END
  7429. this._cursorOffset = 0;
  7430. this._blinkIsEven = false;
  7431. this._isTextHighlightOn = false;
  7432. this._markAsDirty();
  7433. return;
  7434. case 36: // HOME
  7435. this._cursorOffset = this._text.length;
  7436. this._blinkIsEven = false;
  7437. this._isTextHighlightOn = false;
  7438. this._markAsDirty();
  7439. return;
  7440. case 37: // LEFT
  7441. this._cursorOffset++;
  7442. if (this._cursorOffset > this._text.length) {
  7443. this._cursorOffset = this._text.length;
  7444. }
  7445. if (evt && evt.shiftKey) {
  7446. // update the cursor
  7447. this._blinkIsEven = false;
  7448. // shift + ctrl/cmd + <-
  7449. if (evt.ctrlKey || evt.metaKey) {
  7450. if (!this._isTextHighlightOn) {
  7451. if (this._text.length === this._cursorOffset) {
  7452. return;
  7453. }
  7454. else {
  7455. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7456. }
  7457. }
  7458. this._startHighlightIndex = 0;
  7459. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7460. this._cursorOffset = this._text.length;
  7461. this._isTextHighlightOn = true;
  7462. this._markAsDirty();
  7463. return;
  7464. }
  7465. //store the starting point
  7466. if (!this._isTextHighlightOn) {
  7467. this._isTextHighlightOn = true;
  7468. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7469. }
  7470. //if text is already highlighted
  7471. else if (this._cursorIndex === -1) {
  7472. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7473. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7474. }
  7475. //set the highlight indexes
  7476. if (this._cursorIndex < this._cursorOffset) {
  7477. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7478. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7479. }
  7480. else if (this._cursorIndex > this._cursorOffset) {
  7481. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7482. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7483. }
  7484. else {
  7485. this._isTextHighlightOn = false;
  7486. }
  7487. this._markAsDirty();
  7488. return;
  7489. }
  7490. if (this._isTextHighlightOn) {
  7491. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7492. this._isTextHighlightOn = false;
  7493. }
  7494. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7495. this._cursorOffset = this.text.length;
  7496. evt.preventDefault();
  7497. }
  7498. this._blinkIsEven = false;
  7499. this._isTextHighlightOn = false;
  7500. this._cursorIndex = -1;
  7501. this._markAsDirty();
  7502. return;
  7503. case 39: // RIGHT
  7504. this._cursorOffset--;
  7505. if (this._cursorOffset < 0) {
  7506. this._cursorOffset = 0;
  7507. }
  7508. if (evt && evt.shiftKey) {
  7509. //update the cursor
  7510. this._blinkIsEven = false;
  7511. //shift + ctrl/cmd + ->
  7512. if (evt.ctrlKey || evt.metaKey) {
  7513. if (!this._isTextHighlightOn) {
  7514. if (this._cursorOffset === 0) {
  7515. return;
  7516. }
  7517. else {
  7518. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7519. }
  7520. }
  7521. this._endHighlightIndex = this._text.length;
  7522. this._isTextHighlightOn = true;
  7523. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7524. this._cursorOffset = 0;
  7525. this._markAsDirty();
  7526. return;
  7527. }
  7528. if (!this._isTextHighlightOn) {
  7529. this._isTextHighlightOn = true;
  7530. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7531. }
  7532. //if text is already highlighted
  7533. else if (this._cursorIndex === -1) {
  7534. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7535. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7536. }
  7537. //set the highlight indexes
  7538. if (this._cursorIndex < this._cursorOffset) {
  7539. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7540. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7541. }
  7542. else if (this._cursorIndex > this._cursorOffset) {
  7543. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7544. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7545. }
  7546. else {
  7547. this._isTextHighlightOn = false;
  7548. }
  7549. this._markAsDirty();
  7550. return;
  7551. }
  7552. if (this._isTextHighlightOn) {
  7553. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7554. this._isTextHighlightOn = false;
  7555. }
  7556. //ctr + ->
  7557. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7558. this._cursorOffset = 0;
  7559. evt.preventDefault();
  7560. }
  7561. this._blinkIsEven = false;
  7562. this._isTextHighlightOn = false;
  7563. this._cursorIndex = -1;
  7564. this._markAsDirty();
  7565. return;
  7566. case 222: // Dead
  7567. if (evt) {
  7568. evt.preventDefault();
  7569. }
  7570. this._cursorIndex = -1;
  7571. this.deadKey = true;
  7572. break;
  7573. }
  7574. // Printable characters
  7575. if (key &&
  7576. ((keyCode === -1) || // Direct access
  7577. (keyCode === 32) || // Space
  7578. (keyCode > 47 && keyCode < 64) || // Numbers
  7579. (keyCode > 64 && keyCode < 91) || // Letters
  7580. (keyCode > 159 && keyCode < 193) || // Special characters
  7581. (keyCode > 218 && keyCode < 223) || // Special characters
  7582. (keyCode > 95 && keyCode < 112))) { // Numpad
  7583. this._currentKey = key;
  7584. this.onBeforeKeyAddObservable.notifyObservers(this);
  7585. key = this._currentKey;
  7586. if (this._addKey) {
  7587. if (this._isTextHighlightOn) {
  7588. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7589. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7590. this._isTextHighlightOn = false;
  7591. this._blinkIsEven = false;
  7592. this._markAsDirty();
  7593. }
  7594. else if (this._cursorOffset === 0) {
  7595. this.text += key;
  7596. }
  7597. else {
  7598. var insertPosition = this._text.length - this._cursorOffset;
  7599. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7600. }
  7601. }
  7602. }
  7603. };
  7604. /** @hidden */
  7605. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7606. //update the cursor
  7607. this._blinkIsEven = false;
  7608. if (this._cursorIndex === -1) {
  7609. this._cursorIndex = offset;
  7610. }
  7611. else {
  7612. if (this._cursorIndex < this._cursorOffset) {
  7613. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7614. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7615. }
  7616. else if (this._cursorIndex > this._cursorOffset) {
  7617. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7618. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7619. }
  7620. else {
  7621. this._isTextHighlightOn = false;
  7622. this._markAsDirty();
  7623. return;
  7624. }
  7625. }
  7626. this._isTextHighlightOn = true;
  7627. this._markAsDirty();
  7628. };
  7629. /** @hidden */
  7630. InputText.prototype._processDblClick = function (evt) {
  7631. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7632. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7633. this._endHighlightIndex = this._startHighlightIndex;
  7634. var rWord = /\w+/g, moveLeft, moveRight;
  7635. do {
  7636. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7637. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7638. } while (moveLeft || moveRight);
  7639. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7640. this.onTextHighlightObservable.notifyObservers(this);
  7641. this._isTextHighlightOn = true;
  7642. this._clickedCoordinate = null;
  7643. this._blinkIsEven = true;
  7644. this._cursorIndex = -1;
  7645. this._markAsDirty();
  7646. };
  7647. /** @hidden */
  7648. InputText.prototype._selectAllText = function () {
  7649. this._blinkIsEven = true;
  7650. this._isTextHighlightOn = true;
  7651. this._startHighlightIndex = 0;
  7652. this._endHighlightIndex = this._text.length;
  7653. this._cursorOffset = this._text.length;
  7654. this._cursorIndex = -1;
  7655. this._markAsDirty();
  7656. };
  7657. /**
  7658. * Handles the keyboard event
  7659. * @param evt Defines the KeyboardEvent
  7660. */
  7661. InputText.prototype.processKeyboard = function (evt) {
  7662. // process pressed key
  7663. this.processKey(evt.keyCode, evt.key, evt);
  7664. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7665. };
  7666. /** @hidden */
  7667. InputText.prototype._onCopyText = function (ev) {
  7668. this._isTextHighlightOn = false;
  7669. //when write permission to clipbaord data is denied
  7670. try {
  7671. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7672. }
  7673. catch (_a) { } //pass
  7674. this._host.clipboardData = this._highlightedText;
  7675. };
  7676. /** @hidden */
  7677. InputText.prototype._onCutText = function (ev) {
  7678. if (!this._highlightedText) {
  7679. return;
  7680. }
  7681. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7682. this._isTextHighlightOn = false;
  7683. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7684. //when write permission to clipbaord data is denied
  7685. try {
  7686. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7687. }
  7688. catch (_a) { } //pass
  7689. this._host.clipboardData = this._highlightedText;
  7690. this._highlightedText = "";
  7691. };
  7692. /** @hidden */
  7693. InputText.prototype._onPasteText = function (ev) {
  7694. var data = "";
  7695. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7696. data = ev.clipboardData.getData("text/plain");
  7697. }
  7698. else {
  7699. //get the cached data; returns blank string by default
  7700. data = this._host.clipboardData;
  7701. }
  7702. var insertPosition = this._text.length - this._cursorOffset;
  7703. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7704. };
  7705. InputText.prototype._draw = function (context) {
  7706. var _this = this;
  7707. context.save();
  7708. this._applyStates(context);
  7709. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7710. context.shadowColor = this.shadowColor;
  7711. context.shadowBlur = this.shadowBlur;
  7712. context.shadowOffsetX = this.shadowOffsetX;
  7713. context.shadowOffsetY = this.shadowOffsetY;
  7714. }
  7715. // Background
  7716. if (this._isFocused) {
  7717. if (this._focusedBackground) {
  7718. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7719. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7720. }
  7721. }
  7722. else if (this._background) {
  7723. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7724. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7725. }
  7726. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7727. context.shadowBlur = 0;
  7728. context.shadowOffsetX = 0;
  7729. context.shadowOffsetY = 0;
  7730. }
  7731. if (!this._fontOffset) {
  7732. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7733. }
  7734. // Text
  7735. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7736. if (this.color) {
  7737. context.fillStyle = this.color;
  7738. }
  7739. var text = this._beforeRenderText(this._text);
  7740. if (!this._isFocused && !this._text && this._placeholderText) {
  7741. text = this._placeholderText;
  7742. if (this._placeholderColor) {
  7743. context.fillStyle = this._placeholderColor;
  7744. }
  7745. }
  7746. this._textWidth = context.measureText(text).width;
  7747. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7748. if (this._autoStretchWidth) {
  7749. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7750. }
  7751. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7752. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7753. context.save();
  7754. context.beginPath();
  7755. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7756. context.clip();
  7757. if (this._isFocused && this._textWidth > availableWidth) {
  7758. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7759. if (!this._scrollLeft) {
  7760. this._scrollLeft = textLeft;
  7761. }
  7762. }
  7763. else {
  7764. this._scrollLeft = clipTextLeft;
  7765. }
  7766. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7767. // Cursor
  7768. if (this._isFocused) {
  7769. // Need to move cursor
  7770. if (this._clickedCoordinate) {
  7771. var rightPosition = this._scrollLeft + this._textWidth;
  7772. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7773. var currentSize = 0;
  7774. this._cursorOffset = 0;
  7775. var previousDist = 0;
  7776. do {
  7777. if (this._cursorOffset) {
  7778. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7779. }
  7780. this._cursorOffset++;
  7781. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7782. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7783. // Find closest move
  7784. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7785. this._cursorOffset--;
  7786. }
  7787. this._blinkIsEven = false;
  7788. this._clickedCoordinate = null;
  7789. }
  7790. // Render cursor
  7791. if (!this._blinkIsEven) {
  7792. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7793. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7794. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7795. if (cursorLeft < clipTextLeft) {
  7796. this._scrollLeft += (clipTextLeft - cursorLeft);
  7797. cursorLeft = clipTextLeft;
  7798. this._markAsDirty();
  7799. }
  7800. else if (cursorLeft > clipTextLeft + availableWidth) {
  7801. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7802. cursorLeft = clipTextLeft + availableWidth;
  7803. this._markAsDirty();
  7804. }
  7805. if (!this._isTextHighlightOn) {
  7806. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7807. }
  7808. }
  7809. clearTimeout(this._blinkTimeout);
  7810. this._blinkTimeout = setTimeout(function () {
  7811. _this._blinkIsEven = !_this._blinkIsEven;
  7812. _this._markAsDirty();
  7813. }, 500);
  7814. //show the highlighted text
  7815. if (this._isTextHighlightOn) {
  7816. clearTimeout(this._blinkTimeout);
  7817. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7818. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7819. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7820. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7821. if (highlightCursorLeft < clipTextLeft) {
  7822. width = width - (clipTextLeft - highlightCursorLeft);
  7823. if (!width) {
  7824. // when using left arrow on text.length > availableWidth;
  7825. // assigns the width of the first letter after clipTextLeft
  7826. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7827. }
  7828. highlightCursorLeft = clipTextLeft;
  7829. }
  7830. //for transparancy
  7831. context.globalAlpha = this._highligherOpacity;
  7832. context.fillStyle = this._textHighlightColor;
  7833. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7834. context.globalAlpha = 1.0;
  7835. }
  7836. }
  7837. context.restore();
  7838. // Border
  7839. if (this._thickness) {
  7840. if (this._isFocused) {
  7841. if (this.focusedColor) {
  7842. context.strokeStyle = this.focusedColor;
  7843. }
  7844. }
  7845. else {
  7846. if (this.color) {
  7847. context.strokeStyle = this.color;
  7848. }
  7849. }
  7850. context.lineWidth = this._thickness;
  7851. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7852. }
  7853. context.restore();
  7854. };
  7855. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7856. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7857. return false;
  7858. }
  7859. this._clickedCoordinate = coordinates.x;
  7860. this._isTextHighlightOn = false;
  7861. this._highlightedText = "";
  7862. this._cursorIndex = -1;
  7863. this._isPointerDown = true;
  7864. this._host._capturingControl[pointerId] = this;
  7865. if (this._host.focusedControl === this) {
  7866. // Move cursor
  7867. clearTimeout(this._blinkTimeout);
  7868. this._markAsDirty();
  7869. return true;
  7870. }
  7871. if (!this._isEnabled) {
  7872. return false;
  7873. }
  7874. this._host.focusedControl = this;
  7875. return true;
  7876. };
  7877. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7878. if (this._host.focusedControl === this && this._isPointerDown) {
  7879. this._clickedCoordinate = coordinates.x;
  7880. this._markAsDirty();
  7881. this._updateValueFromCursorIndex(this._cursorOffset);
  7882. }
  7883. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7884. };
  7885. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7886. this._isPointerDown = false;
  7887. delete this._host._capturingControl[pointerId];
  7888. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7889. };
  7890. InputText.prototype._beforeRenderText = function (text) {
  7891. return text;
  7892. };
  7893. InputText.prototype.dispose = function () {
  7894. _super.prototype.dispose.call(this);
  7895. this.onBlurObservable.clear();
  7896. this.onFocusObservable.clear();
  7897. this.onTextChangedObservable.clear();
  7898. this.onTextCopyObservable.clear();
  7899. this.onTextCutObservable.clear();
  7900. this.onTextPasteObservable.clear();
  7901. this.onTextHighlightObservable.clear();
  7902. this.onKeyboardEventProcessedObservable.clear();
  7903. };
  7904. return InputText;
  7905. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7906. /***/ }),
  7907. /***/ "./2D/controls/line.ts":
  7908. /*!*****************************!*\
  7909. !*** ./2D/controls/line.ts ***!
  7910. \*****************************/
  7911. /*! exports provided: Line */
  7912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7913. "use strict";
  7914. __webpack_require__.r(__webpack_exports__);
  7915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7917. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7918. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7919. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7920. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7921. /** Class used to render 2D lines */
  7922. var Line = /** @class */ (function (_super) {
  7923. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7924. /**
  7925. * Creates a new Line
  7926. * @param name defines the control name
  7927. */
  7928. function Line(name) {
  7929. var _this = _super.call(this, name) || this;
  7930. _this.name = name;
  7931. _this._lineWidth = 1;
  7932. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7933. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7934. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7935. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7936. _this._dash = new Array();
  7937. _this.isHitTestVisible = false;
  7938. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7939. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7940. return _this;
  7941. }
  7942. Object.defineProperty(Line.prototype, "dash", {
  7943. /** Gets or sets the dash pattern */
  7944. get: function () {
  7945. return this._dash;
  7946. },
  7947. set: function (value) {
  7948. if (this._dash === value) {
  7949. return;
  7950. }
  7951. this._dash = value;
  7952. this._markAsDirty();
  7953. },
  7954. enumerable: true,
  7955. configurable: true
  7956. });
  7957. Object.defineProperty(Line.prototype, "connectedControl", {
  7958. /** Gets or sets the control connected with the line end */
  7959. get: function () {
  7960. return this._connectedControl;
  7961. },
  7962. set: function (value) {
  7963. var _this = this;
  7964. if (this._connectedControl === value) {
  7965. return;
  7966. }
  7967. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7968. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7969. this._connectedControlDirtyObserver = null;
  7970. }
  7971. if (value) {
  7972. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7973. }
  7974. this._connectedControl = value;
  7975. this._markAsDirty();
  7976. },
  7977. enumerable: true,
  7978. configurable: true
  7979. });
  7980. Object.defineProperty(Line.prototype, "x1", {
  7981. /** Gets or sets start coordinates on X axis */
  7982. get: function () {
  7983. return this._x1.toString(this._host);
  7984. },
  7985. set: function (value) {
  7986. if (this._x1.toString(this._host) === value) {
  7987. return;
  7988. }
  7989. if (this._x1.fromString(value)) {
  7990. this._markAsDirty();
  7991. }
  7992. },
  7993. enumerable: true,
  7994. configurable: true
  7995. });
  7996. Object.defineProperty(Line.prototype, "y1", {
  7997. /** Gets or sets start coordinates on Y axis */
  7998. get: function () {
  7999. return this._y1.toString(this._host);
  8000. },
  8001. set: function (value) {
  8002. if (this._y1.toString(this._host) === value) {
  8003. return;
  8004. }
  8005. if (this._y1.fromString(value)) {
  8006. this._markAsDirty();
  8007. }
  8008. },
  8009. enumerable: true,
  8010. configurable: true
  8011. });
  8012. Object.defineProperty(Line.prototype, "x2", {
  8013. /** Gets or sets end coordinates on X axis */
  8014. get: function () {
  8015. return this._x2.toString(this._host);
  8016. },
  8017. set: function (value) {
  8018. if (this._x2.toString(this._host) === value) {
  8019. return;
  8020. }
  8021. if (this._x2.fromString(value)) {
  8022. this._markAsDirty();
  8023. }
  8024. },
  8025. enumerable: true,
  8026. configurable: true
  8027. });
  8028. Object.defineProperty(Line.prototype, "y2", {
  8029. /** Gets or sets end coordinates on Y axis */
  8030. get: function () {
  8031. return this._y2.toString(this._host);
  8032. },
  8033. set: function (value) {
  8034. if (this._y2.toString(this._host) === value) {
  8035. return;
  8036. }
  8037. if (this._y2.fromString(value)) {
  8038. this._markAsDirty();
  8039. }
  8040. },
  8041. enumerable: true,
  8042. configurable: true
  8043. });
  8044. Object.defineProperty(Line.prototype, "lineWidth", {
  8045. /** Gets or sets line width */
  8046. get: function () {
  8047. return this._lineWidth;
  8048. },
  8049. set: function (value) {
  8050. if (this._lineWidth === value) {
  8051. return;
  8052. }
  8053. this._lineWidth = value;
  8054. this._markAsDirty();
  8055. },
  8056. enumerable: true,
  8057. configurable: true
  8058. });
  8059. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8060. /** Gets or sets horizontal alignment */
  8061. set: function (value) {
  8062. return;
  8063. },
  8064. enumerable: true,
  8065. configurable: true
  8066. });
  8067. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8068. /** Gets or sets vertical alignment */
  8069. set: function (value) {
  8070. return;
  8071. },
  8072. enumerable: true,
  8073. configurable: true
  8074. });
  8075. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8076. get: function () {
  8077. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8078. },
  8079. enumerable: true,
  8080. configurable: true
  8081. });
  8082. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8083. get: function () {
  8084. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8085. },
  8086. enumerable: true,
  8087. configurable: true
  8088. });
  8089. Line.prototype._getTypeName = function () {
  8090. return "Line";
  8091. };
  8092. Line.prototype._draw = function (context) {
  8093. context.save();
  8094. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8095. context.shadowColor = this.shadowColor;
  8096. context.shadowBlur = this.shadowBlur;
  8097. context.shadowOffsetX = this.shadowOffsetX;
  8098. context.shadowOffsetY = this.shadowOffsetY;
  8099. }
  8100. this._applyStates(context);
  8101. context.strokeStyle = this.color;
  8102. context.lineWidth = this._lineWidth;
  8103. context.setLineDash(this._dash);
  8104. context.beginPath();
  8105. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8106. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8107. context.stroke();
  8108. context.restore();
  8109. };
  8110. Line.prototype._measure = function () {
  8111. // Width / Height
  8112. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8113. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8114. };
  8115. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8116. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8117. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8118. };
  8119. /**
  8120. * Move one end of the line given 3D cartesian coordinates.
  8121. * @param position Targeted world position
  8122. * @param scene Scene
  8123. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8124. */
  8125. Line.prototype.moveToVector3 = function (position, scene, end) {
  8126. if (end === void 0) { end = false; }
  8127. if (!this._host || this.parent !== this._host._rootContainer) {
  8128. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8129. return;
  8130. }
  8131. var globalViewport = this._host._getGlobalViewport(scene);
  8132. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8133. this._moveToProjectedPosition(projectedPosition, end);
  8134. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8135. this.notRenderable = true;
  8136. return;
  8137. }
  8138. this.notRenderable = false;
  8139. };
  8140. /**
  8141. * Move one end of the line to a position in screen absolute space.
  8142. * @param projectedPosition Position in screen absolute space (X, Y)
  8143. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8144. */
  8145. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8146. if (end === void 0) { end = false; }
  8147. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8148. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8149. if (end) {
  8150. this.x2 = x;
  8151. this.y2 = y;
  8152. this._x2.ignoreAdaptiveScaling = true;
  8153. this._y2.ignoreAdaptiveScaling = true;
  8154. }
  8155. else {
  8156. this.x1 = x;
  8157. this.y1 = y;
  8158. this._x1.ignoreAdaptiveScaling = true;
  8159. this._y1.ignoreAdaptiveScaling = true;
  8160. }
  8161. };
  8162. return Line;
  8163. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8164. /***/ }),
  8165. /***/ "./2D/controls/multiLine.ts":
  8166. /*!**********************************!*\
  8167. !*** ./2D/controls/multiLine.ts ***!
  8168. \**********************************/
  8169. /*! exports provided: MultiLine */
  8170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8171. "use strict";
  8172. __webpack_require__.r(__webpack_exports__);
  8173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8175. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8176. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8177. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8178. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8179. /**
  8180. * Class used to create multi line control
  8181. */
  8182. var MultiLine = /** @class */ (function (_super) {
  8183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8184. /**
  8185. * Creates a new MultiLine
  8186. * @param name defines the control name
  8187. */
  8188. function MultiLine(name) {
  8189. var _this = _super.call(this, name) || this;
  8190. _this.name = name;
  8191. _this._lineWidth = 1;
  8192. /** Function called when a point is updated */
  8193. _this.onPointUpdate = function () {
  8194. _this._markAsDirty();
  8195. };
  8196. _this.isHitTestVisible = false;
  8197. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8198. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8199. _this._dash = [];
  8200. _this._points = [];
  8201. return _this;
  8202. }
  8203. Object.defineProperty(MultiLine.prototype, "dash", {
  8204. /** Gets or sets dash pattern */
  8205. get: function () {
  8206. return this._dash;
  8207. },
  8208. set: function (value) {
  8209. if (this._dash === value) {
  8210. return;
  8211. }
  8212. this._dash = value;
  8213. this._markAsDirty();
  8214. },
  8215. enumerable: true,
  8216. configurable: true
  8217. });
  8218. /**
  8219. * Gets point stored at specified index
  8220. * @param index defines the index to look for
  8221. * @returns the requested point if found
  8222. */
  8223. MultiLine.prototype.getAt = function (index) {
  8224. if (!this._points[index]) {
  8225. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8226. }
  8227. return this._points[index];
  8228. };
  8229. /**
  8230. * Adds new points to the point collection
  8231. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8232. * @returns the list of created MultiLinePoint
  8233. */
  8234. MultiLine.prototype.add = function () {
  8235. var _this = this;
  8236. var items = [];
  8237. for (var _i = 0; _i < arguments.length; _i++) {
  8238. items[_i] = arguments[_i];
  8239. }
  8240. return items.map(function (item) { return _this.push(item); });
  8241. };
  8242. /**
  8243. * Adds a new point to the point collection
  8244. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8245. * @returns the created MultiLinePoint
  8246. */
  8247. MultiLine.prototype.push = function (item) {
  8248. var point = this.getAt(this._points.length);
  8249. if (item == null) {
  8250. return point;
  8251. }
  8252. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8253. point.mesh = item;
  8254. }
  8255. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8256. point.control = item;
  8257. }
  8258. else if (item.x != null && item.y != null) {
  8259. point.x = item.x;
  8260. point.y = item.y;
  8261. }
  8262. return point;
  8263. };
  8264. /**
  8265. * Remove a specific value or point from the active point collection
  8266. * @param value defines the value or point to remove
  8267. */
  8268. MultiLine.prototype.remove = function (value) {
  8269. var index;
  8270. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8271. index = this._points.indexOf(value);
  8272. if (index === -1) {
  8273. return;
  8274. }
  8275. }
  8276. else {
  8277. index = value;
  8278. }
  8279. var point = this._points[index];
  8280. if (!point) {
  8281. return;
  8282. }
  8283. point.dispose();
  8284. this._points.splice(index, 1);
  8285. };
  8286. /**
  8287. * Resets this object to initial state (no point)
  8288. */
  8289. MultiLine.prototype.reset = function () {
  8290. while (this._points.length > 0) {
  8291. this.remove(this._points.length - 1);
  8292. }
  8293. };
  8294. /**
  8295. * Resets all links
  8296. */
  8297. MultiLine.prototype.resetLinks = function () {
  8298. this._points.forEach(function (point) {
  8299. if (point != null) {
  8300. point.resetLinks();
  8301. }
  8302. });
  8303. };
  8304. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8305. /** Gets or sets line width */
  8306. get: function () {
  8307. return this._lineWidth;
  8308. },
  8309. set: function (value) {
  8310. if (this._lineWidth === value) {
  8311. return;
  8312. }
  8313. this._lineWidth = value;
  8314. this._markAsDirty();
  8315. },
  8316. enumerable: true,
  8317. configurable: true
  8318. });
  8319. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8320. set: function (value) {
  8321. return;
  8322. },
  8323. enumerable: true,
  8324. configurable: true
  8325. });
  8326. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8327. set: function (value) {
  8328. return;
  8329. },
  8330. enumerable: true,
  8331. configurable: true
  8332. });
  8333. MultiLine.prototype._getTypeName = function () {
  8334. return "MultiLine";
  8335. };
  8336. MultiLine.prototype._draw = function (context) {
  8337. context.save();
  8338. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8339. context.shadowColor = this.shadowColor;
  8340. context.shadowBlur = this.shadowBlur;
  8341. context.shadowOffsetX = this.shadowOffsetX;
  8342. context.shadowOffsetY = this.shadowOffsetY;
  8343. }
  8344. this._applyStates(context);
  8345. context.strokeStyle = this.color;
  8346. context.lineWidth = this._lineWidth;
  8347. context.setLineDash(this._dash);
  8348. context.beginPath();
  8349. var first = true; //first index is not necessarily 0
  8350. this._points.forEach(function (point) {
  8351. if (!point) {
  8352. return;
  8353. }
  8354. if (first) {
  8355. context.moveTo(point._point.x, point._point.y);
  8356. first = false;
  8357. }
  8358. else {
  8359. context.lineTo(point._point.x, point._point.y);
  8360. }
  8361. });
  8362. context.stroke();
  8363. context.restore();
  8364. };
  8365. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8366. var _this = this;
  8367. this._minX = null;
  8368. this._minY = null;
  8369. this._maxX = null;
  8370. this._maxY = null;
  8371. this._points.forEach(function (point, index) {
  8372. if (!point) {
  8373. return;
  8374. }
  8375. point.translate();
  8376. if (_this._minX == null || point._point.x < _this._minX) {
  8377. _this._minX = point._point.x;
  8378. }
  8379. if (_this._minY == null || point._point.y < _this._minY) {
  8380. _this._minY = point._point.y;
  8381. }
  8382. if (_this._maxX == null || point._point.x > _this._maxX) {
  8383. _this._maxX = point._point.x;
  8384. }
  8385. if (_this._maxY == null || point._point.y > _this._maxY) {
  8386. _this._maxY = point._point.y;
  8387. }
  8388. });
  8389. if (this._minX == null) {
  8390. this._minX = 0;
  8391. }
  8392. if (this._minY == null) {
  8393. this._minY = 0;
  8394. }
  8395. if (this._maxX == null) {
  8396. this._maxX = 0;
  8397. }
  8398. if (this._maxY == null) {
  8399. this._maxY = 0;
  8400. }
  8401. };
  8402. MultiLine.prototype._measure = function () {
  8403. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8404. return;
  8405. }
  8406. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8407. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8408. };
  8409. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8410. if (this._minX == null || this._minY == null) {
  8411. return;
  8412. }
  8413. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8414. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8415. };
  8416. MultiLine.prototype.dispose = function () {
  8417. this.reset();
  8418. _super.prototype.dispose.call(this);
  8419. };
  8420. return MultiLine;
  8421. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8422. /***/ }),
  8423. /***/ "./2D/controls/radioButton.ts":
  8424. /*!************************************!*\
  8425. !*** ./2D/controls/radioButton.ts ***!
  8426. \************************************/
  8427. /*! exports provided: RadioButton */
  8428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8429. "use strict";
  8430. __webpack_require__.r(__webpack_exports__);
  8431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8432. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8433. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8434. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8435. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8436. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8437. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8438. /**
  8439. * Class used to create radio button controls
  8440. */
  8441. var RadioButton = /** @class */ (function (_super) {
  8442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8443. /**
  8444. * Creates a new RadioButton
  8445. * @param name defines the control name
  8446. */
  8447. function RadioButton(name) {
  8448. var _this = _super.call(this, name) || this;
  8449. _this.name = name;
  8450. _this._isChecked = false;
  8451. _this._background = "black";
  8452. _this._checkSizeRatio = 0.8;
  8453. _this._thickness = 1;
  8454. /** Gets or sets group name */
  8455. _this.group = "";
  8456. /** Observable raised when isChecked is changed */
  8457. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8458. _this.isPointerBlocker = true;
  8459. return _this;
  8460. }
  8461. Object.defineProperty(RadioButton.prototype, "thickness", {
  8462. /** Gets or sets border thickness */
  8463. get: function () {
  8464. return this._thickness;
  8465. },
  8466. set: function (value) {
  8467. if (this._thickness === value) {
  8468. return;
  8469. }
  8470. this._thickness = value;
  8471. this._markAsDirty();
  8472. },
  8473. enumerable: true,
  8474. configurable: true
  8475. });
  8476. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8477. /** Gets or sets a value indicating the ratio between overall size and check size */
  8478. get: function () {
  8479. return this._checkSizeRatio;
  8480. },
  8481. set: function (value) {
  8482. value = Math.max(Math.min(1, value), 0);
  8483. if (this._checkSizeRatio === value) {
  8484. return;
  8485. }
  8486. this._checkSizeRatio = value;
  8487. this._markAsDirty();
  8488. },
  8489. enumerable: true,
  8490. configurable: true
  8491. });
  8492. Object.defineProperty(RadioButton.prototype, "background", {
  8493. /** Gets or sets background color */
  8494. get: function () {
  8495. return this._background;
  8496. },
  8497. set: function (value) {
  8498. if (this._background === value) {
  8499. return;
  8500. }
  8501. this._background = value;
  8502. this._markAsDirty();
  8503. },
  8504. enumerable: true,
  8505. configurable: true
  8506. });
  8507. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8508. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8509. get: function () {
  8510. return this._isChecked;
  8511. },
  8512. set: function (value) {
  8513. var _this = this;
  8514. if (this._isChecked === value) {
  8515. return;
  8516. }
  8517. this._isChecked = value;
  8518. this._markAsDirty();
  8519. this.onIsCheckedChangedObservable.notifyObservers(value);
  8520. if (this._isChecked && this._host) {
  8521. // Update all controls from same group
  8522. this._host.executeOnAllControls(function (control) {
  8523. if (control === _this) {
  8524. return;
  8525. }
  8526. if (control.group === undefined) {
  8527. return;
  8528. }
  8529. var childRadio = control;
  8530. if (childRadio.group === _this.group) {
  8531. childRadio.isChecked = false;
  8532. }
  8533. });
  8534. }
  8535. },
  8536. enumerable: true,
  8537. configurable: true
  8538. });
  8539. RadioButton.prototype._getTypeName = function () {
  8540. return "RadioButton";
  8541. };
  8542. RadioButton.prototype._draw = function (context) {
  8543. context.save();
  8544. this._applyStates(context);
  8545. var actualWidth = this._currentMeasure.width - this._thickness;
  8546. var actualHeight = this._currentMeasure.height - this._thickness;
  8547. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8548. context.shadowColor = this.shadowColor;
  8549. context.shadowBlur = this.shadowBlur;
  8550. context.shadowOffsetX = this.shadowOffsetX;
  8551. context.shadowOffsetY = this.shadowOffsetY;
  8552. }
  8553. // Outer
  8554. _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);
  8555. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8556. context.fill();
  8557. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8558. context.shadowBlur = 0;
  8559. context.shadowOffsetX = 0;
  8560. context.shadowOffsetY = 0;
  8561. }
  8562. context.strokeStyle = this.color;
  8563. context.lineWidth = this._thickness;
  8564. context.stroke();
  8565. // Inner
  8566. if (this._isChecked) {
  8567. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8568. var offsetWidth = actualWidth * this._checkSizeRatio;
  8569. var offseHeight = actualHeight * this._checkSizeRatio;
  8570. _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);
  8571. context.fill();
  8572. }
  8573. context.restore();
  8574. };
  8575. // Events
  8576. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8577. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8578. return false;
  8579. }
  8580. if (!this.isChecked) {
  8581. this.isChecked = true;
  8582. }
  8583. return true;
  8584. };
  8585. /**
  8586. * Utility function to easily create a radio button with a header
  8587. * @param title defines the label to use for the header
  8588. * @param group defines the group to use for the radio button
  8589. * @param isChecked defines the initial state of the radio button
  8590. * @param onValueChanged defines the callback to call when value changes
  8591. * @returns a StackPanel containing the radio button and a textBlock
  8592. */
  8593. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8594. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8595. panel.isVertical = false;
  8596. panel.height = "30px";
  8597. var radio = new RadioButton();
  8598. radio.width = "20px";
  8599. radio.height = "20px";
  8600. radio.isChecked = isChecked;
  8601. radio.color = "green";
  8602. radio.group = group;
  8603. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8604. panel.addControl(radio);
  8605. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8606. header.text = title;
  8607. header.width = "180px";
  8608. header.paddingLeft = "5px";
  8609. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8610. header.color = "white";
  8611. panel.addControl(header);
  8612. return panel;
  8613. };
  8614. return RadioButton;
  8615. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8616. /***/ }),
  8617. /***/ "./2D/controls/rectangle.ts":
  8618. /*!**********************************!*\
  8619. !*** ./2D/controls/rectangle.ts ***!
  8620. \**********************************/
  8621. /*! exports provided: Rectangle */
  8622. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8623. "use strict";
  8624. __webpack_require__.r(__webpack_exports__);
  8625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8626. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8627. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8628. /** Class used to create rectangle container */
  8629. var Rectangle = /** @class */ (function (_super) {
  8630. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8631. /**
  8632. * Creates a new Rectangle
  8633. * @param name defines the control name
  8634. */
  8635. function Rectangle(name) {
  8636. var _this = _super.call(this, name) || this;
  8637. _this.name = name;
  8638. _this._thickness = 1;
  8639. _this._cornerRadius = 0;
  8640. return _this;
  8641. }
  8642. Object.defineProperty(Rectangle.prototype, "thickness", {
  8643. /** Gets or sets border thickness */
  8644. get: function () {
  8645. return this._thickness;
  8646. },
  8647. set: function (value) {
  8648. if (this._thickness === value) {
  8649. return;
  8650. }
  8651. this._thickness = value;
  8652. this._markAsDirty();
  8653. },
  8654. enumerable: true,
  8655. configurable: true
  8656. });
  8657. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8658. /** Gets or sets the corner radius angle */
  8659. get: function () {
  8660. return this._cornerRadius;
  8661. },
  8662. set: function (value) {
  8663. if (value < 0) {
  8664. value = 0;
  8665. }
  8666. if (this._cornerRadius === value) {
  8667. return;
  8668. }
  8669. this._cornerRadius = value;
  8670. this._markAsDirty();
  8671. },
  8672. enumerable: true,
  8673. configurable: true
  8674. });
  8675. Rectangle.prototype._getTypeName = function () {
  8676. return "Rectangle";
  8677. };
  8678. Rectangle.prototype._localDraw = function (context) {
  8679. context.save();
  8680. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8681. context.shadowColor = this.shadowColor;
  8682. context.shadowBlur = this.shadowBlur;
  8683. context.shadowOffsetX = this.shadowOffsetX;
  8684. context.shadowOffsetY = this.shadowOffsetY;
  8685. }
  8686. if (this._background) {
  8687. context.fillStyle = this._background;
  8688. if (this._cornerRadius) {
  8689. this._drawRoundedRect(context, this._thickness / 2);
  8690. context.fill();
  8691. }
  8692. else {
  8693. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8694. }
  8695. }
  8696. if (this._thickness) {
  8697. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8698. context.shadowBlur = 0;
  8699. context.shadowOffsetX = 0;
  8700. context.shadowOffsetY = 0;
  8701. }
  8702. if (this.color) {
  8703. context.strokeStyle = this.color;
  8704. }
  8705. context.lineWidth = this._thickness;
  8706. if (this._cornerRadius) {
  8707. this._drawRoundedRect(context, this._thickness / 2);
  8708. context.stroke();
  8709. }
  8710. else {
  8711. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8712. }
  8713. }
  8714. context.restore();
  8715. };
  8716. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8717. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8718. this._measureForChildren.width -= 2 * this._thickness;
  8719. this._measureForChildren.height -= 2 * this._thickness;
  8720. this._measureForChildren.left += this._thickness;
  8721. this._measureForChildren.top += this._thickness;
  8722. };
  8723. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8724. if (offset === void 0) { offset = 0; }
  8725. var x = this._currentMeasure.left + offset;
  8726. var y = this._currentMeasure.top + offset;
  8727. var width = this._currentMeasure.width - offset * 2;
  8728. var height = this._currentMeasure.height - offset * 2;
  8729. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8730. context.beginPath();
  8731. context.moveTo(x + radius, y);
  8732. context.lineTo(x + width - radius, y);
  8733. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8734. context.lineTo(x + width, y + height - radius);
  8735. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8736. context.lineTo(x + radius, y + height);
  8737. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8738. context.lineTo(x, y + radius);
  8739. context.quadraticCurveTo(x, y, x + radius, y);
  8740. context.closePath();
  8741. };
  8742. Rectangle.prototype._clipForChildren = function (context) {
  8743. if (this._cornerRadius) {
  8744. this._drawRoundedRect(context, this._thickness);
  8745. context.clip();
  8746. }
  8747. };
  8748. return Rectangle;
  8749. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8750. /***/ }),
  8751. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8752. /*!***************************************************!*\
  8753. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8754. \***************************************************/
  8755. /*! exports provided: ScrollViewer */
  8756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8757. "use strict";
  8758. __webpack_require__.r(__webpack_exports__);
  8759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8760. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8761. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8762. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8763. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8764. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8765. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8766. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8767. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8768. /**
  8769. * Class used to hold a viewer window and sliders in a grid
  8770. */
  8771. var ScrollViewer = /** @class */ (function (_super) {
  8772. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8773. /**
  8774. * Creates a new ScrollViewer
  8775. * @param name of ScrollViewer
  8776. */
  8777. function ScrollViewer(name) {
  8778. var _this = _super.call(this, name) || this;
  8779. _this._barSize = 20;
  8780. _this._pointerIsOver = false;
  8781. _this._wheelPrecision = 0.05;
  8782. _this.onDirtyObservable.add(function () {
  8783. _this._horizontalBarSpace.color = _this.color;
  8784. _this._verticalBarSpace.color = _this.color;
  8785. _this._dragSpace.color = _this.color;
  8786. });
  8787. _this.onPointerEnterObservable.add(function () {
  8788. _this._pointerIsOver = true;
  8789. });
  8790. _this.onPointerOutObservable.add(function () {
  8791. _this._pointerIsOver = false;
  8792. });
  8793. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8794. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8795. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8796. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8797. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8798. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8799. _this._grid.addColumnDefinition(1);
  8800. _this._grid.addColumnDefinition(0, true);
  8801. _this._grid.addRowDefinition(1);
  8802. _this._grid.addRowDefinition(0, true);
  8803. _super.prototype.addControl.call(_this, _this._grid);
  8804. _this._grid.addControl(_this._window, 0, 0);
  8805. _this._verticalBar.paddingLeft = 0;
  8806. _this._verticalBar.width = "100%";
  8807. _this._verticalBar.height = "100%";
  8808. _this._verticalBar.barOffset = 0;
  8809. _this._verticalBar.value = 0;
  8810. _this._verticalBar.maximum = 1;
  8811. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8812. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8813. _this._verticalBar.isVertical = true;
  8814. _this._verticalBar.rotation = Math.PI;
  8815. _this._verticalBar.isVisible = false;
  8816. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8817. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8818. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8819. _this._verticalBarSpace.thickness = 1;
  8820. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8821. _this._verticalBarSpace.addControl(_this._verticalBar);
  8822. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8823. _this._window.top = value * _this._endTop + "px";
  8824. });
  8825. _this._horizontalBar.paddingLeft = 0;
  8826. _this._horizontalBar.width = "100%";
  8827. _this._horizontalBar.height = "100%";
  8828. _this._horizontalBar.barOffset = 0;
  8829. _this._horizontalBar.value = 0;
  8830. _this._horizontalBar.maximum = 1;
  8831. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8832. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8833. _this._horizontalBar.isVisible = false;
  8834. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8835. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8836. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8837. _this._horizontalBarSpace.thickness = 1;
  8838. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8839. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8840. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8841. _this._window.left = value * _this._endLeft + "px";
  8842. });
  8843. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8844. _this._dragSpace.thickness = 1;
  8845. _this._grid.addControl(_this._dragSpace, 1, 1);
  8846. // Colors
  8847. _this.barColor = "grey";
  8848. _this.barBackground = "transparent";
  8849. return _this;
  8850. }
  8851. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8852. /**
  8853. * Gets the horizontal scrollbar
  8854. */
  8855. get: function () {
  8856. return this._horizontalBar;
  8857. },
  8858. enumerable: true,
  8859. configurable: true
  8860. });
  8861. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8862. /**
  8863. * Gets the vertical scrollbar
  8864. */
  8865. get: function () {
  8866. return this._verticalBar;
  8867. },
  8868. enumerable: true,
  8869. configurable: true
  8870. });
  8871. /**
  8872. * Adds a new control to the current container
  8873. * @param control defines the control to add
  8874. * @returns the current container
  8875. */
  8876. ScrollViewer.prototype.addControl = function (control) {
  8877. if (!control) {
  8878. return this;
  8879. }
  8880. this._window.addControl(control);
  8881. return this;
  8882. };
  8883. /**
  8884. * Removes a control from the current container
  8885. * @param control defines the control to remove
  8886. * @returns the current container
  8887. */
  8888. ScrollViewer.prototype.removeControl = function (control) {
  8889. this._window.removeControl(control);
  8890. return this;
  8891. };
  8892. Object.defineProperty(ScrollViewer.prototype, "children", {
  8893. /** Gets the list of children */
  8894. get: function () {
  8895. return this._window.children;
  8896. },
  8897. enumerable: true,
  8898. configurable: true
  8899. });
  8900. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8901. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8902. var child = _a[_i];
  8903. child._markMatrixAsDirty();
  8904. }
  8905. };
  8906. /** Reset the scroll viewer window to initial size */
  8907. ScrollViewer.prototype.resetWindow = function () {
  8908. this._window.width = "100%";
  8909. this._window.height = "100%";
  8910. };
  8911. ScrollViewer.prototype._getTypeName = function () {
  8912. return "ScrollViewer";
  8913. };
  8914. ScrollViewer.prototype._buildClientSizes = function () {
  8915. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8916. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8917. this._clientWidth = this._window.parentClientWidth;
  8918. this._clientHeight = this._window.parentClientHeight;
  8919. };
  8920. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8921. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8922. this._buildClientSizes();
  8923. };
  8924. ScrollViewer.prototype._postMeasure = function () {
  8925. _super.prototype._postMeasure.call(this);
  8926. this._updateScroller();
  8927. };
  8928. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8929. /**
  8930. * Gets or sets the mouse wheel precision
  8931. * from 0 to 1 with a default value of 0.05
  8932. * */
  8933. get: function () {
  8934. return this._wheelPrecision;
  8935. },
  8936. set: function (value) {
  8937. if (this._wheelPrecision === value) {
  8938. return;
  8939. }
  8940. if (value < 0) {
  8941. value = 0;
  8942. }
  8943. if (value > 1) {
  8944. value = 1;
  8945. }
  8946. this._wheelPrecision = value;
  8947. },
  8948. enumerable: true,
  8949. configurable: true
  8950. });
  8951. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8952. /** Gets or sets the bar color */
  8953. get: function () {
  8954. return this._barColor;
  8955. },
  8956. set: function (color) {
  8957. if (this._barColor === color) {
  8958. return;
  8959. }
  8960. this._barColor = color;
  8961. this._horizontalBar.color = color;
  8962. this._verticalBar.color = color;
  8963. },
  8964. enumerable: true,
  8965. configurable: true
  8966. });
  8967. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8968. /** Gets or sets the size of the bar */
  8969. get: function () {
  8970. return this._barSize;
  8971. },
  8972. set: function (value) {
  8973. if (this._barSize === value) {
  8974. return;
  8975. }
  8976. this._barSize = value;
  8977. this._markAsDirty();
  8978. if (this._horizontalBar.isVisible) {
  8979. this._grid.setRowDefinition(1, this._barSize, true);
  8980. }
  8981. if (this._verticalBar.isVisible) {
  8982. this._grid.setColumnDefinition(1, this._barSize, true);
  8983. }
  8984. },
  8985. enumerable: true,
  8986. configurable: true
  8987. });
  8988. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8989. /** Gets or sets the bar background */
  8990. get: function () {
  8991. return this._barBackground;
  8992. },
  8993. set: function (color) {
  8994. if (this._barBackground === color) {
  8995. return;
  8996. }
  8997. this._barBackground = color;
  8998. this._horizontalBar.background = color;
  8999. this._verticalBar.background = color;
  9000. this._dragSpace.background = color;
  9001. },
  9002. enumerable: true,
  9003. configurable: true
  9004. });
  9005. /** @hidden */
  9006. ScrollViewer.prototype._updateScroller = function () {
  9007. var windowContentsWidth = this._window._currentMeasure.width;
  9008. var windowContentsHeight = this._window._currentMeasure.height;
  9009. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9010. this._grid.setRowDefinition(1, 0, true);
  9011. this._horizontalBar.isVisible = false;
  9012. this._horizontalBar.value = 0;
  9013. this._rebuildLayout = true;
  9014. }
  9015. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9016. this._grid.setRowDefinition(1, this._barSize, true);
  9017. this._horizontalBar.isVisible = true;
  9018. this._rebuildLayout = true;
  9019. }
  9020. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9021. this._grid.setColumnDefinition(1, 0, true);
  9022. this._verticalBar.isVisible = false;
  9023. this._verticalBar.value = 0;
  9024. this._rebuildLayout = true;
  9025. }
  9026. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9027. this._grid.setColumnDefinition(1, this._barSize, true);
  9028. this._verticalBar.isVisible = true;
  9029. this._rebuildLayout = true;
  9030. }
  9031. this._buildClientSizes();
  9032. this._endLeft = this._clientWidth - windowContentsWidth;
  9033. this._endTop = this._clientHeight - windowContentsHeight;
  9034. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9035. var newTop = this._verticalBar.value * this._endTop + "px";
  9036. if (newLeft !== this._window.left) {
  9037. this._window.left = newLeft;
  9038. this._rebuildLayout = true;
  9039. }
  9040. if (newTop !== this._window.top) {
  9041. this._window.top = newTop;
  9042. this._rebuildLayout = true;
  9043. }
  9044. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  9045. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  9046. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  9047. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  9048. };
  9049. ScrollViewer.prototype._link = function (host) {
  9050. _super.prototype._link.call(this, host);
  9051. this._attachWheel();
  9052. };
  9053. /** @hidden */
  9054. ScrollViewer.prototype._attachWheel = function () {
  9055. var _this = this;
  9056. if (!this._host || this._onPointerObserver) {
  9057. return;
  9058. }
  9059. var scene = this._host.getScene();
  9060. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9061. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9062. return;
  9063. }
  9064. if (_this._verticalBar.isVisible == true) {
  9065. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9066. _this._verticalBar.value -= _this._wheelPrecision;
  9067. }
  9068. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9069. _this._verticalBar.value += _this._wheelPrecision;
  9070. }
  9071. }
  9072. if (_this._horizontalBar.isVisible == true) {
  9073. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9074. _this._horizontalBar.value += _this._wheelPrecision;
  9075. }
  9076. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9077. _this._horizontalBar.value -= _this._wheelPrecision;
  9078. }
  9079. }
  9080. });
  9081. };
  9082. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9083. if (!this.isHighlighted) {
  9084. return;
  9085. }
  9086. _super.prototype._renderHighlightSpecific.call(this, context);
  9087. this._grid._renderHighlightSpecific(context);
  9088. context.restore();
  9089. };
  9090. /** Releases associated resources */
  9091. ScrollViewer.prototype.dispose = function () {
  9092. var scene = this._host.getScene();
  9093. if (scene && this._onPointerObserver) {
  9094. scene.onPointerObservable.remove(this._onPointerObserver);
  9095. this._onPointerObserver = null;
  9096. }
  9097. _super.prototype.dispose.call(this);
  9098. };
  9099. return ScrollViewer;
  9100. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9101. /***/ }),
  9102. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9103. /*!*********************************************************!*\
  9104. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9105. \*********************************************************/
  9106. /*! exports provided: _ScrollViewerWindow */
  9107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9108. "use strict";
  9109. __webpack_require__.r(__webpack_exports__);
  9110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9111. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9112. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9113. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9114. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9115. /**
  9116. * Class used to hold a the container for ScrollViewer
  9117. * @hidden
  9118. */
  9119. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9120. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9121. /**
  9122. * Creates a new ScrollViewerWindow
  9123. * @param name of ScrollViewerWindow
  9124. */
  9125. function _ScrollViewerWindow(name) {
  9126. return _super.call(this, name) || this;
  9127. }
  9128. _ScrollViewerWindow.prototype._getTypeName = function () {
  9129. return "ScrollViewerWindow";
  9130. };
  9131. /** @hidden */
  9132. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9133. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9134. this._measureForChildren.left = this._currentMeasure.left;
  9135. this._measureForChildren.top = this._currentMeasure.top;
  9136. this._measureForChildren.width = parentMeasure.width;
  9137. this._measureForChildren.height = parentMeasure.height;
  9138. };
  9139. _ScrollViewerWindow.prototype._postMeasure = function () {
  9140. var maxWidth = this.parentClientWidth;
  9141. var maxHeight = this.parentClientHeight;
  9142. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9143. var child = _a[_i];
  9144. if (!child.isVisible || child.notRenderable) {
  9145. continue;
  9146. }
  9147. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9148. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9149. }
  9150. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9151. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9152. }
  9153. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9154. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9155. }
  9156. if (this._currentMeasure.width !== maxWidth) {
  9157. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9158. this._currentMeasure.width = maxWidth;
  9159. this._rebuildLayout = true;
  9160. this._isDirty = true;
  9161. }
  9162. if (this._currentMeasure.height !== maxHeight) {
  9163. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9164. this._currentMeasure.height = maxHeight;
  9165. this._rebuildLayout = true;
  9166. this._isDirty = true;
  9167. }
  9168. _super.prototype._postMeasure.call(this);
  9169. };
  9170. return _ScrollViewerWindow;
  9171. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9172. /***/ }),
  9173. /***/ "./2D/controls/selector.ts":
  9174. /*!*********************************!*\
  9175. !*** ./2D/controls/selector.ts ***!
  9176. \*********************************/
  9177. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9179. "use strict";
  9180. __webpack_require__.r(__webpack_exports__);
  9181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9187. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9188. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9189. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9190. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9191. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9192. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9193. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9194. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9195. /** Class used to create a RadioGroup
  9196. * which contains groups of radio buttons
  9197. */
  9198. var SelectorGroup = /** @class */ (function () {
  9199. /**
  9200. * Creates a new SelectorGroup
  9201. * @param name of group, used as a group heading
  9202. */
  9203. function SelectorGroup(
  9204. /** name of SelectorGroup */
  9205. name) {
  9206. this.name = name;
  9207. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9208. this._selectors = new Array();
  9209. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9210. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9211. this._groupHeader = this._addGroupHeader(name);
  9212. }
  9213. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9214. /** Gets the groupPanel of the SelectorGroup */
  9215. get: function () {
  9216. return this._groupPanel;
  9217. },
  9218. enumerable: true,
  9219. configurable: true
  9220. });
  9221. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9222. /** Gets the selectors array */
  9223. get: function () {
  9224. return this._selectors;
  9225. },
  9226. enumerable: true,
  9227. configurable: true
  9228. });
  9229. Object.defineProperty(SelectorGroup.prototype, "header", {
  9230. /** Gets and sets the group header */
  9231. get: function () {
  9232. return this._groupHeader.text;
  9233. },
  9234. set: function (label) {
  9235. if (this._groupHeader.text === "label") {
  9236. return;
  9237. }
  9238. this._groupHeader.text = label;
  9239. },
  9240. enumerable: true,
  9241. configurable: true
  9242. });
  9243. /** @hidden */
  9244. SelectorGroup.prototype._addGroupHeader = function (text) {
  9245. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9246. groupHeading.width = 0.9;
  9247. groupHeading.height = "30px";
  9248. groupHeading.textWrapping = true;
  9249. groupHeading.color = "black";
  9250. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9251. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9252. groupHeading.left = "2px";
  9253. this._groupPanel.addControl(groupHeading);
  9254. return groupHeading;
  9255. };
  9256. /** @hidden*/
  9257. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9258. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9259. return;
  9260. }
  9261. return this._selectors[selectorNb];
  9262. };
  9263. /** Removes the selector at the given position
  9264. * @param selectorNb the position of the selector within the group
  9265. */
  9266. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9267. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9268. return;
  9269. }
  9270. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9271. this._selectors.splice(selectorNb, 1);
  9272. };
  9273. return SelectorGroup;
  9274. }());
  9275. /** Class used to create a CheckboxGroup
  9276. * which contains groups of checkbox buttons
  9277. */
  9278. var CheckboxGroup = /** @class */ (function (_super) {
  9279. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9280. function CheckboxGroup() {
  9281. return _super !== null && _super.apply(this, arguments) || this;
  9282. }
  9283. /** Adds a checkbox as a control
  9284. * @param text is the label for the selector
  9285. * @param func is the function called when the Selector is checked
  9286. * @param checked is true when Selector is checked
  9287. */
  9288. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9289. if (func === void 0) { func = function (s) { }; }
  9290. if (checked === void 0) { checked = false; }
  9291. var checked = checked || false;
  9292. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9293. button.width = "20px";
  9294. button.height = "20px";
  9295. button.color = "#364249";
  9296. button.background = "#CCCCCC";
  9297. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9298. button.onIsCheckedChangedObservable.add(function (state) {
  9299. func(state);
  9300. });
  9301. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9302. _selector.height = "30px";
  9303. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9304. _selector.left = "4px";
  9305. this.groupPanel.addControl(_selector);
  9306. this.selectors.push(_selector);
  9307. button.isChecked = checked;
  9308. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9309. button.color = this.groupPanel.parent.parent.buttonColor;
  9310. button.background = this.groupPanel.parent.parent.buttonBackground;
  9311. }
  9312. };
  9313. /** @hidden */
  9314. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9315. this.selectors[selectorNb].children[1].text = label;
  9316. };
  9317. /** @hidden */
  9318. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9319. this.selectors[selectorNb].children[1].color = color;
  9320. };
  9321. /** @hidden */
  9322. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9323. this.selectors[selectorNb].children[0].color = color;
  9324. };
  9325. /** @hidden */
  9326. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9327. this.selectors[selectorNb].children[0].background = color;
  9328. };
  9329. return CheckboxGroup;
  9330. }(SelectorGroup));
  9331. /** Class used to create a RadioGroup
  9332. * which contains groups of radio buttons
  9333. */
  9334. var RadioGroup = /** @class */ (function (_super) {
  9335. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9336. function RadioGroup() {
  9337. var _this = _super !== null && _super.apply(this, arguments) || this;
  9338. _this._selectNb = 0;
  9339. return _this;
  9340. }
  9341. /** Adds a radio button as a control
  9342. * @param label is the label for the selector
  9343. * @param func is the function called when the Selector is checked
  9344. * @param checked is true when Selector is checked
  9345. */
  9346. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9347. if (func === void 0) { func = function (n) { }; }
  9348. if (checked === void 0) { checked = false; }
  9349. var nb = this._selectNb++;
  9350. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9351. button.name = label;
  9352. button.width = "20px";
  9353. button.height = "20px";
  9354. button.color = "#364249";
  9355. button.background = "#CCCCCC";
  9356. button.group = this.name;
  9357. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9358. button.onIsCheckedChangedObservable.add(function (state) {
  9359. if (state) {
  9360. func(nb);
  9361. }
  9362. });
  9363. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9364. _selector.height = "30px";
  9365. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9366. _selector.left = "4px";
  9367. this.groupPanel.addControl(_selector);
  9368. this.selectors.push(_selector);
  9369. button.isChecked = checked;
  9370. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9371. button.color = this.groupPanel.parent.parent.buttonColor;
  9372. button.background = this.groupPanel.parent.parent.buttonBackground;
  9373. }
  9374. };
  9375. /** @hidden */
  9376. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9377. this.selectors[selectorNb].children[1].text = label;
  9378. };
  9379. /** @hidden */
  9380. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9381. this.selectors[selectorNb].children[1].color = color;
  9382. };
  9383. /** @hidden */
  9384. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9385. this.selectors[selectorNb].children[0].color = color;
  9386. };
  9387. /** @hidden */
  9388. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9389. this.selectors[selectorNb].children[0].background = color;
  9390. };
  9391. return RadioGroup;
  9392. }(SelectorGroup));
  9393. /** Class used to create a SliderGroup
  9394. * which contains groups of slider buttons
  9395. */
  9396. var SliderGroup = /** @class */ (function (_super) {
  9397. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9398. function SliderGroup() {
  9399. return _super !== null && _super.apply(this, arguments) || this;
  9400. }
  9401. /**
  9402. * Adds a slider to the SelectorGroup
  9403. * @param label is the label for the SliderBar
  9404. * @param func is the function called when the Slider moves
  9405. * @param unit is a string describing the units used, eg degrees or metres
  9406. * @param min is the minimum value for the Slider
  9407. * @param max is the maximum value for the Slider
  9408. * @param value is the start value for the Slider between min and max
  9409. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9410. */
  9411. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9412. if (func === void 0) { func = function (v) { }; }
  9413. if (unit === void 0) { unit = "Units"; }
  9414. if (min === void 0) { min = 0; }
  9415. if (max === void 0) { max = 0; }
  9416. if (value === void 0) { value = 0; }
  9417. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9418. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9419. button.name = unit;
  9420. button.value = value;
  9421. button.minimum = min;
  9422. button.maximum = max;
  9423. button.width = 0.9;
  9424. button.height = "20px";
  9425. button.color = "#364249";
  9426. button.background = "#CCCCCC";
  9427. button.borderColor = "black";
  9428. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9429. button.left = "4px";
  9430. button.paddingBottom = "4px";
  9431. button.onValueChangedObservable.add(function (value) {
  9432. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9433. func(value);
  9434. });
  9435. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9436. _selector.height = "60px";
  9437. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9438. _selector.left = "4px";
  9439. _selector.children[0].name = label;
  9440. this.groupPanel.addControl(_selector);
  9441. this.selectors.push(_selector);
  9442. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9443. button.color = this.groupPanel.parent.parent.buttonColor;
  9444. button.background = this.groupPanel.parent.parent.buttonBackground;
  9445. }
  9446. };
  9447. /** @hidden */
  9448. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9449. this.selectors[selectorNb].children[0].name = label;
  9450. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9451. };
  9452. /** @hidden */
  9453. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9454. this.selectors[selectorNb].children[0].color = color;
  9455. };
  9456. /** @hidden */
  9457. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9458. this.selectors[selectorNb].children[1].color = color;
  9459. };
  9460. /** @hidden */
  9461. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9462. this.selectors[selectorNb].children[1].background = color;
  9463. };
  9464. return SliderGroup;
  9465. }(SelectorGroup));
  9466. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9467. * @see http://doc.babylonjs.com/how_to/selector
  9468. */
  9469. var SelectionPanel = /** @class */ (function (_super) {
  9470. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9471. /**
  9472. * Creates a new SelectionPanel
  9473. * @param name of SelectionPanel
  9474. * @param groups is an array of SelectionGroups
  9475. */
  9476. function SelectionPanel(
  9477. /** name of SelectionPanel */
  9478. name,
  9479. /** an array of SelectionGroups */
  9480. groups) {
  9481. if (groups === void 0) { groups = []; }
  9482. var _this = _super.call(this, name) || this;
  9483. _this.name = name;
  9484. _this.groups = groups;
  9485. _this._buttonColor = "#364249";
  9486. _this._buttonBackground = "#CCCCCC";
  9487. _this._headerColor = "black";
  9488. _this._barColor = "white";
  9489. _this._barHeight = "2px";
  9490. _this._spacerHeight = "20px";
  9491. _this._bars = new Array();
  9492. _this._groups = groups;
  9493. _this.thickness = 2;
  9494. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9495. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9496. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9497. _this._panel.top = 5;
  9498. _this._panel.left = 5;
  9499. _this._panel.width = 0.95;
  9500. if (groups.length > 0) {
  9501. for (var i = 0; i < groups.length - 1; i++) {
  9502. _this._panel.addControl(groups[i].groupPanel);
  9503. _this._addSpacer();
  9504. }
  9505. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9506. }
  9507. _this.addControl(_this._panel);
  9508. return _this;
  9509. }
  9510. SelectionPanel.prototype._getTypeName = function () {
  9511. return "SelectionPanel";
  9512. };
  9513. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9514. /** Gets or sets the headerColor */
  9515. get: function () {
  9516. return this._headerColor;
  9517. },
  9518. set: function (color) {
  9519. if (this._headerColor === color) {
  9520. return;
  9521. }
  9522. this._headerColor = color;
  9523. this._setHeaderColor();
  9524. },
  9525. enumerable: true,
  9526. configurable: true
  9527. });
  9528. SelectionPanel.prototype._setHeaderColor = function () {
  9529. for (var i = 0; i < this._groups.length; i++) {
  9530. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9531. }
  9532. };
  9533. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9534. /** Gets or sets the button color */
  9535. get: function () {
  9536. return this._buttonColor;
  9537. },
  9538. set: function (color) {
  9539. if (this._buttonColor === color) {
  9540. return;
  9541. }
  9542. this._buttonColor = color;
  9543. this._setbuttonColor();
  9544. },
  9545. enumerable: true,
  9546. configurable: true
  9547. });
  9548. SelectionPanel.prototype._setbuttonColor = function () {
  9549. for (var i = 0; i < this._groups.length; i++) {
  9550. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9551. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9552. }
  9553. }
  9554. };
  9555. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9556. /** Gets or sets the label color */
  9557. get: function () {
  9558. return this._labelColor;
  9559. },
  9560. set: function (color) {
  9561. if (this._labelColor === color) {
  9562. return;
  9563. }
  9564. this._labelColor = color;
  9565. this._setLabelColor();
  9566. },
  9567. enumerable: true,
  9568. configurable: true
  9569. });
  9570. SelectionPanel.prototype._setLabelColor = function () {
  9571. for (var i = 0; i < this._groups.length; i++) {
  9572. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9573. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9574. }
  9575. }
  9576. };
  9577. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9578. /** Gets or sets the button background */
  9579. get: function () {
  9580. return this._buttonBackground;
  9581. },
  9582. set: function (color) {
  9583. if (this._buttonBackground === color) {
  9584. return;
  9585. }
  9586. this._buttonBackground = color;
  9587. this._setButtonBackground();
  9588. },
  9589. enumerable: true,
  9590. configurable: true
  9591. });
  9592. SelectionPanel.prototype._setButtonBackground = function () {
  9593. for (var i = 0; i < this._groups.length; i++) {
  9594. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9595. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9596. }
  9597. }
  9598. };
  9599. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9600. /** Gets or sets the color of separator bar */
  9601. get: function () {
  9602. return this._barColor;
  9603. },
  9604. set: function (color) {
  9605. if (this._barColor === color) {
  9606. return;
  9607. }
  9608. this._barColor = color;
  9609. this._setBarColor();
  9610. },
  9611. enumerable: true,
  9612. configurable: true
  9613. });
  9614. SelectionPanel.prototype._setBarColor = function () {
  9615. for (var i = 0; i < this._bars.length; i++) {
  9616. this._bars[i].children[0].background = this._barColor;
  9617. }
  9618. };
  9619. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9620. /** Gets or sets the height of separator bar */
  9621. get: function () {
  9622. return this._barHeight;
  9623. },
  9624. set: function (value) {
  9625. if (this._barHeight === value) {
  9626. return;
  9627. }
  9628. this._barHeight = value;
  9629. this._setBarHeight();
  9630. },
  9631. enumerable: true,
  9632. configurable: true
  9633. });
  9634. SelectionPanel.prototype._setBarHeight = function () {
  9635. for (var i = 0; i < this._bars.length; i++) {
  9636. this._bars[i].children[0].height = this._barHeight;
  9637. }
  9638. };
  9639. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9640. /** Gets or sets the height of spacers*/
  9641. get: function () {
  9642. return this._spacerHeight;
  9643. },
  9644. set: function (value) {
  9645. if (this._spacerHeight === value) {
  9646. return;
  9647. }
  9648. this._spacerHeight = value;
  9649. this._setSpacerHeight();
  9650. },
  9651. enumerable: true,
  9652. configurable: true
  9653. });
  9654. SelectionPanel.prototype._setSpacerHeight = function () {
  9655. for (var i = 0; i < this._bars.length; i++) {
  9656. this._bars[i].height = this._spacerHeight;
  9657. }
  9658. };
  9659. /** Adds a bar between groups */
  9660. SelectionPanel.prototype._addSpacer = function () {
  9661. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9662. separator.width = 1;
  9663. separator.height = this._spacerHeight;
  9664. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9665. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9666. bar.width = 1;
  9667. bar.height = this._barHeight;
  9668. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9669. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9670. bar.background = this._barColor;
  9671. bar.color = "transparent";
  9672. separator.addControl(bar);
  9673. this._panel.addControl(separator);
  9674. this._bars.push(separator);
  9675. };
  9676. /** Add a group to the selection panel
  9677. * @param group is the selector group to add
  9678. */
  9679. SelectionPanel.prototype.addGroup = function (group) {
  9680. if (this._groups.length > 0) {
  9681. this._addSpacer();
  9682. }
  9683. this._panel.addControl(group.groupPanel);
  9684. this._groups.push(group);
  9685. group.groupPanel.children[0].color = this._headerColor;
  9686. for (var j = 0; j < group.selectors.length; j++) {
  9687. group._setSelectorButtonColor(j, this._buttonColor);
  9688. group._setSelectorButtonBackground(j, this._buttonBackground);
  9689. }
  9690. };
  9691. /** Remove the group from the given position
  9692. * @param groupNb is the position of the group in the list
  9693. */
  9694. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9695. if (groupNb < 0 || groupNb >= this._groups.length) {
  9696. return;
  9697. }
  9698. var group = this._groups[groupNb];
  9699. this._panel.removeControl(group.groupPanel);
  9700. this._groups.splice(groupNb, 1);
  9701. if (groupNb < this._bars.length) {
  9702. this._panel.removeControl(this._bars[groupNb]);
  9703. this._bars.splice(groupNb, 1);
  9704. }
  9705. };
  9706. /** Change a group header label
  9707. * @param label is the new group header label
  9708. * @param groupNb is the number of the group to relabel
  9709. * */
  9710. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9711. if (groupNb < 0 || groupNb >= this._groups.length) {
  9712. return;
  9713. }
  9714. var group = this._groups[groupNb];
  9715. group.groupPanel.children[0].text = label;
  9716. };
  9717. /** Change selector label to the one given
  9718. * @param label is the new selector label
  9719. * @param groupNb is the number of the groupcontaining the selector
  9720. * @param selectorNb is the number of the selector within a group to relabel
  9721. * */
  9722. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9723. if (groupNb < 0 || groupNb >= this._groups.length) {
  9724. return;
  9725. }
  9726. var group = this._groups[groupNb];
  9727. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9728. return;
  9729. }
  9730. group._setSelectorLabel(selectorNb, label);
  9731. };
  9732. /** For a given group position remove the selector at the given position
  9733. * @param groupNb is the number of the group to remove the selector from
  9734. * @param selectorNb is the number of the selector within the group
  9735. */
  9736. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9737. if (groupNb < 0 || groupNb >= this._groups.length) {
  9738. return;
  9739. }
  9740. var group = this._groups[groupNb];
  9741. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9742. return;
  9743. }
  9744. group.removeSelector(selectorNb);
  9745. };
  9746. /** For a given group position of correct type add a checkbox button
  9747. * @param groupNb is the number of the group to remove the selector from
  9748. * @param label is the label for the selector
  9749. * @param func is the function called when the Selector is checked
  9750. * @param checked is true when Selector is checked
  9751. */
  9752. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9753. if (func === void 0) { func = function () { }; }
  9754. if (checked === void 0) { checked = false; }
  9755. if (groupNb < 0 || groupNb >= this._groups.length) {
  9756. return;
  9757. }
  9758. var group = this._groups[groupNb];
  9759. group.addCheckbox(label, func, checked);
  9760. };
  9761. /** For a given group position of correct type add a radio button
  9762. * @param groupNb is the number of the group to remove the selector from
  9763. * @param label is the label for the selector
  9764. * @param func is the function called when the Selector is checked
  9765. * @param checked is true when Selector is checked
  9766. */
  9767. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9768. if (func === void 0) { func = function () { }; }
  9769. if (checked === void 0) { checked = false; }
  9770. if (groupNb < 0 || groupNb >= this._groups.length) {
  9771. return;
  9772. }
  9773. var group = this._groups[groupNb];
  9774. group.addRadio(label, func, checked);
  9775. };
  9776. /**
  9777. * For a given slider group add a slider
  9778. * @param groupNb is the number of the group to add the slider to
  9779. * @param label is the label for the Slider
  9780. * @param func is the function called when the Slider moves
  9781. * @param unit is a string describing the units used, eg degrees or metres
  9782. * @param min is the minimum value for the Slider
  9783. * @param max is the maximum value for the Slider
  9784. * @param value is the start value for the Slider between min and max
  9785. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9786. */
  9787. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9788. if (func === void 0) { func = function () { }; }
  9789. if (unit === void 0) { unit = "Units"; }
  9790. if (min === void 0) { min = 0; }
  9791. if (max === void 0) { max = 0; }
  9792. if (value === void 0) { value = 0; }
  9793. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9794. if (groupNb < 0 || groupNb >= this._groups.length) {
  9795. return;
  9796. }
  9797. var group = this._groups[groupNb];
  9798. group.addSlider(label, func, unit, min, max, value, onVal);
  9799. };
  9800. return SelectionPanel;
  9801. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9802. /***/ }),
  9803. /***/ "./2D/controls/sliders/baseSlider.ts":
  9804. /*!*******************************************!*\
  9805. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9806. \*******************************************/
  9807. /*! exports provided: BaseSlider */
  9808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9809. "use strict";
  9810. __webpack_require__.r(__webpack_exports__);
  9811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9812. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9813. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9814. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9815. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9816. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9817. /**
  9818. * Class used to create slider controls
  9819. */
  9820. var BaseSlider = /** @class */ (function (_super) {
  9821. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9822. /**
  9823. * Creates a new BaseSlider
  9824. * @param name defines the control name
  9825. */
  9826. function BaseSlider(name) {
  9827. var _this = _super.call(this, name) || this;
  9828. _this.name = name;
  9829. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9830. _this._minimum = 0;
  9831. _this._maximum = 100;
  9832. _this._value = 50;
  9833. _this._isVertical = false;
  9834. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9835. _this._isThumbClamped = false;
  9836. _this._displayThumb = true;
  9837. _this._step = 0;
  9838. _this._lastPointerDownID = -1;
  9839. // Shared rendering info
  9840. _this._effectiveBarOffset = 0;
  9841. /** Observable raised when the sldier value changes */
  9842. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9843. // Events
  9844. _this._pointerIsDown = false;
  9845. _this.isPointerBlocker = true;
  9846. return _this;
  9847. }
  9848. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9849. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9850. get: function () {
  9851. return this._displayThumb;
  9852. },
  9853. set: function (value) {
  9854. if (this._displayThumb === value) {
  9855. return;
  9856. }
  9857. this._displayThumb = value;
  9858. this._markAsDirty();
  9859. },
  9860. enumerable: true,
  9861. configurable: true
  9862. });
  9863. Object.defineProperty(BaseSlider.prototype, "step", {
  9864. /** Gets or sets a step to apply to values (0 by default) */
  9865. get: function () {
  9866. return this._step;
  9867. },
  9868. set: function (value) {
  9869. if (this._step === value) {
  9870. return;
  9871. }
  9872. this._step = value;
  9873. this._markAsDirty();
  9874. },
  9875. enumerable: true,
  9876. configurable: true
  9877. });
  9878. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9879. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9880. get: function () {
  9881. return this._barOffset.toString(this._host);
  9882. },
  9883. set: function (value) {
  9884. if (this._barOffset.toString(this._host) === value) {
  9885. return;
  9886. }
  9887. if (this._barOffset.fromString(value)) {
  9888. this._markAsDirty();
  9889. }
  9890. },
  9891. enumerable: true,
  9892. configurable: true
  9893. });
  9894. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9895. /** Gets main bar offset in pixels*/
  9896. get: function () {
  9897. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9898. },
  9899. enumerable: true,
  9900. configurable: true
  9901. });
  9902. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9903. /** Gets or sets thumb width */
  9904. get: function () {
  9905. return this._thumbWidth.toString(this._host);
  9906. },
  9907. set: function (value) {
  9908. if (this._thumbWidth.toString(this._host) === value) {
  9909. return;
  9910. }
  9911. if (this._thumbWidth.fromString(value)) {
  9912. this._markAsDirty();
  9913. }
  9914. },
  9915. enumerable: true,
  9916. configurable: true
  9917. });
  9918. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9919. /** Gets thumb width in pixels */
  9920. get: function () {
  9921. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9922. },
  9923. enumerable: true,
  9924. configurable: true
  9925. });
  9926. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9927. /** Gets or sets minimum value */
  9928. get: function () {
  9929. return this._minimum;
  9930. },
  9931. set: function (value) {
  9932. if (this._minimum === value) {
  9933. return;
  9934. }
  9935. this._minimum = value;
  9936. this._markAsDirty();
  9937. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9938. },
  9939. enumerable: true,
  9940. configurable: true
  9941. });
  9942. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9943. /** Gets or sets maximum value */
  9944. get: function () {
  9945. return this._maximum;
  9946. },
  9947. set: function (value) {
  9948. if (this._maximum === value) {
  9949. return;
  9950. }
  9951. this._maximum = value;
  9952. this._markAsDirty();
  9953. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9954. },
  9955. enumerable: true,
  9956. configurable: true
  9957. });
  9958. Object.defineProperty(BaseSlider.prototype, "value", {
  9959. /** Gets or sets current value */
  9960. get: function () {
  9961. return this._value;
  9962. },
  9963. set: function (value) {
  9964. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9965. if (this._value === value) {
  9966. return;
  9967. }
  9968. this._value = value;
  9969. this._markAsDirty();
  9970. this.onValueChangedObservable.notifyObservers(this._value);
  9971. },
  9972. enumerable: true,
  9973. configurable: true
  9974. });
  9975. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9976. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9977. get: function () {
  9978. return this._isVertical;
  9979. },
  9980. set: function (value) {
  9981. if (this._isVertical === value) {
  9982. return;
  9983. }
  9984. this._isVertical = value;
  9985. this._markAsDirty();
  9986. },
  9987. enumerable: true,
  9988. configurable: true
  9989. });
  9990. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9991. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9992. get: function () {
  9993. return this._isThumbClamped;
  9994. },
  9995. set: function (value) {
  9996. if (this._isThumbClamped === value) {
  9997. return;
  9998. }
  9999. this._isThumbClamped = value;
  10000. this._markAsDirty();
  10001. },
  10002. enumerable: true,
  10003. configurable: true
  10004. });
  10005. BaseSlider.prototype._getTypeName = function () {
  10006. return "BaseSlider";
  10007. };
  10008. BaseSlider.prototype._getThumbPosition = function () {
  10009. if (this.isVertical) {
  10010. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10011. }
  10012. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10013. };
  10014. BaseSlider.prototype._getThumbThickness = function (type) {
  10015. var thumbThickness = 0;
  10016. switch (type) {
  10017. case "circle":
  10018. if (this._thumbWidth.isPixel) {
  10019. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10020. }
  10021. else {
  10022. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10023. }
  10024. break;
  10025. case "rectangle":
  10026. if (this._thumbWidth.isPixel) {
  10027. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10028. }
  10029. else {
  10030. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10031. }
  10032. }
  10033. return thumbThickness;
  10034. };
  10035. BaseSlider.prototype._prepareRenderingData = function (type) {
  10036. // Main bar
  10037. this._effectiveBarOffset = 0;
  10038. this._renderLeft = this._currentMeasure.left;
  10039. this._renderTop = this._currentMeasure.top;
  10040. this._renderWidth = this._currentMeasure.width;
  10041. this._renderHeight = this._currentMeasure.height;
  10042. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10043. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10044. this._effectiveThumbThickness = this._getThumbThickness(type);
  10045. if (this.displayThumb) {
  10046. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10047. }
  10048. //throw error when height is less than width for vertical slider
  10049. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10050. console.error("Height should be greater than width");
  10051. return;
  10052. }
  10053. if (this._barOffset.isPixel) {
  10054. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10055. }
  10056. else {
  10057. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10058. }
  10059. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10060. if (this.isVertical) {
  10061. this._renderLeft += this._effectiveBarOffset;
  10062. if (!this.isThumbClamped && this.displayThumb) {
  10063. this._renderTop += (this._effectiveThumbThickness / 2);
  10064. }
  10065. this._renderHeight = this._backgroundBoxLength;
  10066. this._renderWidth = this._backgroundBoxThickness;
  10067. }
  10068. else {
  10069. this._renderTop += this._effectiveBarOffset;
  10070. if (!this.isThumbClamped && this.displayThumb) {
  10071. this._renderLeft += (this._effectiveThumbThickness / 2);
  10072. }
  10073. this._renderHeight = this._backgroundBoxThickness;
  10074. this._renderWidth = this._backgroundBoxLength;
  10075. }
  10076. };
  10077. /** @hidden */
  10078. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10079. if (this.rotation != 0) {
  10080. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10081. x = this._transformedPosition.x;
  10082. y = this._transformedPosition.y;
  10083. }
  10084. var value;
  10085. if (this._isVertical) {
  10086. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10087. }
  10088. else {
  10089. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10090. }
  10091. var mult = (1 / this._step) | 0;
  10092. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10093. };
  10094. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10095. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10096. return false;
  10097. }
  10098. this._pointerIsDown = true;
  10099. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10100. this._host._capturingControl[pointerId] = this;
  10101. this._lastPointerDownID = pointerId;
  10102. return true;
  10103. };
  10104. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10105. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10106. if (pointerId != this._lastPointerDownID) {
  10107. return;
  10108. }
  10109. if (this._pointerIsDown) {
  10110. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10111. }
  10112. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10113. };
  10114. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10115. this._pointerIsDown = false;
  10116. delete this._host._capturingControl[pointerId];
  10117. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10118. };
  10119. return BaseSlider;
  10120. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10121. /***/ }),
  10122. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10123. /*!*************************************************!*\
  10124. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10125. \*************************************************/
  10126. /*! exports provided: ImageBasedSlider */
  10127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10128. "use strict";
  10129. __webpack_require__.r(__webpack_exports__);
  10130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10132. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10133. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10134. /**
  10135. * Class used to create slider controls based on images
  10136. */
  10137. var ImageBasedSlider = /** @class */ (function (_super) {
  10138. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10139. /**
  10140. * Creates a new ImageBasedSlider
  10141. * @param name defines the control name
  10142. */
  10143. function ImageBasedSlider(name) {
  10144. var _this = _super.call(this, name) || this;
  10145. _this.name = name;
  10146. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10147. return _this;
  10148. }
  10149. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10150. get: function () {
  10151. return this._displayThumb && this.thumbImage != null;
  10152. },
  10153. set: function (value) {
  10154. if (this._displayThumb === value) {
  10155. return;
  10156. }
  10157. this._displayThumb = value;
  10158. this._markAsDirty();
  10159. },
  10160. enumerable: true,
  10161. configurable: true
  10162. });
  10163. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10164. /**
  10165. * Gets or sets the image used to render the background
  10166. */
  10167. get: function () {
  10168. return this._backgroundImage;
  10169. },
  10170. set: function (value) {
  10171. var _this = this;
  10172. if (this._backgroundImage === value) {
  10173. return;
  10174. }
  10175. this._backgroundImage = value;
  10176. if (value && !value.isLoaded) {
  10177. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10178. }
  10179. this._markAsDirty();
  10180. },
  10181. enumerable: true,
  10182. configurable: true
  10183. });
  10184. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10185. /**
  10186. * Gets or sets the image used to render the value bar
  10187. */
  10188. get: function () {
  10189. return this._valueBarImage;
  10190. },
  10191. set: function (value) {
  10192. var _this = this;
  10193. if (this._valueBarImage === value) {
  10194. return;
  10195. }
  10196. this._valueBarImage = value;
  10197. if (value && !value.isLoaded) {
  10198. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10199. }
  10200. this._markAsDirty();
  10201. },
  10202. enumerable: true,
  10203. configurable: true
  10204. });
  10205. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10206. /**
  10207. * Gets or sets the image used to render the thumb
  10208. */
  10209. get: function () {
  10210. return this._thumbImage;
  10211. },
  10212. set: function (value) {
  10213. var _this = this;
  10214. if (this._thumbImage === value) {
  10215. return;
  10216. }
  10217. this._thumbImage = value;
  10218. if (value && !value.isLoaded) {
  10219. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10220. }
  10221. this._markAsDirty();
  10222. },
  10223. enumerable: true,
  10224. configurable: true
  10225. });
  10226. ImageBasedSlider.prototype._getTypeName = function () {
  10227. return "ImageBasedSlider";
  10228. };
  10229. ImageBasedSlider.prototype._draw = function (context) {
  10230. context.save();
  10231. this._applyStates(context);
  10232. this._prepareRenderingData("rectangle");
  10233. var thumbPosition = this._getThumbPosition();
  10234. var left = this._renderLeft;
  10235. var top = this._renderTop;
  10236. var width = this._renderWidth;
  10237. var height = this._renderHeight;
  10238. // Background
  10239. if (this._backgroundImage) {
  10240. this._tempMeasure.copyFromFloats(left, top, width, height);
  10241. if (this.isThumbClamped && this.displayThumb) {
  10242. if (this.isVertical) {
  10243. this._tempMeasure.height += this._effectiveThumbThickness;
  10244. }
  10245. else {
  10246. this._tempMeasure.width += this._effectiveThumbThickness;
  10247. }
  10248. }
  10249. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10250. this._backgroundImage._draw(context);
  10251. }
  10252. // Bar
  10253. if (this._valueBarImage) {
  10254. if (this.isVertical) {
  10255. if (this.isThumbClamped && this.displayThumb) {
  10256. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10257. }
  10258. else {
  10259. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10260. }
  10261. }
  10262. else {
  10263. if (this.isThumbClamped && this.displayThumb) {
  10264. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10265. }
  10266. else {
  10267. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10268. }
  10269. }
  10270. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10271. this._valueBarImage._draw(context);
  10272. }
  10273. // Thumb
  10274. if (this.displayThumb) {
  10275. if (this.isVertical) {
  10276. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10277. }
  10278. else {
  10279. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10280. }
  10281. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10282. this._thumbImage._draw(context);
  10283. }
  10284. context.restore();
  10285. };
  10286. return ImageBasedSlider;
  10287. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10288. /***/ }),
  10289. /***/ "./2D/controls/sliders/scrollBar.ts":
  10290. /*!******************************************!*\
  10291. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10292. \******************************************/
  10293. /*! exports provided: ScrollBar */
  10294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10295. "use strict";
  10296. __webpack_require__.r(__webpack_exports__);
  10297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10299. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10300. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10301. /**
  10302. * Class used to create slider controls
  10303. */
  10304. var ScrollBar = /** @class */ (function (_super) {
  10305. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10306. /**
  10307. * Creates a new Slider
  10308. * @param name defines the control name
  10309. */
  10310. function ScrollBar(name) {
  10311. var _this = _super.call(this, name) || this;
  10312. _this.name = name;
  10313. _this._background = "black";
  10314. _this._borderColor = "white";
  10315. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10316. return _this;
  10317. }
  10318. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10319. /** Gets or sets border color */
  10320. get: function () {
  10321. return this._borderColor;
  10322. },
  10323. set: function (value) {
  10324. if (this._borderColor === value) {
  10325. return;
  10326. }
  10327. this._borderColor = value;
  10328. this._markAsDirty();
  10329. },
  10330. enumerable: true,
  10331. configurable: true
  10332. });
  10333. Object.defineProperty(ScrollBar.prototype, "background", {
  10334. /** Gets or sets background color */
  10335. get: function () {
  10336. return this._background;
  10337. },
  10338. set: function (value) {
  10339. if (this._background === value) {
  10340. return;
  10341. }
  10342. this._background = value;
  10343. this._markAsDirty();
  10344. },
  10345. enumerable: true,
  10346. configurable: true
  10347. });
  10348. ScrollBar.prototype._getTypeName = function () {
  10349. return "Scrollbar";
  10350. };
  10351. ScrollBar.prototype._getThumbThickness = function () {
  10352. var thumbThickness = 0;
  10353. if (this._thumbWidth.isPixel) {
  10354. thumbThickness = this._thumbWidth.getValue(this._host);
  10355. }
  10356. else {
  10357. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10358. }
  10359. return thumbThickness;
  10360. };
  10361. ScrollBar.prototype._draw = function (context) {
  10362. context.save();
  10363. this._applyStates(context);
  10364. this._prepareRenderingData("rectangle");
  10365. var left = this._renderLeft;
  10366. var thumbPosition = this._getThumbPosition();
  10367. context.fillStyle = this._background;
  10368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10369. // Value bar
  10370. context.fillStyle = this.color;
  10371. // Thumb
  10372. if (this.isVertical) {
  10373. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10374. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10375. this._thumbMeasure.width = this._currentMeasure.width;
  10376. this._thumbMeasure.height = this._effectiveThumbThickness;
  10377. }
  10378. else {
  10379. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10380. this._thumbMeasure.top = this._currentMeasure.top;
  10381. this._thumbMeasure.width = this._effectiveThumbThickness;
  10382. this._thumbMeasure.height = this._currentMeasure.height;
  10383. }
  10384. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10385. context.restore();
  10386. };
  10387. /** @hidden */
  10388. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10389. if (this.rotation != 0) {
  10390. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10391. x = this._transformedPosition.x;
  10392. y = this._transformedPosition.y;
  10393. }
  10394. if (this._first) {
  10395. this._first = false;
  10396. this._originX = x;
  10397. this._originY = y;
  10398. // Check if move is required
  10399. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10400. if (this.isVertical) {
  10401. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10402. }
  10403. else {
  10404. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10405. }
  10406. }
  10407. }
  10408. // Delta mode
  10409. var delta = 0;
  10410. if (this.isVertical) {
  10411. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10412. }
  10413. else {
  10414. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10415. }
  10416. this.value += delta * (this.maximum - this.minimum);
  10417. this._originX = x;
  10418. this._originY = y;
  10419. };
  10420. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10421. this._first = true;
  10422. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10423. };
  10424. return ScrollBar;
  10425. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10426. /***/ }),
  10427. /***/ "./2D/controls/sliders/slider.ts":
  10428. /*!***************************************!*\
  10429. !*** ./2D/controls/sliders/slider.ts ***!
  10430. \***************************************/
  10431. /*! exports provided: Slider */
  10432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10433. "use strict";
  10434. __webpack_require__.r(__webpack_exports__);
  10435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10437. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10438. /**
  10439. * Class used to create slider controls
  10440. */
  10441. var Slider = /** @class */ (function (_super) {
  10442. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10443. /**
  10444. * Creates a new Slider
  10445. * @param name defines the control name
  10446. */
  10447. function Slider(name) {
  10448. var _this = _super.call(this, name) || this;
  10449. _this.name = name;
  10450. _this._background = "black";
  10451. _this._borderColor = "white";
  10452. _this._isThumbCircle = false;
  10453. _this._displayValueBar = true;
  10454. return _this;
  10455. }
  10456. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10457. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10458. get: function () {
  10459. return this._displayValueBar;
  10460. },
  10461. set: function (value) {
  10462. if (this._displayValueBar === value) {
  10463. return;
  10464. }
  10465. this._displayValueBar = value;
  10466. this._markAsDirty();
  10467. },
  10468. enumerable: true,
  10469. configurable: true
  10470. });
  10471. Object.defineProperty(Slider.prototype, "borderColor", {
  10472. /** Gets or sets border color */
  10473. get: function () {
  10474. return this._borderColor;
  10475. },
  10476. set: function (value) {
  10477. if (this._borderColor === value) {
  10478. return;
  10479. }
  10480. this._borderColor = value;
  10481. this._markAsDirty();
  10482. },
  10483. enumerable: true,
  10484. configurable: true
  10485. });
  10486. Object.defineProperty(Slider.prototype, "background", {
  10487. /** Gets or sets background color */
  10488. get: function () {
  10489. return this._background;
  10490. },
  10491. set: function (value) {
  10492. if (this._background === value) {
  10493. return;
  10494. }
  10495. this._background = value;
  10496. this._markAsDirty();
  10497. },
  10498. enumerable: true,
  10499. configurable: true
  10500. });
  10501. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10502. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10503. get: function () {
  10504. return this._isThumbCircle;
  10505. },
  10506. set: function (value) {
  10507. if (this._isThumbCircle === value) {
  10508. return;
  10509. }
  10510. this._isThumbCircle = value;
  10511. this._markAsDirty();
  10512. },
  10513. enumerable: true,
  10514. configurable: true
  10515. });
  10516. Slider.prototype._getTypeName = function () {
  10517. return "Slider";
  10518. };
  10519. Slider.prototype._draw = function (context) {
  10520. context.save();
  10521. this._applyStates(context);
  10522. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10523. var left = this._renderLeft;
  10524. var top = this._renderTop;
  10525. var width = this._renderWidth;
  10526. var height = this._renderHeight;
  10527. var radius = 0;
  10528. if (this.isThumbClamped && this.isThumbCircle) {
  10529. if (this.isVertical) {
  10530. top += (this._effectiveThumbThickness / 2);
  10531. }
  10532. else {
  10533. left += (this._effectiveThumbThickness / 2);
  10534. }
  10535. radius = this._backgroundBoxThickness / 2;
  10536. }
  10537. else {
  10538. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10539. }
  10540. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10541. context.shadowColor = this.shadowColor;
  10542. context.shadowBlur = this.shadowBlur;
  10543. context.shadowOffsetX = this.shadowOffsetX;
  10544. context.shadowOffsetY = this.shadowOffsetY;
  10545. }
  10546. var thumbPosition = this._getThumbPosition();
  10547. context.fillStyle = this._background;
  10548. if (this.isVertical) {
  10549. if (this.isThumbClamped) {
  10550. if (this.isThumbCircle) {
  10551. context.beginPath();
  10552. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10553. context.fill();
  10554. context.fillRect(left, top, width, height);
  10555. }
  10556. else {
  10557. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10558. }
  10559. }
  10560. else {
  10561. context.fillRect(left, top, width, height);
  10562. }
  10563. }
  10564. else {
  10565. if (this.isThumbClamped) {
  10566. if (this.isThumbCircle) {
  10567. context.beginPath();
  10568. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10569. context.fill();
  10570. context.fillRect(left, top, width, height);
  10571. }
  10572. else {
  10573. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10574. }
  10575. }
  10576. else {
  10577. context.fillRect(left, top, width, height);
  10578. }
  10579. }
  10580. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10581. context.shadowBlur = 0;
  10582. context.shadowOffsetX = 0;
  10583. context.shadowOffsetY = 0;
  10584. }
  10585. // Value bar
  10586. context.fillStyle = this.color;
  10587. if (this._displayValueBar) {
  10588. if (this.isVertical) {
  10589. if (this.isThumbClamped) {
  10590. if (this.isThumbCircle) {
  10591. context.beginPath();
  10592. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10593. context.fill();
  10594. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10595. }
  10596. else {
  10597. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10598. }
  10599. }
  10600. else {
  10601. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10602. }
  10603. }
  10604. else {
  10605. if (this.isThumbClamped) {
  10606. if (this.isThumbCircle) {
  10607. context.beginPath();
  10608. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10609. context.fill();
  10610. context.fillRect(left, top, thumbPosition, height);
  10611. }
  10612. else {
  10613. context.fillRect(left, top, thumbPosition, height);
  10614. }
  10615. }
  10616. else {
  10617. context.fillRect(left, top, thumbPosition, height);
  10618. }
  10619. }
  10620. }
  10621. // Thumb
  10622. if (this.displayThumb) {
  10623. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10624. context.shadowColor = this.shadowColor;
  10625. context.shadowBlur = this.shadowBlur;
  10626. context.shadowOffsetX = this.shadowOffsetX;
  10627. context.shadowOffsetY = this.shadowOffsetY;
  10628. }
  10629. if (this._isThumbCircle) {
  10630. context.beginPath();
  10631. if (this.isVertical) {
  10632. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10633. }
  10634. else {
  10635. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10636. }
  10637. context.fill();
  10638. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10639. context.shadowBlur = 0;
  10640. context.shadowOffsetX = 0;
  10641. context.shadowOffsetY = 0;
  10642. }
  10643. context.strokeStyle = this._borderColor;
  10644. context.stroke();
  10645. }
  10646. else {
  10647. if (this.isVertical) {
  10648. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10649. }
  10650. else {
  10651. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10652. }
  10653. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10654. context.shadowBlur = 0;
  10655. context.shadowOffsetX = 0;
  10656. context.shadowOffsetY = 0;
  10657. }
  10658. context.strokeStyle = this._borderColor;
  10659. if (this.isVertical) {
  10660. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10661. }
  10662. else {
  10663. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10664. }
  10665. }
  10666. }
  10667. context.restore();
  10668. };
  10669. return Slider;
  10670. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10671. /***/ }),
  10672. /***/ "./2D/controls/stackPanel.ts":
  10673. /*!***********************************!*\
  10674. !*** ./2D/controls/stackPanel.ts ***!
  10675. \***********************************/
  10676. /*! exports provided: StackPanel */
  10677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10678. "use strict";
  10679. __webpack_require__.r(__webpack_exports__);
  10680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10682. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  10683. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10684. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10685. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10686. /**
  10687. * Class used to create a 2D stack panel container
  10688. */
  10689. var StackPanel = /** @class */ (function (_super) {
  10690. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10691. /**
  10692. * Creates a new StackPanel
  10693. * @param name defines control name
  10694. */
  10695. function StackPanel(name) {
  10696. var _this = _super.call(this, name) || this;
  10697. _this.name = name;
  10698. _this._isVertical = true;
  10699. _this._manualWidth = false;
  10700. _this._manualHeight = false;
  10701. _this._doNotTrackManualChanges = false;
  10702. /**
  10703. * Gets or sets a boolean indicating that layou warnings should be ignored
  10704. */
  10705. _this.ignoreLayoutWarnings = false;
  10706. return _this;
  10707. }
  10708. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10709. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10710. get: function () {
  10711. return this._isVertical;
  10712. },
  10713. set: function (value) {
  10714. if (this._isVertical === value) {
  10715. return;
  10716. }
  10717. this._isVertical = value;
  10718. this._markAsDirty();
  10719. },
  10720. enumerable: true,
  10721. configurable: true
  10722. });
  10723. Object.defineProperty(StackPanel.prototype, "width", {
  10724. get: function () {
  10725. return this._width.toString(this._host);
  10726. },
  10727. /**
  10728. * Gets or sets panel width.
  10729. * This value should not be set when in horizontal mode as it will be computed automatically
  10730. */
  10731. set: function (value) {
  10732. if (!this._doNotTrackManualChanges) {
  10733. this._manualWidth = true;
  10734. }
  10735. if (this._width.toString(this._host) === value) {
  10736. return;
  10737. }
  10738. if (this._width.fromString(value)) {
  10739. this._markAsDirty();
  10740. }
  10741. },
  10742. enumerable: true,
  10743. configurable: true
  10744. });
  10745. Object.defineProperty(StackPanel.prototype, "height", {
  10746. get: function () {
  10747. return this._height.toString(this._host);
  10748. },
  10749. /**
  10750. * Gets or sets panel height.
  10751. * This value should not be set when in vertical mode as it will be computed automatically
  10752. */
  10753. set: function (value) {
  10754. if (!this._doNotTrackManualChanges) {
  10755. this._manualHeight = true;
  10756. }
  10757. if (this._height.toString(this._host) === value) {
  10758. return;
  10759. }
  10760. if (this._height.fromString(value)) {
  10761. this._markAsDirty();
  10762. }
  10763. },
  10764. enumerable: true,
  10765. configurable: true
  10766. });
  10767. StackPanel.prototype._getTypeName = function () {
  10768. return "StackPanel";
  10769. };
  10770. /** @hidden */
  10771. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10772. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10773. var child = _a[_i];
  10774. if (this._isVertical) {
  10775. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10776. }
  10777. else {
  10778. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10779. }
  10780. }
  10781. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10782. };
  10783. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10784. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10785. this._measureForChildren.copyFrom(parentMeasure);
  10786. this._measureForChildren.left = this._currentMeasure.left;
  10787. this._measureForChildren.top = this._currentMeasure.top;
  10788. if (!this.isVertical || this._manualWidth) {
  10789. this._measureForChildren.width = this._currentMeasure.width;
  10790. }
  10791. if (this.isVertical || this._manualHeight) {
  10792. this._measureForChildren.height = this._currentMeasure.height;
  10793. }
  10794. };
  10795. StackPanel.prototype._postMeasure = function () {
  10796. var stackWidth = 0;
  10797. var stackHeight = 0;
  10798. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10799. var child = _a[_i];
  10800. if (!child.isVisible || child.notRenderable) {
  10801. continue;
  10802. }
  10803. if (this._isVertical) {
  10804. if (child.top !== stackHeight + "px") {
  10805. child.top = stackHeight + "px";
  10806. this._rebuildLayout = true;
  10807. child._top.ignoreAdaptiveScaling = true;
  10808. }
  10809. if (child._height.isPercentage) {
  10810. if (!this.ignoreLayoutWarnings) {
  10811. 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");
  10812. }
  10813. }
  10814. else {
  10815. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10816. }
  10817. }
  10818. else {
  10819. if (child.left !== stackWidth + "px") {
  10820. child.left = stackWidth + "px";
  10821. this._rebuildLayout = true;
  10822. child._left.ignoreAdaptiveScaling = true;
  10823. }
  10824. if (child._width.isPercentage) {
  10825. if (!this.ignoreLayoutWarnings) {
  10826. 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");
  10827. }
  10828. }
  10829. else {
  10830. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10831. }
  10832. }
  10833. }
  10834. this._doNotTrackManualChanges = true;
  10835. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10836. // User can now define their own height and width for stack panel.
  10837. var panelWidthChanged = false;
  10838. var panelHeightChanged = false;
  10839. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10840. var previousHeight = this.height;
  10841. this.height = stackHeight + "px";
  10842. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10843. }
  10844. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10845. var previousWidth = this.width;
  10846. this.width = stackWidth + "px";
  10847. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10848. }
  10849. if (panelHeightChanged) {
  10850. this._height.ignoreAdaptiveScaling = true;
  10851. }
  10852. if (panelWidthChanged) {
  10853. this._width.ignoreAdaptiveScaling = true;
  10854. }
  10855. this._doNotTrackManualChanges = false;
  10856. if (panelWidthChanged || panelHeightChanged) {
  10857. this._rebuildLayout = true;
  10858. }
  10859. _super.prototype._postMeasure.call(this);
  10860. };
  10861. return StackPanel;
  10862. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10863. /***/ }),
  10864. /***/ "./2D/controls/statics.ts":
  10865. /*!********************************!*\
  10866. !*** ./2D/controls/statics.ts ***!
  10867. \********************************/
  10868. /*! exports provided: name */
  10869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10870. "use strict";
  10871. __webpack_require__.r(__webpack_exports__);
  10872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10873. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10874. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10875. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10876. /**
  10877. * Forcing an export so that this code will execute
  10878. * @hidden
  10879. */
  10880. var name = "Statics";
  10881. /**
  10882. * Creates a stack panel that can be used to render headers
  10883. * @param control defines the control to associate with the header
  10884. * @param text defines the text of the header
  10885. * @param size defines the size of the header
  10886. * @param options defines options used to configure the header
  10887. * @returns a new StackPanel
  10888. */
  10889. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10890. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10891. var isHorizontal = options ? options.isHorizontal : true;
  10892. var controlFirst = options ? options.controlFirst : true;
  10893. panel.isVertical = !isHorizontal;
  10894. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10895. header.text = text;
  10896. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10897. if (isHorizontal) {
  10898. header.width = size;
  10899. }
  10900. else {
  10901. header.height = size;
  10902. }
  10903. if (controlFirst) {
  10904. panel.addControl(control);
  10905. panel.addControl(header);
  10906. header.paddingLeft = "5px";
  10907. }
  10908. else {
  10909. panel.addControl(header);
  10910. panel.addControl(control);
  10911. header.paddingRight = "5px";
  10912. }
  10913. header.shadowBlur = control.shadowBlur;
  10914. header.shadowColor = control.shadowColor;
  10915. header.shadowOffsetX = control.shadowOffsetX;
  10916. header.shadowOffsetY = control.shadowOffsetY;
  10917. return panel;
  10918. };
  10919. /***/ }),
  10920. /***/ "./2D/controls/textBlock.ts":
  10921. /*!**********************************!*\
  10922. !*** ./2D/controls/textBlock.ts ***!
  10923. \**********************************/
  10924. /*! exports provided: TextWrapping, TextBlock */
  10925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10926. "use strict";
  10927. __webpack_require__.r(__webpack_exports__);
  10928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10931. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10932. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10933. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10934. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10935. /**
  10936. * Enum that determines the text-wrapping mode to use.
  10937. */
  10938. var TextWrapping;
  10939. (function (TextWrapping) {
  10940. /**
  10941. * Clip the text when it's larger than Control.width; this is the default mode.
  10942. */
  10943. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10944. /**
  10945. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10946. */
  10947. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10948. /**
  10949. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10950. */
  10951. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10952. })(TextWrapping || (TextWrapping = {}));
  10953. /**
  10954. * Class used to create text block control
  10955. */
  10956. var TextBlock = /** @class */ (function (_super) {
  10957. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10958. /**
  10959. * Creates a new TextBlock object
  10960. * @param name defines the name of the control
  10961. * @param text defines the text to display (emptry string by default)
  10962. */
  10963. function TextBlock(
  10964. /**
  10965. * Defines the name of the control
  10966. */
  10967. name, text) {
  10968. if (text === void 0) { text = ""; }
  10969. var _this = _super.call(this, name) || this;
  10970. _this.name = name;
  10971. _this._text = "";
  10972. _this._textWrapping = TextWrapping.Clip;
  10973. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10974. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10975. _this._resizeToFit = false;
  10976. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10977. _this._outlineWidth = 0;
  10978. _this._outlineColor = "white";
  10979. /**
  10980. * An event triggered after the text is changed
  10981. */
  10982. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10983. /**
  10984. * An event triggered after the text was broken up into lines
  10985. */
  10986. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10987. _this.text = text;
  10988. return _this;
  10989. }
  10990. Object.defineProperty(TextBlock.prototype, "lines", {
  10991. /**
  10992. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10993. */
  10994. get: function () {
  10995. return this._lines;
  10996. },
  10997. enumerable: true,
  10998. configurable: true
  10999. });
  11000. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11001. /**
  11002. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11003. */
  11004. get: function () {
  11005. return this._resizeToFit;
  11006. },
  11007. /**
  11008. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11009. */
  11010. set: function (value) {
  11011. if (this._resizeToFit === value) {
  11012. return;
  11013. }
  11014. this._resizeToFit = value;
  11015. if (this._resizeToFit) {
  11016. this._width.ignoreAdaptiveScaling = true;
  11017. this._height.ignoreAdaptiveScaling = true;
  11018. }
  11019. this._markAsDirty();
  11020. },
  11021. enumerable: true,
  11022. configurable: true
  11023. });
  11024. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11025. /**
  11026. * Gets or sets a boolean indicating if text must be wrapped
  11027. */
  11028. get: function () {
  11029. return this._textWrapping;
  11030. },
  11031. /**
  11032. * Gets or sets a boolean indicating if text must be wrapped
  11033. */
  11034. set: function (value) {
  11035. if (this._textWrapping === value) {
  11036. return;
  11037. }
  11038. this._textWrapping = +value;
  11039. this._markAsDirty();
  11040. },
  11041. enumerable: true,
  11042. configurable: true
  11043. });
  11044. Object.defineProperty(TextBlock.prototype, "text", {
  11045. /**
  11046. * Gets or sets text to display
  11047. */
  11048. get: function () {
  11049. return this._text;
  11050. },
  11051. /**
  11052. * Gets or sets text to display
  11053. */
  11054. set: function (value) {
  11055. if (this._text === value) {
  11056. return;
  11057. }
  11058. this._text = value;
  11059. this._markAsDirty();
  11060. this.onTextChangedObservable.notifyObservers(this);
  11061. },
  11062. enumerable: true,
  11063. configurable: true
  11064. });
  11065. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11066. /**
  11067. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11068. */
  11069. get: function () {
  11070. return this._textHorizontalAlignment;
  11071. },
  11072. /**
  11073. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11074. */
  11075. set: function (value) {
  11076. if (this._textHorizontalAlignment === value) {
  11077. return;
  11078. }
  11079. this._textHorizontalAlignment = value;
  11080. this._markAsDirty();
  11081. },
  11082. enumerable: true,
  11083. configurable: true
  11084. });
  11085. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11086. /**
  11087. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11088. */
  11089. get: function () {
  11090. return this._textVerticalAlignment;
  11091. },
  11092. /**
  11093. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11094. */
  11095. set: function (value) {
  11096. if (this._textVerticalAlignment === value) {
  11097. return;
  11098. }
  11099. this._textVerticalAlignment = value;
  11100. this._markAsDirty();
  11101. },
  11102. enumerable: true,
  11103. configurable: true
  11104. });
  11105. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11106. /**
  11107. * Gets or sets line spacing value
  11108. */
  11109. get: function () {
  11110. return this._lineSpacing.toString(this._host);
  11111. },
  11112. /**
  11113. * Gets or sets line spacing value
  11114. */
  11115. set: function (value) {
  11116. if (this._lineSpacing.fromString(value)) {
  11117. this._markAsDirty();
  11118. }
  11119. },
  11120. enumerable: true,
  11121. configurable: true
  11122. });
  11123. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11124. /**
  11125. * Gets or sets outlineWidth of the text to display
  11126. */
  11127. get: function () {
  11128. return this._outlineWidth;
  11129. },
  11130. /**
  11131. * Gets or sets outlineWidth of the text to display
  11132. */
  11133. set: function (value) {
  11134. if (this._outlineWidth === value) {
  11135. return;
  11136. }
  11137. this._outlineWidth = value;
  11138. this._markAsDirty();
  11139. },
  11140. enumerable: true,
  11141. configurable: true
  11142. });
  11143. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11144. /**
  11145. * Gets or sets outlineColor of the text to display
  11146. */
  11147. get: function () {
  11148. return this._outlineColor;
  11149. },
  11150. /**
  11151. * Gets or sets outlineColor of the text to display
  11152. */
  11153. set: function (value) {
  11154. if (this._outlineColor === value) {
  11155. return;
  11156. }
  11157. this._outlineColor = value;
  11158. this._markAsDirty();
  11159. },
  11160. enumerable: true,
  11161. configurable: true
  11162. });
  11163. TextBlock.prototype._getTypeName = function () {
  11164. return "TextBlock";
  11165. };
  11166. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11167. if (!this._fontOffset) {
  11168. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11169. }
  11170. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11171. // Prepare lines
  11172. this._lines = this._breakLines(this._currentMeasure.width, context);
  11173. this.onLinesReadyObservable.notifyObservers(this);
  11174. var maxLineWidth = 0;
  11175. for (var i = 0; i < this._lines.length; i++) {
  11176. var line = this._lines[i];
  11177. if (line.width > maxLineWidth) {
  11178. maxLineWidth = line.width;
  11179. }
  11180. }
  11181. if (this._resizeToFit) {
  11182. if (this._textWrapping === TextWrapping.Clip) {
  11183. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11184. if (newWidth !== this._width.internalValue) {
  11185. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11186. this._rebuildLayout = true;
  11187. }
  11188. }
  11189. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11190. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11191. var lineSpacing = 0;
  11192. if (this._lineSpacing.isPixel) {
  11193. lineSpacing = this._lineSpacing.getValue(this._host);
  11194. }
  11195. else {
  11196. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11197. }
  11198. newHeight += (this._lines.length - 1) * lineSpacing;
  11199. }
  11200. if (newHeight !== this._height.internalValue) {
  11201. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11202. this._rebuildLayout = true;
  11203. }
  11204. }
  11205. };
  11206. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11207. var width = this._currentMeasure.width;
  11208. var x = 0;
  11209. switch (this._textHorizontalAlignment) {
  11210. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11211. x = 0;
  11212. break;
  11213. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11214. x = width - textWidth;
  11215. break;
  11216. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11217. x = (width - textWidth) / 2;
  11218. break;
  11219. }
  11220. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11221. context.shadowColor = this.shadowColor;
  11222. context.shadowBlur = this.shadowBlur;
  11223. context.shadowOffsetX = this.shadowOffsetX;
  11224. context.shadowOffsetY = this.shadowOffsetY;
  11225. }
  11226. if (this.outlineWidth) {
  11227. context.strokeText(text, this._currentMeasure.left + x, y);
  11228. }
  11229. context.fillText(text, this._currentMeasure.left + x, y);
  11230. };
  11231. /** @hidden */
  11232. TextBlock.prototype._draw = function (context) {
  11233. context.save();
  11234. this._applyStates(context);
  11235. // Render lines
  11236. this._renderLines(context);
  11237. context.restore();
  11238. };
  11239. TextBlock.prototype._applyStates = function (context) {
  11240. _super.prototype._applyStates.call(this, context);
  11241. if (this.outlineWidth) {
  11242. context.lineWidth = this.outlineWidth;
  11243. context.strokeStyle = this.outlineColor;
  11244. }
  11245. };
  11246. TextBlock.prototype._breakLines = function (refWidth, context) {
  11247. var lines = [];
  11248. var _lines = this.text.split("\n");
  11249. if (this._textWrapping === TextWrapping.Ellipsis) {
  11250. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11251. var _line = _lines_1[_i];
  11252. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11253. }
  11254. }
  11255. else if (this._textWrapping === TextWrapping.WordWrap) {
  11256. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11257. var _line = _lines_2[_a];
  11258. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11259. }
  11260. }
  11261. else {
  11262. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11263. var _line = _lines_3[_b];
  11264. lines.push(this._parseLine(_line, context));
  11265. }
  11266. }
  11267. return lines;
  11268. };
  11269. TextBlock.prototype._parseLine = function (line, context) {
  11270. if (line === void 0) { line = ''; }
  11271. return { text: line, width: context.measureText(line).width };
  11272. };
  11273. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11274. if (line === void 0) { line = ''; }
  11275. var lineWidth = context.measureText(line).width;
  11276. if (lineWidth > width) {
  11277. line += '…';
  11278. }
  11279. while (line.length > 2 && lineWidth > width) {
  11280. line = line.slice(0, -2) + '…';
  11281. lineWidth = context.measureText(line).width;
  11282. }
  11283. return { text: line, width: lineWidth };
  11284. };
  11285. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11286. if (line === void 0) { line = ''; }
  11287. var lines = [];
  11288. var words = line.split(' ');
  11289. var lineWidth = 0;
  11290. for (var n = 0; n < words.length; n++) {
  11291. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11292. var metrics = context.measureText(testLine);
  11293. var testWidth = metrics.width;
  11294. if (testWidth > width && n > 0) {
  11295. lines.push({ text: line, width: lineWidth });
  11296. line = words[n];
  11297. lineWidth = context.measureText(line).width;
  11298. }
  11299. else {
  11300. lineWidth = testWidth;
  11301. line = testLine;
  11302. }
  11303. }
  11304. lines.push({ text: line, width: lineWidth });
  11305. return lines;
  11306. };
  11307. TextBlock.prototype._renderLines = function (context) {
  11308. var height = this._currentMeasure.height;
  11309. var rootY = 0;
  11310. switch (this._textVerticalAlignment) {
  11311. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11312. rootY = this._fontOffset.ascent;
  11313. break;
  11314. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11315. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11316. break;
  11317. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11318. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11319. break;
  11320. }
  11321. rootY += this._currentMeasure.top;
  11322. for (var i = 0; i < this._lines.length; i++) {
  11323. var line = this._lines[i];
  11324. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11325. if (this._lineSpacing.isPixel) {
  11326. rootY += this._lineSpacing.getValue(this._host);
  11327. }
  11328. else {
  11329. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11330. }
  11331. }
  11332. this._drawText(line.text, line.width, rootY, context);
  11333. rootY += this._fontOffset.height;
  11334. }
  11335. };
  11336. /**
  11337. * Given a width constraint applied on the text block, find the expected height
  11338. * @returns expected height
  11339. */
  11340. TextBlock.prototype.computeExpectedHeight = function () {
  11341. if (this.text && this.widthInPixels) {
  11342. var context_1 = document.createElement('canvas').getContext('2d');
  11343. if (context_1) {
  11344. this._applyStates(context_1);
  11345. if (!this._fontOffset) {
  11346. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11347. }
  11348. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11349. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11350. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11351. var lineSpacing = 0;
  11352. if (this._lineSpacing.isPixel) {
  11353. lineSpacing = this._lineSpacing.getValue(this._host);
  11354. }
  11355. else {
  11356. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11357. }
  11358. newHeight += (lines.length - 1) * lineSpacing;
  11359. }
  11360. return newHeight;
  11361. }
  11362. }
  11363. return 0;
  11364. };
  11365. TextBlock.prototype.dispose = function () {
  11366. _super.prototype.dispose.call(this);
  11367. this.onTextChangedObservable.clear();
  11368. };
  11369. return TextBlock;
  11370. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11371. /***/ }),
  11372. /***/ "./2D/controls/virtualKeyboard.ts":
  11373. /*!****************************************!*\
  11374. !*** ./2D/controls/virtualKeyboard.ts ***!
  11375. \****************************************/
  11376. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11378. "use strict";
  11379. __webpack_require__.r(__webpack_exports__);
  11380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11383. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11384. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11385. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11386. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11387. /**
  11388. * Class used to store key control properties
  11389. */
  11390. var KeyPropertySet = /** @class */ (function () {
  11391. function KeyPropertySet() {
  11392. }
  11393. return KeyPropertySet;
  11394. }());
  11395. /**
  11396. * Class used to create virtual keyboard
  11397. */
  11398. var VirtualKeyboard = /** @class */ (function (_super) {
  11399. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11400. function VirtualKeyboard() {
  11401. var _this = _super !== null && _super.apply(this, arguments) || this;
  11402. /** Observable raised when a key is pressed */
  11403. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11404. /** Gets or sets default key button width */
  11405. _this.defaultButtonWidth = "40px";
  11406. /** Gets or sets default key button height */
  11407. _this.defaultButtonHeight = "40px";
  11408. /** Gets or sets default key button left padding */
  11409. _this.defaultButtonPaddingLeft = "2px";
  11410. /** Gets or sets default key button right padding */
  11411. _this.defaultButtonPaddingRight = "2px";
  11412. /** Gets or sets default key button top padding */
  11413. _this.defaultButtonPaddingTop = "2px";
  11414. /** Gets or sets default key button bottom padding */
  11415. _this.defaultButtonPaddingBottom = "2px";
  11416. /** Gets or sets default key button foreground color */
  11417. _this.defaultButtonColor = "#DDD";
  11418. /** Gets or sets default key button background color */
  11419. _this.defaultButtonBackground = "#070707";
  11420. /** Gets or sets shift button foreground color */
  11421. _this.shiftButtonColor = "#7799FF";
  11422. /** Gets or sets shift button thickness*/
  11423. _this.selectedShiftThickness = 1;
  11424. /** Gets shift key state */
  11425. _this.shiftState = 0;
  11426. _this._currentlyConnectedInputText = null;
  11427. _this._connectedInputTexts = [];
  11428. _this._onKeyPressObserver = null;
  11429. return _this;
  11430. }
  11431. VirtualKeyboard.prototype._getTypeName = function () {
  11432. return "VirtualKeyboard";
  11433. };
  11434. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11435. var _this = this;
  11436. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11437. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11438. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11439. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11440. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11441. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11442. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11443. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11444. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11445. button.thickness = 0;
  11446. button.isFocusInvisible = true;
  11447. button.shadowColor = this.shadowColor;
  11448. button.shadowBlur = this.shadowBlur;
  11449. button.shadowOffsetX = this.shadowOffsetX;
  11450. button.shadowOffsetY = this.shadowOffsetY;
  11451. button.onPointerUpObservable.add(function () {
  11452. _this.onKeyPressObservable.notifyObservers(key);
  11453. });
  11454. return button;
  11455. };
  11456. /**
  11457. * Adds a new row of keys
  11458. * @param keys defines the list of keys to add
  11459. * @param propertySets defines the associated property sets
  11460. */
  11461. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11462. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11463. panel.isVertical = false;
  11464. panel.isFocusInvisible = true;
  11465. var maxKey = null;
  11466. for (var i = 0; i < keys.length; i++) {
  11467. var properties = null;
  11468. if (propertySets && propertySets.length === keys.length) {
  11469. properties = propertySets[i];
  11470. }
  11471. var key = this._createKey(keys[i], properties);
  11472. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11473. maxKey = key;
  11474. }
  11475. panel.addControl(key);
  11476. }
  11477. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11478. this.addControl(panel);
  11479. };
  11480. /**
  11481. * Set the shift key to a specific state
  11482. * @param shiftState defines the new shift state
  11483. */
  11484. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11485. if (!this.children) {
  11486. return;
  11487. }
  11488. for (var i = 0; i < this.children.length; i++) {
  11489. var row = this.children[i];
  11490. if (!row || !row.children) {
  11491. continue;
  11492. }
  11493. var rowContainer = row;
  11494. for (var j = 0; j < rowContainer.children.length; j++) {
  11495. var button = rowContainer.children[j];
  11496. if (!button || !button.children[0]) {
  11497. continue;
  11498. }
  11499. var button_tblock = button.children[0];
  11500. if (button_tblock.text === "\u21E7") {
  11501. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11502. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11503. }
  11504. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11505. }
  11506. }
  11507. };
  11508. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11509. /** Gets the input text control currently attached to the keyboard */
  11510. get: function () {
  11511. return this._currentlyConnectedInputText;
  11512. },
  11513. enumerable: true,
  11514. configurable: true
  11515. });
  11516. /**
  11517. * Connects the keyboard with an input text control
  11518. *
  11519. * @param input defines the target control
  11520. */
  11521. VirtualKeyboard.prototype.connect = function (input) {
  11522. var _this = this;
  11523. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11524. if (inputTextAlreadyConnected) {
  11525. return;
  11526. }
  11527. if (this._onKeyPressObserver === null) {
  11528. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11529. if (!_this._currentlyConnectedInputText) {
  11530. return;
  11531. }
  11532. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11533. switch (key) {
  11534. case "\u21E7":
  11535. _this.shiftState++;
  11536. if (_this.shiftState > 2) {
  11537. _this.shiftState = 0;
  11538. }
  11539. _this.applyShiftState(_this.shiftState);
  11540. return;
  11541. case "\u2190":
  11542. _this._currentlyConnectedInputText.processKey(8);
  11543. return;
  11544. case "\u21B5":
  11545. _this._currentlyConnectedInputText.processKey(13);
  11546. return;
  11547. }
  11548. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11549. if (_this.shiftState === 1) {
  11550. _this.shiftState = 0;
  11551. _this.applyShiftState(_this.shiftState);
  11552. }
  11553. });
  11554. }
  11555. this.isVisible = false;
  11556. this._currentlyConnectedInputText = input;
  11557. input._connectedVirtualKeyboard = this;
  11558. // Events hooking
  11559. var onFocusObserver = input.onFocusObservable.add(function () {
  11560. _this._currentlyConnectedInputText = input;
  11561. input._connectedVirtualKeyboard = _this;
  11562. _this.isVisible = true;
  11563. });
  11564. var onBlurObserver = input.onBlurObservable.add(function () {
  11565. input._connectedVirtualKeyboard = null;
  11566. _this._currentlyConnectedInputText = null;
  11567. _this.isVisible = false;
  11568. });
  11569. this._connectedInputTexts.push({
  11570. input: input,
  11571. onBlurObserver: onBlurObserver,
  11572. onFocusObserver: onFocusObserver
  11573. });
  11574. };
  11575. /**
  11576. * Disconnects the keyboard from connected InputText controls
  11577. *
  11578. * @param input optionally defines a target control, otherwise all are disconnected
  11579. */
  11580. VirtualKeyboard.prototype.disconnect = function (input) {
  11581. var _this = this;
  11582. if (input) {
  11583. // .find not available on IE
  11584. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11585. if (filtered.length === 1) {
  11586. this._removeConnectedInputObservables(filtered[0]);
  11587. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11588. if (this._currentlyConnectedInputText === input) {
  11589. this._currentlyConnectedInputText = null;
  11590. }
  11591. }
  11592. }
  11593. else {
  11594. this._connectedInputTexts.forEach(function (connectedInputText) {
  11595. _this._removeConnectedInputObservables(connectedInputText);
  11596. });
  11597. this._connectedInputTexts = [];
  11598. }
  11599. if (this._connectedInputTexts.length === 0) {
  11600. this._currentlyConnectedInputText = null;
  11601. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11602. this._onKeyPressObserver = null;
  11603. }
  11604. };
  11605. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11606. connectedInputText.input._connectedVirtualKeyboard = null;
  11607. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11608. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11609. };
  11610. /**
  11611. * Release all resources
  11612. */
  11613. VirtualKeyboard.prototype.dispose = function () {
  11614. _super.prototype.dispose.call(this);
  11615. this.disconnect();
  11616. };
  11617. // Statics
  11618. /**
  11619. * Creates a new keyboard using a default layout
  11620. *
  11621. * @param name defines control name
  11622. * @returns a new VirtualKeyboard
  11623. */
  11624. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11625. var returnValue = new VirtualKeyboard(name);
  11626. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11627. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11628. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11629. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11630. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11631. return returnValue;
  11632. };
  11633. return VirtualKeyboard;
  11634. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11635. /***/ }),
  11636. /***/ "./2D/index.ts":
  11637. /*!*********************!*\
  11638. !*** ./2D/index.ts ***!
  11639. \*********************/
  11640. /*! 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, ScrollBar, name */
  11641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11642. "use strict";
  11643. __webpack_require__.r(__webpack_exports__);
  11644. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11676. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11678. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11680. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11683. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11685. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11687. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11689. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11691. /***/ }),
  11692. /***/ "./2D/math2D.ts":
  11693. /*!**********************!*\
  11694. !*** ./2D/math2D.ts ***!
  11695. \**********************/
  11696. /*! exports provided: Vector2WithInfo, Matrix2D */
  11697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11698. "use strict";
  11699. __webpack_require__.r(__webpack_exports__);
  11700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11703. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11704. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11705. /**
  11706. * Class used to transport Vector2 information for pointer events
  11707. */
  11708. var Vector2WithInfo = /** @class */ (function (_super) {
  11709. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11710. /**
  11711. * Creates a new Vector2WithInfo
  11712. * @param source defines the vector2 data to transport
  11713. * @param buttonIndex defines the current mouse button index
  11714. */
  11715. function Vector2WithInfo(source,
  11716. /** defines the current mouse button index */
  11717. buttonIndex) {
  11718. if (buttonIndex === void 0) { buttonIndex = 0; }
  11719. var _this = _super.call(this, source.x, source.y) || this;
  11720. _this.buttonIndex = buttonIndex;
  11721. return _this;
  11722. }
  11723. return Vector2WithInfo;
  11724. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11725. /** Class used to provide 2D matrix features */
  11726. var Matrix2D = /** @class */ (function () {
  11727. /**
  11728. * Creates a new matrix
  11729. * @param m00 defines value for (0, 0)
  11730. * @param m01 defines value for (0, 1)
  11731. * @param m10 defines value for (1, 0)
  11732. * @param m11 defines value for (1, 1)
  11733. * @param m20 defines value for (2, 0)
  11734. * @param m21 defines value for (2, 1)
  11735. */
  11736. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11737. /** Gets the internal array of 6 floats used to store matrix data */
  11738. this.m = new Float32Array(6);
  11739. this.fromValues(m00, m01, m10, m11, m20, m21);
  11740. }
  11741. /**
  11742. * Fills the matrix from direct values
  11743. * @param m00 defines value for (0, 0)
  11744. * @param m01 defines value for (0, 1)
  11745. * @param m10 defines value for (1, 0)
  11746. * @param m11 defines value for (1, 1)
  11747. * @param m20 defines value for (2, 0)
  11748. * @param m21 defines value for (2, 1)
  11749. * @returns the current modified matrix
  11750. */
  11751. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11752. this.m[0] = m00;
  11753. this.m[1] = m01;
  11754. this.m[2] = m10;
  11755. this.m[3] = m11;
  11756. this.m[4] = m20;
  11757. this.m[5] = m21;
  11758. return this;
  11759. };
  11760. /**
  11761. * Gets matrix determinant
  11762. * @returns the determinant
  11763. */
  11764. Matrix2D.prototype.determinant = function () {
  11765. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11766. };
  11767. /**
  11768. * Inverses the matrix and stores it in a target matrix
  11769. * @param result defines the target matrix
  11770. * @returns the current matrix
  11771. */
  11772. Matrix2D.prototype.invertToRef = function (result) {
  11773. var l0 = this.m[0];
  11774. var l1 = this.m[1];
  11775. var l2 = this.m[2];
  11776. var l3 = this.m[3];
  11777. var l4 = this.m[4];
  11778. var l5 = this.m[5];
  11779. var det = this.determinant();
  11780. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11781. result.m[0] = 0;
  11782. result.m[1] = 0;
  11783. result.m[2] = 0;
  11784. result.m[3] = 0;
  11785. result.m[4] = 0;
  11786. result.m[5] = 0;
  11787. return this;
  11788. }
  11789. var detDiv = 1 / det;
  11790. var det4 = l2 * l5 - l3 * l4;
  11791. var det5 = l1 * l4 - l0 * l5;
  11792. result.m[0] = l3 * detDiv;
  11793. result.m[1] = -l1 * detDiv;
  11794. result.m[2] = -l2 * detDiv;
  11795. result.m[3] = l0 * detDiv;
  11796. result.m[4] = det4 * detDiv;
  11797. result.m[5] = det5 * detDiv;
  11798. return this;
  11799. };
  11800. /**
  11801. * Multiplies the current matrix with another one
  11802. * @param other defines the second operand
  11803. * @param result defines the target matrix
  11804. * @returns the current matrix
  11805. */
  11806. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11807. var l0 = this.m[0];
  11808. var l1 = this.m[1];
  11809. var l2 = this.m[2];
  11810. var l3 = this.m[3];
  11811. var l4 = this.m[4];
  11812. var l5 = this.m[5];
  11813. var r0 = other.m[0];
  11814. var r1 = other.m[1];
  11815. var r2 = other.m[2];
  11816. var r3 = other.m[3];
  11817. var r4 = other.m[4];
  11818. var r5 = other.m[5];
  11819. result.m[0] = l0 * r0 + l1 * r2;
  11820. result.m[1] = l0 * r1 + l1 * r3;
  11821. result.m[2] = l2 * r0 + l3 * r2;
  11822. result.m[3] = l2 * r1 + l3 * r3;
  11823. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11824. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11825. return this;
  11826. };
  11827. /**
  11828. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11829. * @param x defines the x coordinate to transform
  11830. * @param y defines the x coordinate to transform
  11831. * @param result defines the target vector2
  11832. * @returns the current matrix
  11833. */
  11834. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11835. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11836. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11837. return this;
  11838. };
  11839. // Statics
  11840. /**
  11841. * Creates an identity matrix
  11842. * @returns a new matrix
  11843. */
  11844. Matrix2D.Identity = function () {
  11845. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11846. };
  11847. /**
  11848. * Creates a translation matrix and stores it in a target matrix
  11849. * @param x defines the x coordinate of the translation
  11850. * @param y defines the y coordinate of the translation
  11851. * @param result defines the target matrix
  11852. */
  11853. Matrix2D.TranslationToRef = function (x, y, result) {
  11854. result.fromValues(1, 0, 0, 1, x, y);
  11855. };
  11856. /**
  11857. * Creates a scaling matrix and stores it in a target matrix
  11858. * @param x defines the x coordinate of the scaling
  11859. * @param y defines the y coordinate of the scaling
  11860. * @param result defines the target matrix
  11861. */
  11862. Matrix2D.ScalingToRef = function (x, y, result) {
  11863. result.fromValues(x, 0, 0, y, 0, 0);
  11864. };
  11865. /**
  11866. * Creates a rotation matrix and stores it in a target matrix
  11867. * @param angle defines the rotation angle
  11868. * @param result defines the target matrix
  11869. */
  11870. Matrix2D.RotationToRef = function (angle, result) {
  11871. var s = Math.sin(angle);
  11872. var c = Math.cos(angle);
  11873. result.fromValues(c, s, -s, c, 0, 0);
  11874. };
  11875. /**
  11876. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11877. * @param tx defines the x coordinate of the translation
  11878. * @param ty defines the y coordinate of the translation
  11879. * @param angle defines the rotation angle
  11880. * @param scaleX defines the x coordinate of the scaling
  11881. * @param scaleY defines the y coordinate of the scaling
  11882. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11883. * @param result defines the target matrix
  11884. */
  11885. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11886. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11887. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11888. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11889. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11890. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11891. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11892. if (parentMatrix) {
  11893. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11894. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11895. }
  11896. else {
  11897. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11898. }
  11899. };
  11900. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11901. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11902. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11903. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11904. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11905. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11906. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11907. return Matrix2D;
  11908. }());
  11909. /***/ }),
  11910. /***/ "./2D/measure.ts":
  11911. /*!***********************!*\
  11912. !*** ./2D/measure.ts ***!
  11913. \***********************/
  11914. /*! exports provided: Measure */
  11915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11916. "use strict";
  11917. __webpack_require__.r(__webpack_exports__);
  11918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11919. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11920. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11921. /**
  11922. * Class used to store 2D control sizes
  11923. */
  11924. var Measure = /** @class */ (function () {
  11925. /**
  11926. * Creates a new measure
  11927. * @param left defines left coordinate
  11928. * @param top defines top coordinate
  11929. * @param width defines width dimension
  11930. * @param height defines height dimension
  11931. */
  11932. function Measure(
  11933. /** defines left coordinate */
  11934. left,
  11935. /** defines top coordinate */
  11936. top,
  11937. /** defines width dimension */
  11938. width,
  11939. /** defines height dimension */
  11940. height) {
  11941. this.left = left;
  11942. this.top = top;
  11943. this.width = width;
  11944. this.height = height;
  11945. }
  11946. /**
  11947. * Copy from another measure
  11948. * @param other defines the other measure to copy from
  11949. */
  11950. Measure.prototype.copyFrom = function (other) {
  11951. this.left = other.left;
  11952. this.top = other.top;
  11953. this.width = other.width;
  11954. this.height = other.height;
  11955. };
  11956. /**
  11957. * Copy from a group of 4 floats
  11958. * @param left defines left coordinate
  11959. * @param top defines top coordinate
  11960. * @param width defines width dimension
  11961. * @param height defines height dimension
  11962. */
  11963. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11964. this.left = left;
  11965. this.top = top;
  11966. this.width = width;
  11967. this.height = height;
  11968. };
  11969. /**
  11970. * Computes the axis aligned bounding box measure for two given measures
  11971. * @param a Input measure
  11972. * @param b Input measure
  11973. * @param result the resulting bounding measure
  11974. */
  11975. Measure.CombineToRef = function (a, b, result) {
  11976. var left = Math.min(a.left, b.left);
  11977. var top = Math.min(a.top, b.top);
  11978. var right = Math.max(a.left + a.width, b.left + b.width);
  11979. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11980. result.left = left;
  11981. result.top = top;
  11982. result.width = right - left;
  11983. result.height = bottom - top;
  11984. };
  11985. /**
  11986. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11987. * @param transform the matrix to transform the measure before computing the AABB
  11988. * @param result the resulting AABB
  11989. */
  11990. Measure.prototype.transformToRef = function (transform, result) {
  11991. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11992. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11993. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11994. for (var i = 0; i < 4; i++) {
  11995. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11996. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11997. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11998. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11999. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12000. }
  12001. result.left = min.x;
  12002. result.top = min.y;
  12003. result.width = max.x - min.x;
  12004. result.height = max.y - min.y;
  12005. };
  12006. /**
  12007. * Check equality between this measure and another one
  12008. * @param other defines the other measures
  12009. * @returns true if both measures are equals
  12010. */
  12011. Measure.prototype.isEqualsTo = function (other) {
  12012. if (this.left !== other.left) {
  12013. return false;
  12014. }
  12015. if (this.top !== other.top) {
  12016. return false;
  12017. }
  12018. if (this.width !== other.width) {
  12019. return false;
  12020. }
  12021. if (this.height !== other.height) {
  12022. return false;
  12023. }
  12024. return true;
  12025. };
  12026. /**
  12027. * Creates an empty measure
  12028. * @returns a new measure
  12029. */
  12030. Measure.Empty = function () {
  12031. return new Measure(0, 0, 0, 0);
  12032. };
  12033. return Measure;
  12034. }());
  12035. /***/ }),
  12036. /***/ "./2D/multiLinePoint.ts":
  12037. /*!******************************!*\
  12038. !*** ./2D/multiLinePoint.ts ***!
  12039. \******************************/
  12040. /*! exports provided: MultiLinePoint */
  12041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12042. "use strict";
  12043. __webpack_require__.r(__webpack_exports__);
  12044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12045. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12046. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12047. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12048. /**
  12049. * Class used to store a point for a MultiLine object.
  12050. * The point can be pure 2D coordinates, a mesh or a control
  12051. */
  12052. var MultiLinePoint = /** @class */ (function () {
  12053. /**
  12054. * Creates a new MultiLinePoint
  12055. * @param multiLine defines the source MultiLine object
  12056. */
  12057. function MultiLinePoint(multiLine) {
  12058. this._multiLine = multiLine;
  12059. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12060. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12061. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12062. }
  12063. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12064. /** Gets or sets x coordinate */
  12065. get: function () {
  12066. return this._x.toString(this._multiLine._host);
  12067. },
  12068. set: function (value) {
  12069. if (this._x.toString(this._multiLine._host) === value) {
  12070. return;
  12071. }
  12072. if (this._x.fromString(value)) {
  12073. this._multiLine._markAsDirty();
  12074. }
  12075. },
  12076. enumerable: true,
  12077. configurable: true
  12078. });
  12079. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12080. /** Gets or sets y coordinate */
  12081. get: function () {
  12082. return this._y.toString(this._multiLine._host);
  12083. },
  12084. set: function (value) {
  12085. if (this._y.toString(this._multiLine._host) === value) {
  12086. return;
  12087. }
  12088. if (this._y.fromString(value)) {
  12089. this._multiLine._markAsDirty();
  12090. }
  12091. },
  12092. enumerable: true,
  12093. configurable: true
  12094. });
  12095. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12096. /** Gets or sets the control associated with this point */
  12097. get: function () {
  12098. return this._control;
  12099. },
  12100. set: function (value) {
  12101. if (this._control === value) {
  12102. return;
  12103. }
  12104. if (this._control && this._controlObserver) {
  12105. this._control.onDirtyObservable.remove(this._controlObserver);
  12106. this._controlObserver = null;
  12107. }
  12108. this._control = value;
  12109. if (this._control) {
  12110. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12111. }
  12112. this._multiLine._markAsDirty();
  12113. },
  12114. enumerable: true,
  12115. configurable: true
  12116. });
  12117. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12118. /** Gets or sets the mesh associated with this point */
  12119. get: function () {
  12120. return this._mesh;
  12121. },
  12122. set: function (value) {
  12123. if (this._mesh === value) {
  12124. return;
  12125. }
  12126. if (this._mesh && this._meshObserver) {
  12127. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12128. }
  12129. this._mesh = value;
  12130. if (this._mesh) {
  12131. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12132. }
  12133. this._multiLine._markAsDirty();
  12134. },
  12135. enumerable: true,
  12136. configurable: true
  12137. });
  12138. /** Resets links */
  12139. MultiLinePoint.prototype.resetLinks = function () {
  12140. this.control = null;
  12141. this.mesh = null;
  12142. };
  12143. /**
  12144. * Gets a translation vector
  12145. * @returns the translation vector
  12146. */
  12147. MultiLinePoint.prototype.translate = function () {
  12148. this._point = this._translatePoint();
  12149. return this._point;
  12150. };
  12151. MultiLinePoint.prototype._translatePoint = function () {
  12152. if (this._mesh != null) {
  12153. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12154. }
  12155. else if (this._control != null) {
  12156. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12157. }
  12158. else {
  12159. var host = this._multiLine._host;
  12160. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12161. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12162. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12163. }
  12164. };
  12165. /** Release associated resources */
  12166. MultiLinePoint.prototype.dispose = function () {
  12167. this.resetLinks();
  12168. };
  12169. return MultiLinePoint;
  12170. }());
  12171. /***/ }),
  12172. /***/ "./2D/style.ts":
  12173. /*!*********************!*\
  12174. !*** ./2D/style.ts ***!
  12175. \*********************/
  12176. /*! exports provided: Style */
  12177. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12178. "use strict";
  12179. __webpack_require__.r(__webpack_exports__);
  12180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12181. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12182. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12183. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12184. /**
  12185. * Define a style used by control to automatically setup properties based on a template.
  12186. * Only support font related properties so far
  12187. */
  12188. var Style = /** @class */ (function () {
  12189. /**
  12190. * Creates a new style object
  12191. * @param host defines the AdvancedDynamicTexture which hosts this style
  12192. */
  12193. function Style(host) {
  12194. this._fontFamily = "Arial";
  12195. this._fontStyle = "";
  12196. this._fontWeight = "";
  12197. /** @hidden */
  12198. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12199. /**
  12200. * Observable raised when the style values are changed
  12201. */
  12202. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12203. this._host = host;
  12204. }
  12205. Object.defineProperty(Style.prototype, "fontSize", {
  12206. /**
  12207. * Gets or sets the font size
  12208. */
  12209. get: function () {
  12210. return this._fontSize.toString(this._host);
  12211. },
  12212. set: function (value) {
  12213. if (this._fontSize.toString(this._host) === value) {
  12214. return;
  12215. }
  12216. if (this._fontSize.fromString(value)) {
  12217. this.onChangedObservable.notifyObservers(this);
  12218. }
  12219. },
  12220. enumerable: true,
  12221. configurable: true
  12222. });
  12223. Object.defineProperty(Style.prototype, "fontFamily", {
  12224. /**
  12225. * Gets or sets the font family
  12226. */
  12227. get: function () {
  12228. return this._fontFamily;
  12229. },
  12230. set: function (value) {
  12231. if (this._fontFamily === value) {
  12232. return;
  12233. }
  12234. this._fontFamily = value;
  12235. this.onChangedObservable.notifyObservers(this);
  12236. },
  12237. enumerable: true,
  12238. configurable: true
  12239. });
  12240. Object.defineProperty(Style.prototype, "fontStyle", {
  12241. /**
  12242. * Gets or sets the font style
  12243. */
  12244. get: function () {
  12245. return this._fontStyle;
  12246. },
  12247. set: function (value) {
  12248. if (this._fontStyle === value) {
  12249. return;
  12250. }
  12251. this._fontStyle = value;
  12252. this.onChangedObservable.notifyObservers(this);
  12253. },
  12254. enumerable: true,
  12255. configurable: true
  12256. });
  12257. Object.defineProperty(Style.prototype, "fontWeight", {
  12258. /** Gets or sets font weight */
  12259. get: function () {
  12260. return this._fontWeight;
  12261. },
  12262. set: function (value) {
  12263. if (this._fontWeight === value) {
  12264. return;
  12265. }
  12266. this._fontWeight = value;
  12267. this.onChangedObservable.notifyObservers(this);
  12268. },
  12269. enumerable: true,
  12270. configurable: true
  12271. });
  12272. /** Dispose all associated resources */
  12273. Style.prototype.dispose = function () {
  12274. this.onChangedObservable.clear();
  12275. };
  12276. return Style;
  12277. }());
  12278. /***/ }),
  12279. /***/ "./2D/valueAndUnit.ts":
  12280. /*!****************************!*\
  12281. !*** ./2D/valueAndUnit.ts ***!
  12282. \****************************/
  12283. /*! exports provided: ValueAndUnit */
  12284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12285. "use strict";
  12286. __webpack_require__.r(__webpack_exports__);
  12287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12288. /**
  12289. * Class used to specific a value and its associated unit
  12290. */
  12291. var ValueAndUnit = /** @class */ (function () {
  12292. /**
  12293. * Creates a new ValueAndUnit
  12294. * @param value defines the value to store
  12295. * @param unit defines the unit to store
  12296. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12297. */
  12298. function ValueAndUnit(value,
  12299. /** defines the unit to store */
  12300. unit,
  12301. /** defines a boolean indicating if the value can be negative */
  12302. negativeValueAllowed) {
  12303. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12304. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12305. this.unit = unit;
  12306. this.negativeValueAllowed = negativeValueAllowed;
  12307. this._value = 1;
  12308. /**
  12309. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12310. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12311. */
  12312. this.ignoreAdaptiveScaling = false;
  12313. this._value = value;
  12314. this._originalUnit = unit;
  12315. }
  12316. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12317. /** Gets a boolean indicating if the value is a percentage */
  12318. get: function () {
  12319. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12320. },
  12321. enumerable: true,
  12322. configurable: true
  12323. });
  12324. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12325. /** Gets a boolean indicating if the value is store as pixel */
  12326. get: function () {
  12327. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12328. },
  12329. enumerable: true,
  12330. configurable: true
  12331. });
  12332. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12333. /** Gets direct internal value */
  12334. get: function () {
  12335. return this._value;
  12336. },
  12337. enumerable: true,
  12338. configurable: true
  12339. });
  12340. /**
  12341. * Gets value as pixel
  12342. * @param host defines the root host
  12343. * @param refValue defines the reference value for percentages
  12344. * @returns the value as pixel
  12345. */
  12346. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12347. if (this.isPixel) {
  12348. return this.getValue(host);
  12349. }
  12350. return this.getValue(host) * refValue;
  12351. };
  12352. /**
  12353. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12354. * @param value defines the value to store
  12355. * @param unit defines the unit to store
  12356. * @returns the current ValueAndUnit
  12357. */
  12358. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12359. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12360. this._value = value;
  12361. this.unit = unit;
  12362. return this;
  12363. };
  12364. /**
  12365. * Gets the value accordingly to its unit
  12366. * @param host defines the root host
  12367. * @returns the value
  12368. */
  12369. ValueAndUnit.prototype.getValue = function (host) {
  12370. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12371. var width = 0;
  12372. var height = 0;
  12373. if (host.idealWidth) {
  12374. width = (this._value * host.getSize().width) / host.idealWidth;
  12375. }
  12376. if (host.idealHeight) {
  12377. height = (this._value * host.getSize().height) / host.idealHeight;
  12378. }
  12379. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12380. return window.innerWidth < window.innerHeight ? width : height;
  12381. }
  12382. if (host.idealWidth) { // horizontal
  12383. return width;
  12384. }
  12385. if (host.idealHeight) { // vertical
  12386. return height;
  12387. }
  12388. }
  12389. return this._value;
  12390. };
  12391. /**
  12392. * Gets a string representation of the value
  12393. * @param host defines the root host
  12394. * @param decimals defines an optional number of decimals to display
  12395. * @returns a string
  12396. */
  12397. ValueAndUnit.prototype.toString = function (host, decimals) {
  12398. switch (this.unit) {
  12399. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12400. var percentage = this.getValue(host) * 100;
  12401. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12402. case ValueAndUnit.UNITMODE_PIXEL:
  12403. var pixels = this.getValue(host);
  12404. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12405. }
  12406. return this.unit.toString();
  12407. };
  12408. /**
  12409. * Store a value parsed from a string
  12410. * @param source defines the source string
  12411. * @returns true if the value was successfully parsed
  12412. */
  12413. ValueAndUnit.prototype.fromString = function (source) {
  12414. var match = ValueAndUnit._Regex.exec(source.toString());
  12415. if (!match || match.length === 0) {
  12416. return false;
  12417. }
  12418. var sourceValue = parseFloat(match[1]);
  12419. var sourceUnit = this._originalUnit;
  12420. if (!this.negativeValueAllowed) {
  12421. if (sourceValue < 0) {
  12422. sourceValue = 0;
  12423. }
  12424. }
  12425. if (match.length === 4) {
  12426. switch (match[3]) {
  12427. case "px":
  12428. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12429. break;
  12430. case "%":
  12431. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12432. sourceValue /= 100.0;
  12433. break;
  12434. }
  12435. }
  12436. if (sourceValue === this._value && sourceUnit === this.unit) {
  12437. return false;
  12438. }
  12439. this._value = sourceValue;
  12440. this.unit = sourceUnit;
  12441. return true;
  12442. };
  12443. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12444. /** UNITMODE_PERCENTAGE */
  12445. get: function () {
  12446. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12447. },
  12448. enumerable: true,
  12449. configurable: true
  12450. });
  12451. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12452. /** UNITMODE_PIXEL */
  12453. get: function () {
  12454. return ValueAndUnit._UNITMODE_PIXEL;
  12455. },
  12456. enumerable: true,
  12457. configurable: true
  12458. });
  12459. // Static
  12460. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12461. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12462. ValueAndUnit._UNITMODE_PIXEL = 1;
  12463. return ValueAndUnit;
  12464. }());
  12465. /***/ }),
  12466. /***/ "./3D/controls/abstractButton3D.ts":
  12467. /*!*****************************************!*\
  12468. !*** ./3D/controls/abstractButton3D.ts ***!
  12469. \*****************************************/
  12470. /*! exports provided: AbstractButton3D */
  12471. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12472. "use strict";
  12473. __webpack_require__.r(__webpack_exports__);
  12474. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12475. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12476. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12477. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12478. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12479. /**
  12480. * Class used as a root to all buttons
  12481. */
  12482. var AbstractButton3D = /** @class */ (function (_super) {
  12483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12484. /**
  12485. * Creates a new button
  12486. * @param name defines the control name
  12487. */
  12488. function AbstractButton3D(name) {
  12489. return _super.call(this, name) || this;
  12490. }
  12491. AbstractButton3D.prototype._getTypeName = function () {
  12492. return "AbstractButton3D";
  12493. };
  12494. // Mesh association
  12495. AbstractButton3D.prototype._createNode = function (scene) {
  12496. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12497. };
  12498. return AbstractButton3D;
  12499. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12500. /***/ }),
  12501. /***/ "./3D/controls/button3D.ts":
  12502. /*!*********************************!*\
  12503. !*** ./3D/controls/button3D.ts ***!
  12504. \*********************************/
  12505. /*! exports provided: Button3D */
  12506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12507. "use strict";
  12508. __webpack_require__.r(__webpack_exports__);
  12509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12511. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12512. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12513. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12514. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12515. /**
  12516. * Class used to create a button in 3D
  12517. */
  12518. var Button3D = /** @class */ (function (_super) {
  12519. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12520. /**
  12521. * Creates a new button
  12522. * @param name defines the control name
  12523. */
  12524. function Button3D(name) {
  12525. var _this = _super.call(this, name) || this;
  12526. _this._contentResolution = 512;
  12527. _this._contentScaleRatio = 2;
  12528. // Default animations
  12529. _this.pointerEnterAnimation = function () {
  12530. if (!_this.mesh) {
  12531. return;
  12532. }
  12533. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12534. };
  12535. _this.pointerOutAnimation = function () {
  12536. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12537. };
  12538. _this.pointerDownAnimation = function () {
  12539. if (!_this.mesh) {
  12540. return;
  12541. }
  12542. _this.mesh.scaling.scaleInPlace(0.95);
  12543. };
  12544. _this.pointerUpAnimation = function () {
  12545. if (!_this.mesh) {
  12546. return;
  12547. }
  12548. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12549. };
  12550. return _this;
  12551. }
  12552. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12553. /**
  12554. * Gets or sets the texture resolution used to render content (512 by default)
  12555. */
  12556. get: function () {
  12557. return this._contentResolution;
  12558. },
  12559. set: function (value) {
  12560. if (this._contentResolution === value) {
  12561. return;
  12562. }
  12563. this._contentResolution = value;
  12564. this._resetContent();
  12565. },
  12566. enumerable: true,
  12567. configurable: true
  12568. });
  12569. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12570. /**
  12571. * Gets or sets the texture scale ratio used to render content (2 by default)
  12572. */
  12573. get: function () {
  12574. return this._contentScaleRatio;
  12575. },
  12576. set: function (value) {
  12577. if (this._contentScaleRatio === value) {
  12578. return;
  12579. }
  12580. this._contentScaleRatio = value;
  12581. this._resetContent();
  12582. },
  12583. enumerable: true,
  12584. configurable: true
  12585. });
  12586. Button3D.prototype._disposeFacadeTexture = function () {
  12587. if (this._facadeTexture) {
  12588. this._facadeTexture.dispose();
  12589. this._facadeTexture = null;
  12590. }
  12591. };
  12592. Button3D.prototype._resetContent = function () {
  12593. this._disposeFacadeTexture();
  12594. this.content = this._content;
  12595. };
  12596. Object.defineProperty(Button3D.prototype, "content", {
  12597. /**
  12598. * Gets or sets the GUI 2D content used to display the button's facade
  12599. */
  12600. get: function () {
  12601. return this._content;
  12602. },
  12603. set: function (value) {
  12604. this._content = value;
  12605. if (!this._host || !this._host.utilityLayer) {
  12606. return;
  12607. }
  12608. if (!this._facadeTexture) {
  12609. 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);
  12610. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12611. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12612. this._facadeTexture.premulAlpha = true;
  12613. }
  12614. this._facadeTexture.addControl(value);
  12615. this._applyFacade(this._facadeTexture);
  12616. },
  12617. enumerable: true,
  12618. configurable: true
  12619. });
  12620. /**
  12621. * Apply the facade texture (created from the content property).
  12622. * This function can be overloaded by child classes
  12623. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12624. */
  12625. Button3D.prototype._applyFacade = function (facadeTexture) {
  12626. this._currentMaterial.emissiveTexture = facadeTexture;
  12627. };
  12628. Button3D.prototype._getTypeName = function () {
  12629. return "Button3D";
  12630. };
  12631. // Mesh association
  12632. Button3D.prototype._createNode = function (scene) {
  12633. var faceUV = new Array(6);
  12634. for (var i = 0; i < 6; i++) {
  12635. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12636. }
  12637. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12638. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12639. width: 1.0,
  12640. height: 1.0,
  12641. depth: 0.08,
  12642. faceUV: faceUV
  12643. }, scene);
  12644. return mesh;
  12645. };
  12646. Button3D.prototype._affectMaterial = function (mesh) {
  12647. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12648. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12649. mesh.material = material;
  12650. this._currentMaterial = material;
  12651. this._resetContent();
  12652. };
  12653. /**
  12654. * Releases all associated resources
  12655. */
  12656. Button3D.prototype.dispose = function () {
  12657. _super.prototype.dispose.call(this);
  12658. this._disposeFacadeTexture();
  12659. if (this._currentMaterial) {
  12660. this._currentMaterial.dispose();
  12661. }
  12662. };
  12663. return Button3D;
  12664. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12665. /***/ }),
  12666. /***/ "./3D/controls/container3D.ts":
  12667. /*!************************************!*\
  12668. !*** ./3D/controls/container3D.ts ***!
  12669. \************************************/
  12670. /*! exports provided: Container3D */
  12671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12672. "use strict";
  12673. __webpack_require__.r(__webpack_exports__);
  12674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12675. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12676. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12677. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12678. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12679. /**
  12680. * Class used to create containers for controls
  12681. */
  12682. var Container3D = /** @class */ (function (_super) {
  12683. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12684. /**
  12685. * Creates a new container
  12686. * @param name defines the container name
  12687. */
  12688. function Container3D(name) {
  12689. var _this = _super.call(this, name) || this;
  12690. _this._blockLayout = false;
  12691. /**
  12692. * Gets the list of child controls
  12693. */
  12694. _this._children = new Array();
  12695. return _this;
  12696. }
  12697. Object.defineProperty(Container3D.prototype, "children", {
  12698. /**
  12699. * Gets the list of child controls
  12700. */
  12701. get: function () {
  12702. return this._children;
  12703. },
  12704. enumerable: true,
  12705. configurable: true
  12706. });
  12707. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12708. /**
  12709. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12710. * This is helpful to optimize layout operation when adding multiple children in a row
  12711. */
  12712. get: function () {
  12713. return this._blockLayout;
  12714. },
  12715. set: function (value) {
  12716. if (this._blockLayout === value) {
  12717. return;
  12718. }
  12719. this._blockLayout = value;
  12720. if (!this._blockLayout) {
  12721. this._arrangeChildren();
  12722. }
  12723. },
  12724. enumerable: true,
  12725. configurable: true
  12726. });
  12727. /**
  12728. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12729. * @returns the current container
  12730. */
  12731. Container3D.prototype.updateLayout = function () {
  12732. this._arrangeChildren();
  12733. return this;
  12734. };
  12735. /**
  12736. * Gets a boolean indicating if the given control is in the children of this control
  12737. * @param control defines the control to check
  12738. * @returns true if the control is in the child list
  12739. */
  12740. Container3D.prototype.containsControl = function (control) {
  12741. return this._children.indexOf(control) !== -1;
  12742. };
  12743. /**
  12744. * Adds a control to the children of this control
  12745. * @param control defines the control to add
  12746. * @returns the current container
  12747. */
  12748. Container3D.prototype.addControl = function (control) {
  12749. var index = this._children.indexOf(control);
  12750. if (index !== -1) {
  12751. return this;
  12752. }
  12753. control.parent = this;
  12754. control._host = this._host;
  12755. this._children.push(control);
  12756. if (this._host.utilityLayer) {
  12757. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12758. if (control.node) {
  12759. control.node.parent = this.node;
  12760. }
  12761. if (!this.blockLayout) {
  12762. this._arrangeChildren();
  12763. }
  12764. }
  12765. return this;
  12766. };
  12767. /**
  12768. * This function will be called everytime a new control is added
  12769. */
  12770. Container3D.prototype._arrangeChildren = function () {
  12771. };
  12772. Container3D.prototype._createNode = function (scene) {
  12773. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12774. };
  12775. /**
  12776. * Removes a control from the children of this control
  12777. * @param control defines the control to remove
  12778. * @returns the current container
  12779. */
  12780. Container3D.prototype.removeControl = function (control) {
  12781. var index = this._children.indexOf(control);
  12782. if (index !== -1) {
  12783. this._children.splice(index, 1);
  12784. control.parent = null;
  12785. control._disposeNode();
  12786. }
  12787. return this;
  12788. };
  12789. Container3D.prototype._getTypeName = function () {
  12790. return "Container3D";
  12791. };
  12792. /**
  12793. * Releases all associated resources
  12794. */
  12795. Container3D.prototype.dispose = function () {
  12796. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12797. var control = _a[_i];
  12798. control.dispose();
  12799. }
  12800. this._children = [];
  12801. _super.prototype.dispose.call(this);
  12802. };
  12803. /** Control rotation will remain unchanged */
  12804. Container3D.UNSET_ORIENTATION = 0;
  12805. /** Control will rotate to make it look at sphere central axis */
  12806. Container3D.FACEORIGIN_ORIENTATION = 1;
  12807. /** Control will rotate to make it look back at sphere central axis */
  12808. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12809. /** Control will rotate to look at z axis (0, 0, 1) */
  12810. Container3D.FACEFORWARD_ORIENTATION = 3;
  12811. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12812. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12813. return Container3D;
  12814. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12815. /***/ }),
  12816. /***/ "./3D/controls/control3D.ts":
  12817. /*!**********************************!*\
  12818. !*** ./3D/controls/control3D.ts ***!
  12819. \**********************************/
  12820. /*! exports provided: Control3D */
  12821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12822. "use strict";
  12823. __webpack_require__.r(__webpack_exports__);
  12824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12825. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12826. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12827. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12828. /**
  12829. * Class used as base class for controls
  12830. */
  12831. var Control3D = /** @class */ (function () {
  12832. /**
  12833. * Creates a new control
  12834. * @param name defines the control name
  12835. */
  12836. function Control3D(
  12837. /** Defines the control name */
  12838. name) {
  12839. this.name = name;
  12840. this._downCount = 0;
  12841. this._enterCount = -1;
  12842. this._downPointerIds = {};
  12843. this._isVisible = true;
  12844. /**
  12845. * An event triggered when the pointer move over the control
  12846. */
  12847. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12848. /**
  12849. * An event triggered when the pointer move out of the control
  12850. */
  12851. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12852. /**
  12853. * An event triggered when the pointer taps the control
  12854. */
  12855. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12856. /**
  12857. * An event triggered when pointer is up
  12858. */
  12859. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12860. /**
  12861. * An event triggered when a control is clicked on (with a mouse)
  12862. */
  12863. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12864. /**
  12865. * An event triggered when pointer enters the control
  12866. */
  12867. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12868. // Behaviors
  12869. this._behaviors = new Array();
  12870. }
  12871. Object.defineProperty(Control3D.prototype, "position", {
  12872. /** Gets or sets the control position in world space */
  12873. get: function () {
  12874. if (!this._node) {
  12875. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12876. }
  12877. return this._node.position;
  12878. },
  12879. set: function (value) {
  12880. if (!this._node) {
  12881. return;
  12882. }
  12883. this._node.position = value;
  12884. },
  12885. enumerable: true,
  12886. configurable: true
  12887. });
  12888. Object.defineProperty(Control3D.prototype, "scaling", {
  12889. /** Gets or sets the control scaling in world space */
  12890. get: function () {
  12891. if (!this._node) {
  12892. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12893. }
  12894. return this._node.scaling;
  12895. },
  12896. set: function (value) {
  12897. if (!this._node) {
  12898. return;
  12899. }
  12900. this._node.scaling = value;
  12901. },
  12902. enumerable: true,
  12903. configurable: true
  12904. });
  12905. Object.defineProperty(Control3D.prototype, "behaviors", {
  12906. /**
  12907. * Gets the list of attached behaviors
  12908. * @see http://doc.babylonjs.com/features/behaviour
  12909. */
  12910. get: function () {
  12911. return this._behaviors;
  12912. },
  12913. enumerable: true,
  12914. configurable: true
  12915. });
  12916. /**
  12917. * Attach a behavior to the control
  12918. * @see http://doc.babylonjs.com/features/behaviour
  12919. * @param behavior defines the behavior to attach
  12920. * @returns the current control
  12921. */
  12922. Control3D.prototype.addBehavior = function (behavior) {
  12923. var _this = this;
  12924. var index = this._behaviors.indexOf(behavior);
  12925. if (index !== -1) {
  12926. return this;
  12927. }
  12928. behavior.init();
  12929. var scene = this._host.scene;
  12930. if (scene.isLoading) {
  12931. // We defer the attach when the scene will be loaded
  12932. scene.onDataLoadedObservable.addOnce(function () {
  12933. behavior.attach(_this);
  12934. });
  12935. }
  12936. else {
  12937. behavior.attach(this);
  12938. }
  12939. this._behaviors.push(behavior);
  12940. return this;
  12941. };
  12942. /**
  12943. * Remove an attached behavior
  12944. * @see http://doc.babylonjs.com/features/behaviour
  12945. * @param behavior defines the behavior to attach
  12946. * @returns the current control
  12947. */
  12948. Control3D.prototype.removeBehavior = function (behavior) {
  12949. var index = this._behaviors.indexOf(behavior);
  12950. if (index === -1) {
  12951. return this;
  12952. }
  12953. this._behaviors[index].detach();
  12954. this._behaviors.splice(index, 1);
  12955. return this;
  12956. };
  12957. /**
  12958. * Gets an attached behavior by name
  12959. * @param name defines the name of the behavior to look for
  12960. * @see http://doc.babylonjs.com/features/behaviour
  12961. * @returns null if behavior was not found else the requested behavior
  12962. */
  12963. Control3D.prototype.getBehaviorByName = function (name) {
  12964. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12965. var behavior = _a[_i];
  12966. if (behavior.name === name) {
  12967. return behavior;
  12968. }
  12969. }
  12970. return null;
  12971. };
  12972. Object.defineProperty(Control3D.prototype, "isVisible", {
  12973. /** Gets or sets a boolean indicating if the control is visible */
  12974. get: function () {
  12975. return this._isVisible;
  12976. },
  12977. set: function (value) {
  12978. if (this._isVisible === value) {
  12979. return;
  12980. }
  12981. this._isVisible = value;
  12982. var mesh = this.mesh;
  12983. if (mesh) {
  12984. mesh.setEnabled(value);
  12985. }
  12986. },
  12987. enumerable: true,
  12988. configurable: true
  12989. });
  12990. Object.defineProperty(Control3D.prototype, "typeName", {
  12991. /**
  12992. * Gets a string representing the class name
  12993. */
  12994. get: function () {
  12995. return this._getTypeName();
  12996. },
  12997. enumerable: true,
  12998. configurable: true
  12999. });
  13000. /**
  13001. * Get the current class name of the control.
  13002. * @returns current class name
  13003. */
  13004. Control3D.prototype.getClassName = function () {
  13005. return this._getTypeName();
  13006. };
  13007. Control3D.prototype._getTypeName = function () {
  13008. return "Control3D";
  13009. };
  13010. Object.defineProperty(Control3D.prototype, "node", {
  13011. /**
  13012. * Gets the transform node used by this control
  13013. */
  13014. get: function () {
  13015. return this._node;
  13016. },
  13017. enumerable: true,
  13018. configurable: true
  13019. });
  13020. Object.defineProperty(Control3D.prototype, "mesh", {
  13021. /**
  13022. * Gets the mesh used to render this control
  13023. */
  13024. get: function () {
  13025. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13026. return this._node;
  13027. }
  13028. return null;
  13029. },
  13030. enumerable: true,
  13031. configurable: true
  13032. });
  13033. /**
  13034. * Link the control as child of the given node
  13035. * @param node defines the node to link to. Use null to unlink the control
  13036. * @returns the current control
  13037. */
  13038. Control3D.prototype.linkToTransformNode = function (node) {
  13039. if (this._node) {
  13040. this._node.parent = node;
  13041. }
  13042. return this;
  13043. };
  13044. /** @hidden **/
  13045. Control3D.prototype._prepareNode = function (scene) {
  13046. if (!this._node) {
  13047. this._node = this._createNode(scene);
  13048. if (!this.node) {
  13049. return;
  13050. }
  13051. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13052. this._node.position = this.position;
  13053. this._node.scaling = this.scaling;
  13054. var mesh = this.mesh;
  13055. if (mesh) {
  13056. mesh.isPickable = true;
  13057. this._affectMaterial(mesh);
  13058. }
  13059. }
  13060. };
  13061. /**
  13062. * Node creation.
  13063. * Can be overriden by children
  13064. * @param scene defines the scene where the node must be attached
  13065. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13066. */
  13067. Control3D.prototype._createNode = function (scene) {
  13068. // Do nothing by default
  13069. return null;
  13070. };
  13071. /**
  13072. * Affect a material to the given mesh
  13073. * @param mesh defines the mesh which will represent the control
  13074. */
  13075. Control3D.prototype._affectMaterial = function (mesh) {
  13076. mesh.material = null;
  13077. };
  13078. // Pointers
  13079. /** @hidden */
  13080. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13081. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13082. };
  13083. /** @hidden */
  13084. Control3D.prototype._onPointerEnter = function (target) {
  13085. if (this._enterCount > 0) {
  13086. return false;
  13087. }
  13088. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13089. this._enterCount = 0;
  13090. }
  13091. this._enterCount++;
  13092. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13093. if (this.pointerEnterAnimation) {
  13094. this.pointerEnterAnimation();
  13095. }
  13096. return true;
  13097. };
  13098. /** @hidden */
  13099. Control3D.prototype._onPointerOut = function (target) {
  13100. this._enterCount = 0;
  13101. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13102. if (this.pointerOutAnimation) {
  13103. this.pointerOutAnimation();
  13104. }
  13105. };
  13106. /** @hidden */
  13107. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13108. if (this._downCount !== 0) {
  13109. this._downCount++;
  13110. return false;
  13111. }
  13112. this._downCount++;
  13113. this._downPointerIds[pointerId] = true;
  13114. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13115. if (this.pointerDownAnimation) {
  13116. this.pointerDownAnimation();
  13117. }
  13118. return true;
  13119. };
  13120. /** @hidden */
  13121. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13122. this._downCount--;
  13123. delete this._downPointerIds[pointerId];
  13124. if (this._downCount < 0) {
  13125. // Handle if forcePointerUp was called prior to this
  13126. this._downCount = 0;
  13127. return;
  13128. }
  13129. if (this._downCount == 0) {
  13130. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13131. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13132. }
  13133. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13134. if (this.pointerUpAnimation) {
  13135. this.pointerUpAnimation();
  13136. }
  13137. }
  13138. };
  13139. /** @hidden */
  13140. Control3D.prototype.forcePointerUp = function (pointerId) {
  13141. if (pointerId === void 0) { pointerId = null; }
  13142. if (pointerId !== null) {
  13143. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13144. }
  13145. else {
  13146. for (var key in this._downPointerIds) {
  13147. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13148. }
  13149. if (this._downCount > 0) {
  13150. this._downCount = 1;
  13151. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13152. }
  13153. }
  13154. };
  13155. /** @hidden */
  13156. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13157. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13158. this._onPointerMove(this, pickedPoint);
  13159. var previousControlOver = this._host._lastControlOver[pointerId];
  13160. if (previousControlOver && previousControlOver !== this) {
  13161. previousControlOver._onPointerOut(this);
  13162. }
  13163. if (previousControlOver !== this) {
  13164. this._onPointerEnter(this);
  13165. }
  13166. this._host._lastControlOver[pointerId] = this;
  13167. return true;
  13168. }
  13169. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13170. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13171. this._host._lastControlDown[pointerId] = this;
  13172. this._host._lastPickedControl = this;
  13173. return true;
  13174. }
  13175. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13176. if (this._host._lastControlDown[pointerId]) {
  13177. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13178. }
  13179. delete this._host._lastControlDown[pointerId];
  13180. return true;
  13181. }
  13182. return false;
  13183. };
  13184. /** @hidden */
  13185. Control3D.prototype._disposeNode = function () {
  13186. if (this._node) {
  13187. this._node.dispose();
  13188. this._node = null;
  13189. }
  13190. };
  13191. /**
  13192. * Releases all associated resources
  13193. */
  13194. Control3D.prototype.dispose = function () {
  13195. this.onPointerDownObservable.clear();
  13196. this.onPointerEnterObservable.clear();
  13197. this.onPointerMoveObservable.clear();
  13198. this.onPointerOutObservable.clear();
  13199. this.onPointerUpObservable.clear();
  13200. this.onPointerClickObservable.clear();
  13201. this._disposeNode();
  13202. // Behaviors
  13203. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13204. var behavior = _a[_i];
  13205. behavior.detach();
  13206. }
  13207. };
  13208. return Control3D;
  13209. }());
  13210. /***/ }),
  13211. /***/ "./3D/controls/cylinderPanel.ts":
  13212. /*!**************************************!*\
  13213. !*** ./3D/controls/cylinderPanel.ts ***!
  13214. \**************************************/
  13215. /*! exports provided: CylinderPanel */
  13216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13217. "use strict";
  13218. __webpack_require__.r(__webpack_exports__);
  13219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13220. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13221. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13222. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13223. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13224. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13225. /**
  13226. * Class used to create a container panel deployed on the surface of a cylinder
  13227. */
  13228. var CylinderPanel = /** @class */ (function (_super) {
  13229. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13230. function CylinderPanel() {
  13231. var _this = _super !== null && _super.apply(this, arguments) || this;
  13232. _this._radius = 5.0;
  13233. return _this;
  13234. }
  13235. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13236. /**
  13237. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13238. */
  13239. get: function () {
  13240. return this._radius;
  13241. },
  13242. set: function (value) {
  13243. var _this = this;
  13244. if (this._radius === value) {
  13245. return;
  13246. }
  13247. this._radius = value;
  13248. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13249. _this._arrangeChildren();
  13250. });
  13251. },
  13252. enumerable: true,
  13253. configurable: true
  13254. });
  13255. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13256. var mesh = control.mesh;
  13257. if (!mesh) {
  13258. return;
  13259. }
  13260. var newPos = this._cylindricalMapping(nodePosition);
  13261. control.position = newPos;
  13262. switch (this.orientation) {
  13263. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13264. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13265. break;
  13266. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13267. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13268. break;
  13269. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13270. break;
  13271. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13272. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13273. break;
  13274. }
  13275. };
  13276. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13277. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13278. var yAngle = (source.x / this._radius);
  13279. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13280. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13281. };
  13282. return CylinderPanel;
  13283. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13284. /***/ }),
  13285. /***/ "./3D/controls/holographicButton.ts":
  13286. /*!******************************************!*\
  13287. !*** ./3D/controls/holographicButton.ts ***!
  13288. \******************************************/
  13289. /*! exports provided: HolographicButton */
  13290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13291. "use strict";
  13292. __webpack_require__.r(__webpack_exports__);
  13293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13294. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13295. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13296. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13297. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13298. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13299. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13300. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13301. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13302. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13303. /**
  13304. * Class used to create a holographic button in 3D
  13305. */
  13306. var HolographicButton = /** @class */ (function (_super) {
  13307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13308. /**
  13309. * Creates a new button
  13310. * @param name defines the control name
  13311. */
  13312. function HolographicButton(name, shareMaterials) {
  13313. if (shareMaterials === void 0) { shareMaterials = true; }
  13314. var _this = _super.call(this, name) || this;
  13315. _this._shareMaterials = true;
  13316. _this._shareMaterials = shareMaterials;
  13317. // Default animations
  13318. _this.pointerEnterAnimation = function () {
  13319. if (!_this.mesh) {
  13320. return;
  13321. }
  13322. _this._frontPlate.setEnabled(true);
  13323. };
  13324. _this.pointerOutAnimation = function () {
  13325. if (!_this.mesh) {
  13326. return;
  13327. }
  13328. _this._frontPlate.setEnabled(false);
  13329. };
  13330. return _this;
  13331. }
  13332. HolographicButton.prototype._disposeTooltip = function () {
  13333. this._tooltipFade = null;
  13334. if (this._tooltipTextBlock) {
  13335. this._tooltipTextBlock.dispose();
  13336. }
  13337. if (this._tooltipTexture) {
  13338. this._tooltipTexture.dispose();
  13339. }
  13340. if (this._tooltipMesh) {
  13341. this._tooltipMesh.dispose();
  13342. }
  13343. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13344. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13345. };
  13346. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13347. get: function () {
  13348. if (this._tooltipTextBlock) {
  13349. return this._tooltipTextBlock.text;
  13350. }
  13351. return null;
  13352. },
  13353. /**
  13354. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13355. */
  13356. set: function (text) {
  13357. var _this = this;
  13358. if (!text) {
  13359. this._disposeTooltip();
  13360. return;
  13361. }
  13362. if (!this._tooltipFade) {
  13363. // Create tooltip with mesh and text
  13364. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13365. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  13366. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13367. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13368. tooltipBackground.material = mat;
  13369. tooltipBackground.isPickable = false;
  13370. this._tooltipMesh.addChild(tooltipBackground);
  13371. tooltipBackground.position.z = 0.05;
  13372. this._tooltipMesh.scaling.y = 1 / 3;
  13373. this._tooltipMesh.position.y = 0.7;
  13374. this._tooltipMesh.position.z = -0.15;
  13375. this._tooltipMesh.isPickable = false;
  13376. this._tooltipMesh.parent = this._backPlate;
  13377. // Create text texture for the tooltip
  13378. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13379. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13380. this._tooltipTextBlock.scaleY = 3;
  13381. this._tooltipTextBlock.color = "white";
  13382. this._tooltipTextBlock.fontSize = 130;
  13383. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13384. // Add hover action to tooltip
  13385. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13386. this._tooltipFade.delay = 500;
  13387. this._tooltipMesh.addBehavior(this._tooltipFade);
  13388. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13389. if (_this._tooltipFade) {
  13390. _this._tooltipFade.fadeIn(true);
  13391. }
  13392. });
  13393. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13394. if (_this._tooltipFade) {
  13395. _this._tooltipFade.fadeIn(false);
  13396. }
  13397. });
  13398. }
  13399. if (this._tooltipTextBlock) {
  13400. this._tooltipTextBlock.text = text;
  13401. }
  13402. },
  13403. enumerable: true,
  13404. configurable: true
  13405. });
  13406. Object.defineProperty(HolographicButton.prototype, "text", {
  13407. /**
  13408. * Gets or sets text for the button
  13409. */
  13410. get: function () {
  13411. return this._text;
  13412. },
  13413. set: function (value) {
  13414. if (this._text === value) {
  13415. return;
  13416. }
  13417. this._text = value;
  13418. this._rebuildContent();
  13419. },
  13420. enumerable: true,
  13421. configurable: true
  13422. });
  13423. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13424. /**
  13425. * Gets or sets the image url for the button
  13426. */
  13427. get: function () {
  13428. return this._imageUrl;
  13429. },
  13430. set: function (value) {
  13431. if (this._imageUrl === value) {
  13432. return;
  13433. }
  13434. this._imageUrl = value;
  13435. this._rebuildContent();
  13436. },
  13437. enumerable: true,
  13438. configurable: true
  13439. });
  13440. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13441. /**
  13442. * Gets the back material used by this button
  13443. */
  13444. get: function () {
  13445. return this._backMaterial;
  13446. },
  13447. enumerable: true,
  13448. configurable: true
  13449. });
  13450. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13451. /**
  13452. * Gets the front material used by this button
  13453. */
  13454. get: function () {
  13455. return this._frontMaterial;
  13456. },
  13457. enumerable: true,
  13458. configurable: true
  13459. });
  13460. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13461. /**
  13462. * Gets the plate material used by this button
  13463. */
  13464. get: function () {
  13465. return this._plateMaterial;
  13466. },
  13467. enumerable: true,
  13468. configurable: true
  13469. });
  13470. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13471. /**
  13472. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13473. */
  13474. get: function () {
  13475. return this._shareMaterials;
  13476. },
  13477. enumerable: true,
  13478. configurable: true
  13479. });
  13480. HolographicButton.prototype._getTypeName = function () {
  13481. return "HolographicButton";
  13482. };
  13483. HolographicButton.prototype._rebuildContent = function () {
  13484. this._disposeFacadeTexture();
  13485. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13486. panel.isVertical = true;
  13487. if (this._imageUrl) {
  13488. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13489. image.source = this._imageUrl;
  13490. image.paddingTop = "40px";
  13491. image.height = "180px";
  13492. image.width = "100px";
  13493. image.paddingBottom = "40px";
  13494. panel.addControl(image);
  13495. }
  13496. if (this._text) {
  13497. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13498. text.text = this._text;
  13499. text.color = "white";
  13500. text.height = "30px";
  13501. text.fontSize = 24;
  13502. panel.addControl(text);
  13503. }
  13504. if (this._frontPlate) {
  13505. this.content = panel;
  13506. }
  13507. };
  13508. // Mesh association
  13509. HolographicButton.prototype._createNode = function (scene) {
  13510. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13511. width: 1.0,
  13512. height: 1.0,
  13513. depth: 0.08
  13514. }, scene);
  13515. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13516. width: 1.0,
  13517. height: 1.0,
  13518. depth: 0.08
  13519. }, scene);
  13520. this._frontPlate.parent = this._backPlate;
  13521. this._frontPlate.position.z = -0.08;
  13522. this._frontPlate.isPickable = false;
  13523. this._frontPlate.setEnabled(false);
  13524. this._textPlate = _super.prototype._createNode.call(this, scene);
  13525. this._textPlate.parent = this._backPlate;
  13526. this._textPlate.position.z = -0.08;
  13527. this._textPlate.isPickable = false;
  13528. return this._backPlate;
  13529. };
  13530. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13531. this._plateMaterial.emissiveTexture = facadeTexture;
  13532. this._plateMaterial.opacityTexture = facadeTexture;
  13533. };
  13534. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13535. var _this = this;
  13536. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13537. this._backMaterial.renderHoverLight = true;
  13538. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13539. if (pickedPoint) {
  13540. _this._backMaterial.hoverPosition = pickedPoint;
  13541. _this._backMaterial.hoverColor.a = 1.0;
  13542. }
  13543. else {
  13544. _this._backMaterial.hoverColor.a = 0;
  13545. }
  13546. });
  13547. };
  13548. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13549. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13550. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13551. this._frontMaterial.alpha = 0.5; // Additive
  13552. this._frontMaterial.renderBorders = true;
  13553. };
  13554. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13555. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13556. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13557. };
  13558. HolographicButton.prototype._affectMaterial = function (mesh) {
  13559. // Back
  13560. if (this._shareMaterials) {
  13561. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13562. this._createBackMaterial(mesh);
  13563. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13564. }
  13565. else {
  13566. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13567. }
  13568. // Front
  13569. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13570. this._createFrontMaterial(mesh);
  13571. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13572. }
  13573. else {
  13574. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13575. }
  13576. }
  13577. else {
  13578. this._createBackMaterial(mesh);
  13579. this._createFrontMaterial(mesh);
  13580. }
  13581. this._createPlateMaterial(mesh);
  13582. this._backPlate.material = this._backMaterial;
  13583. this._frontPlate.material = this._frontMaterial;
  13584. this._textPlate.material = this._plateMaterial;
  13585. this._rebuildContent();
  13586. };
  13587. /**
  13588. * Releases all associated resources
  13589. */
  13590. HolographicButton.prototype.dispose = function () {
  13591. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13592. this._disposeTooltip();
  13593. if (!this.shareMaterials) {
  13594. this._backMaterial.dispose();
  13595. this._frontMaterial.dispose();
  13596. this._plateMaterial.dispose();
  13597. if (this._pickedPointObserver) {
  13598. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13599. this._pickedPointObserver = null;
  13600. }
  13601. }
  13602. };
  13603. return HolographicButton;
  13604. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13605. /***/ }),
  13606. /***/ "./3D/controls/index.ts":
  13607. /*!******************************!*\
  13608. !*** ./3D/controls/index.ts ***!
  13609. \******************************/
  13610. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13612. "use strict";
  13613. __webpack_require__.r(__webpack_exports__);
  13614. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13616. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13618. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13620. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13622. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13624. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13626. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13628. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13630. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13632. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13634. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13636. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13638. /***/ }),
  13639. /***/ "./3D/controls/meshButton3D.ts":
  13640. /*!*************************************!*\
  13641. !*** ./3D/controls/meshButton3D.ts ***!
  13642. \*************************************/
  13643. /*! exports provided: MeshButton3D */
  13644. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13645. "use strict";
  13646. __webpack_require__.r(__webpack_exports__);
  13647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13648. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13649. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13650. /**
  13651. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13652. */
  13653. var MeshButton3D = /** @class */ (function (_super) {
  13654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13655. /**
  13656. * Creates a new 3D button based on a mesh
  13657. * @param mesh mesh to become a 3D button
  13658. * @param name defines the control name
  13659. */
  13660. function MeshButton3D(mesh, name) {
  13661. var _this = _super.call(this, name) || this;
  13662. _this._currentMesh = mesh;
  13663. /**
  13664. * Provides a default behavior on hover/out & up/down
  13665. * Override those function to create your own desired behavior specific to your mesh
  13666. */
  13667. _this.pointerEnterAnimation = function () {
  13668. if (!_this.mesh) {
  13669. return;
  13670. }
  13671. _this.mesh.scaling.scaleInPlace(1.1);
  13672. };
  13673. _this.pointerOutAnimation = function () {
  13674. if (!_this.mesh) {
  13675. return;
  13676. }
  13677. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13678. };
  13679. _this.pointerDownAnimation = function () {
  13680. if (!_this.mesh) {
  13681. return;
  13682. }
  13683. _this.mesh.scaling.scaleInPlace(0.95);
  13684. };
  13685. _this.pointerUpAnimation = function () {
  13686. if (!_this.mesh) {
  13687. return;
  13688. }
  13689. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13690. };
  13691. return _this;
  13692. }
  13693. MeshButton3D.prototype._getTypeName = function () {
  13694. return "MeshButton3D";
  13695. };
  13696. // Mesh association
  13697. MeshButton3D.prototype._createNode = function (scene) {
  13698. var _this = this;
  13699. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13700. mesh.metadata = _this;
  13701. });
  13702. return this._currentMesh;
  13703. };
  13704. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13705. };
  13706. return MeshButton3D;
  13707. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13708. /***/ }),
  13709. /***/ "./3D/controls/planePanel.ts":
  13710. /*!***********************************!*\
  13711. !*** ./3D/controls/planePanel.ts ***!
  13712. \***********************************/
  13713. /*! exports provided: PlanePanel */
  13714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13715. "use strict";
  13716. __webpack_require__.r(__webpack_exports__);
  13717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13718. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13719. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13720. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13721. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13722. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13723. /**
  13724. * Class used to create a container panel deployed on the surface of a plane
  13725. */
  13726. var PlanePanel = /** @class */ (function (_super) {
  13727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13728. function PlanePanel() {
  13729. return _super !== null && _super.apply(this, arguments) || this;
  13730. }
  13731. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13732. var mesh = control.mesh;
  13733. if (!mesh) {
  13734. return;
  13735. }
  13736. control.position = nodePosition.clone();
  13737. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13738. target.copyFrom(nodePosition);
  13739. switch (this.orientation) {
  13740. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13741. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13742. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13743. mesh.lookAt(target);
  13744. break;
  13745. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13746. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13747. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13748. mesh.lookAt(target);
  13749. break;
  13750. }
  13751. };
  13752. return PlanePanel;
  13753. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13754. /***/ }),
  13755. /***/ "./3D/controls/scatterPanel.ts":
  13756. /*!*************************************!*\
  13757. !*** ./3D/controls/scatterPanel.ts ***!
  13758. \*************************************/
  13759. /*! exports provided: ScatterPanel */
  13760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13761. "use strict";
  13762. __webpack_require__.r(__webpack_exports__);
  13763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13764. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13765. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13766. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13767. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13768. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13769. /**
  13770. * Class used to create a container panel where items get randomized planar mapping
  13771. */
  13772. var ScatterPanel = /** @class */ (function (_super) {
  13773. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13774. function ScatterPanel() {
  13775. var _this = _super !== null && _super.apply(this, arguments) || this;
  13776. _this._iteration = 100.0;
  13777. return _this;
  13778. }
  13779. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13780. /**
  13781. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13782. */
  13783. get: function () {
  13784. return this._iteration;
  13785. },
  13786. set: function (value) {
  13787. var _this = this;
  13788. if (this._iteration === value) {
  13789. return;
  13790. }
  13791. this._iteration = value;
  13792. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13793. _this._arrangeChildren();
  13794. });
  13795. },
  13796. enumerable: true,
  13797. configurable: true
  13798. });
  13799. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13800. var mesh = control.mesh;
  13801. var newPos = this._scatterMapping(nodePosition);
  13802. if (!mesh) {
  13803. return;
  13804. }
  13805. switch (this.orientation) {
  13806. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13807. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13808. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13809. break;
  13810. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13811. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13812. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13813. break;
  13814. }
  13815. control.position = newPos;
  13816. };
  13817. ScatterPanel.prototype._scatterMapping = function (source) {
  13818. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13819. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13820. return source;
  13821. };
  13822. ScatterPanel.prototype._finalProcessing = function () {
  13823. var meshes = [];
  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. meshes.push(child.mesh);
  13830. }
  13831. for (var count = 0; count < this._iteration; count++) {
  13832. meshes.sort(function (a, b) {
  13833. var distance1 = a.position.lengthSquared();
  13834. var distance2 = b.position.lengthSquared();
  13835. if (distance1 < distance2) {
  13836. return 1;
  13837. }
  13838. else if (distance1 > distance2) {
  13839. return -1;
  13840. }
  13841. return 0;
  13842. });
  13843. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13844. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13845. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13846. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13847. for (var i = 0; i < meshes.length - 1; i++) {
  13848. for (var j = i + 1; j < meshes.length; j++) {
  13849. if (i != j) {
  13850. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13851. // Ignore Z axis
  13852. difference2D.x = difference.x;
  13853. difference2D.y = difference.y;
  13854. var combinedRadius = cellSize;
  13855. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13856. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13857. distance -= minSeparation;
  13858. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13859. difference2D.normalize();
  13860. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13861. meshes[j].position.addInPlace(difference);
  13862. meshes[i].position.subtractInPlace(difference);
  13863. }
  13864. }
  13865. }
  13866. }
  13867. }
  13868. };
  13869. return ScatterPanel;
  13870. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13871. /***/ }),
  13872. /***/ "./3D/controls/spherePanel.ts":
  13873. /*!************************************!*\
  13874. !*** ./3D/controls/spherePanel.ts ***!
  13875. \************************************/
  13876. /*! exports provided: SpherePanel */
  13877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13878. "use strict";
  13879. __webpack_require__.r(__webpack_exports__);
  13880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13881. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13882. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13883. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13884. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13885. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13886. /**
  13887. * Class used to create a container panel deployed on the surface of a sphere
  13888. */
  13889. var SpherePanel = /** @class */ (function (_super) {
  13890. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13891. function SpherePanel() {
  13892. var _this = _super !== null && _super.apply(this, arguments) || this;
  13893. _this._radius = 5.0;
  13894. return _this;
  13895. }
  13896. Object.defineProperty(SpherePanel.prototype, "radius", {
  13897. /**
  13898. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13899. */
  13900. get: function () {
  13901. return this._radius;
  13902. },
  13903. set: function (value) {
  13904. var _this = this;
  13905. if (this._radius === value) {
  13906. return;
  13907. }
  13908. this._radius = value;
  13909. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13910. _this._arrangeChildren();
  13911. });
  13912. },
  13913. enumerable: true,
  13914. configurable: true
  13915. });
  13916. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13917. var mesh = control.mesh;
  13918. if (!mesh) {
  13919. return;
  13920. }
  13921. var newPos = this._sphericalMapping(nodePosition);
  13922. control.position = newPos;
  13923. switch (this.orientation) {
  13924. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13925. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13926. break;
  13927. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13928. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13929. break;
  13930. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13931. break;
  13932. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13933. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13934. break;
  13935. }
  13936. };
  13937. SpherePanel.prototype._sphericalMapping = function (source) {
  13938. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13939. var xAngle = (source.y / this._radius);
  13940. var yAngle = -(source.x / this._radius);
  13941. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13942. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13943. };
  13944. return SpherePanel;
  13945. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13946. /***/ }),
  13947. /***/ "./3D/controls/stackPanel3D.ts":
  13948. /*!*************************************!*\
  13949. !*** ./3D/controls/stackPanel3D.ts ***!
  13950. \*************************************/
  13951. /*! exports provided: StackPanel3D */
  13952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13953. "use strict";
  13954. __webpack_require__.r(__webpack_exports__);
  13955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13957. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13958. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13959. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13960. /**
  13961. * Class used to create a stack panel in 3D on XY plane
  13962. */
  13963. var StackPanel3D = /** @class */ (function (_super) {
  13964. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13965. /**
  13966. * Creates new StackPanel
  13967. * @param isVertical
  13968. */
  13969. function StackPanel3D(isVertical) {
  13970. if (isVertical === void 0) { isVertical = false; }
  13971. var _this = _super.call(this) || this;
  13972. _this._isVertical = false;
  13973. /**
  13974. * Gets or sets the distance between elements
  13975. */
  13976. _this.margin = 0.1;
  13977. _this._isVertical = isVertical;
  13978. return _this;
  13979. }
  13980. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13981. /**
  13982. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13983. */
  13984. get: function () {
  13985. return this._isVertical;
  13986. },
  13987. set: function (value) {
  13988. var _this = this;
  13989. if (this._isVertical === value) {
  13990. return;
  13991. }
  13992. this._isVertical = value;
  13993. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13994. _this._arrangeChildren();
  13995. });
  13996. },
  13997. enumerable: true,
  13998. configurable: true
  13999. });
  14000. StackPanel3D.prototype._arrangeChildren = function () {
  14001. var width = 0;
  14002. var height = 0;
  14003. var controlCount = 0;
  14004. var extendSizes = [];
  14005. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14006. // Measure
  14007. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14008. var child = _a[_i];
  14009. if (!child.mesh) {
  14010. continue;
  14011. }
  14012. controlCount++;
  14013. child.mesh.computeWorldMatrix(true);
  14014. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14015. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14016. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14017. extendSizes.push(extendSize);
  14018. if (this._isVertical) {
  14019. height += extendSize.y;
  14020. }
  14021. else {
  14022. width += extendSize.x;
  14023. }
  14024. }
  14025. if (this._isVertical) {
  14026. height += (controlCount - 1) * this.margin / 2;
  14027. }
  14028. else {
  14029. width += (controlCount - 1) * this.margin / 2;
  14030. }
  14031. // Arrange
  14032. var offset;
  14033. if (this._isVertical) {
  14034. offset = -height;
  14035. }
  14036. else {
  14037. offset = -width;
  14038. }
  14039. var index = 0;
  14040. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14041. var child = _c[_b];
  14042. if (!child.mesh) {
  14043. continue;
  14044. }
  14045. controlCount--;
  14046. var extendSize = extendSizes[index++];
  14047. if (this._isVertical) {
  14048. child.position.y = offset + extendSize.y;
  14049. child.position.x = 0;
  14050. offset += extendSize.y * 2;
  14051. }
  14052. else {
  14053. child.position.x = offset + extendSize.x;
  14054. child.position.y = 0;
  14055. offset += extendSize.x * 2;
  14056. }
  14057. offset += (controlCount > 0 ? this.margin : 0);
  14058. }
  14059. };
  14060. return StackPanel3D;
  14061. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14062. /***/ }),
  14063. /***/ "./3D/controls/volumeBasedPanel.ts":
  14064. /*!*****************************************!*\
  14065. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14066. \*****************************************/
  14067. /*! exports provided: VolumeBasedPanel */
  14068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14069. "use strict";
  14070. __webpack_require__.r(__webpack_exports__);
  14071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14073. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14074. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14075. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14076. /**
  14077. * Abstract class used to create a container panel deployed on the surface of a volume
  14078. */
  14079. var VolumeBasedPanel = /** @class */ (function (_super) {
  14080. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  14081. /**
  14082. * Creates new VolumeBasedPanel
  14083. */
  14084. function VolumeBasedPanel() {
  14085. var _this = _super.call(this) || this;
  14086. _this._columns = 10;
  14087. _this._rows = 0;
  14088. _this._rowThenColum = true;
  14089. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14090. /**
  14091. * Gets or sets the distance between elements
  14092. */
  14093. _this.margin = 0;
  14094. return _this;
  14095. }
  14096. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14097. /**
  14098. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14099. * | Value | Type | Description |
  14100. * | ----- | ----------------------------------- | ----------- |
  14101. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14102. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14103. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14104. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14105. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14106. */
  14107. get: function () {
  14108. return this._orientation;
  14109. },
  14110. set: function (value) {
  14111. var _this = this;
  14112. if (this._orientation === value) {
  14113. return;
  14114. }
  14115. this._orientation = value;
  14116. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14117. _this._arrangeChildren();
  14118. });
  14119. },
  14120. enumerable: true,
  14121. configurable: true
  14122. });
  14123. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14124. /**
  14125. * Gets or sets the number of columns requested (10 by default).
  14126. * The panel will automatically compute the number of rows based on number of child controls.
  14127. */
  14128. get: function () {
  14129. return this._columns;
  14130. },
  14131. set: function (value) {
  14132. var _this = this;
  14133. if (this._columns === value) {
  14134. return;
  14135. }
  14136. this._columns = value;
  14137. this._rowThenColum = true;
  14138. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14139. _this._arrangeChildren();
  14140. });
  14141. },
  14142. enumerable: true,
  14143. configurable: true
  14144. });
  14145. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14146. /**
  14147. * Gets or sets a the number of rows requested.
  14148. * The panel will automatically compute the number of columns based on number of child controls.
  14149. */
  14150. get: function () {
  14151. return this._rows;
  14152. },
  14153. set: function (value) {
  14154. var _this = this;
  14155. if (this._rows === value) {
  14156. return;
  14157. }
  14158. this._rows = value;
  14159. this._rowThenColum = false;
  14160. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14161. _this._arrangeChildren();
  14162. });
  14163. },
  14164. enumerable: true,
  14165. configurable: true
  14166. });
  14167. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14168. this._cellWidth = 0;
  14169. this._cellHeight = 0;
  14170. var rows = 0;
  14171. var columns = 0;
  14172. var controlCount = 0;
  14173. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14174. // Measure
  14175. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14176. var child = _a[_i];
  14177. if (!child.mesh) {
  14178. continue;
  14179. }
  14180. controlCount++;
  14181. child.mesh.computeWorldMatrix(true);
  14182. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14183. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14184. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14185. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14186. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14187. diff.scaleInPlace(0.5);
  14188. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14189. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14190. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14191. }
  14192. this._cellWidth += this.margin * 2;
  14193. this._cellHeight += this.margin * 2;
  14194. // Arrange
  14195. if (this._rowThenColum) {
  14196. columns = this._columns;
  14197. rows = Math.ceil(controlCount / this._columns);
  14198. }
  14199. else {
  14200. rows = this._rows;
  14201. columns = Math.ceil(controlCount / this._rows);
  14202. }
  14203. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14204. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14205. var nodeGrid = [];
  14206. var cellCounter = 0;
  14207. if (this._rowThenColum) {
  14208. for (var r = 0; r < rows; r++) {
  14209. for (var c = 0; c < columns; c++) {
  14210. 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));
  14211. cellCounter++;
  14212. if (cellCounter > controlCount) {
  14213. break;
  14214. }
  14215. }
  14216. }
  14217. }
  14218. else {
  14219. for (var c = 0; c < columns; c++) {
  14220. for (var r = 0; r < rows; r++) {
  14221. 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));
  14222. cellCounter++;
  14223. if (cellCounter > controlCount) {
  14224. break;
  14225. }
  14226. }
  14227. }
  14228. }
  14229. cellCounter = 0;
  14230. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14231. var child = _c[_b];
  14232. if (!child.mesh) {
  14233. continue;
  14234. }
  14235. this._mapGridNode(child, nodeGrid[cellCounter]);
  14236. cellCounter++;
  14237. }
  14238. this._finalProcessing();
  14239. };
  14240. /** Child classes can implement this function to provide additional processing */
  14241. VolumeBasedPanel.prototype._finalProcessing = function () {
  14242. };
  14243. return VolumeBasedPanel;
  14244. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14245. /***/ }),
  14246. /***/ "./3D/gui3DManager.ts":
  14247. /*!****************************!*\
  14248. !*** ./3D/gui3DManager.ts ***!
  14249. \****************************/
  14250. /*! exports provided: GUI3DManager */
  14251. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14252. "use strict";
  14253. __webpack_require__.r(__webpack_exports__);
  14254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14255. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14256. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14257. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14258. /**
  14259. * Class used to manage 3D user interface
  14260. * @see http://doc.babylonjs.com/how_to/gui3d
  14261. */
  14262. var GUI3DManager = /** @class */ (function () {
  14263. /**
  14264. * Creates a new GUI3DManager
  14265. * @param scene
  14266. */
  14267. function GUI3DManager(scene) {
  14268. var _this = this;
  14269. /** @hidden */
  14270. this._lastControlOver = {};
  14271. /** @hidden */
  14272. this._lastControlDown = {};
  14273. /**
  14274. * Observable raised when the point picked by the pointer events changed
  14275. */
  14276. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14277. // Shared resources
  14278. /** @hidden */
  14279. this._sharedMaterials = {};
  14280. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14281. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14282. _this._sceneDisposeObserver = null;
  14283. _this._utilityLayer = null;
  14284. _this.dispose();
  14285. });
  14286. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14287. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14288. this._utilityLayer.pickUtilitySceneFirst = false;
  14289. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14290. return mesh && mesh.metadata && mesh.metadata._node;
  14291. };
  14292. // Root
  14293. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14294. this._rootContainer._host = this;
  14295. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14296. // Events
  14297. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14298. _this._handlePointerOut(pointerId, true);
  14299. });
  14300. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14301. _this._doPicking(pi);
  14302. });
  14303. // Scene
  14304. this._utilityLayer.utilityLayerScene.autoClear = false;
  14305. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14306. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14307. }
  14308. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14309. /** Gets the hosting scene */
  14310. get: function () {
  14311. return this._scene;
  14312. },
  14313. enumerable: true,
  14314. configurable: true
  14315. });
  14316. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14317. /** Gets associated utility layer */
  14318. get: function () {
  14319. return this._utilityLayer;
  14320. },
  14321. enumerable: true,
  14322. configurable: true
  14323. });
  14324. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14325. var previousControlOver = this._lastControlOver[pointerId];
  14326. if (previousControlOver) {
  14327. previousControlOver._onPointerOut(previousControlOver);
  14328. delete this._lastControlOver[pointerId];
  14329. }
  14330. if (isPointerUp) {
  14331. if (this._lastControlDown[pointerId]) {
  14332. this._lastControlDown[pointerId].forcePointerUp();
  14333. delete this._lastControlDown[pointerId];
  14334. }
  14335. }
  14336. this.onPickedPointChangedObservable.notifyObservers(null);
  14337. };
  14338. GUI3DManager.prototype._doPicking = function (pi) {
  14339. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14340. return false;
  14341. }
  14342. var pointerEvent = (pi.event);
  14343. var pointerId = pointerEvent.pointerId || 0;
  14344. var buttonIndex = pointerEvent.button;
  14345. var pickingInfo = pi.pickInfo;
  14346. if (!pickingInfo || !pickingInfo.hit) {
  14347. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14348. return false;
  14349. }
  14350. var control = (pickingInfo.pickedMesh.metadata);
  14351. if (pickingInfo.pickedPoint) {
  14352. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14353. }
  14354. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14355. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14356. if (this._lastControlOver[pointerId]) {
  14357. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14358. }
  14359. delete this._lastControlOver[pointerId];
  14360. }
  14361. }
  14362. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14363. if (this._lastControlDown[pointerEvent.pointerId]) {
  14364. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14365. delete this._lastControlDown[pointerEvent.pointerId];
  14366. }
  14367. if (pointerEvent.pointerType === "touch") {
  14368. this._handlePointerOut(pointerId, false);
  14369. }
  14370. }
  14371. return true;
  14372. };
  14373. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14374. /**
  14375. * Gets the root container
  14376. */
  14377. get: function () {
  14378. return this._rootContainer;
  14379. },
  14380. enumerable: true,
  14381. configurable: true
  14382. });
  14383. /**
  14384. * Gets a boolean indicating if the given control is in the root child list
  14385. * @param control defines the control to check
  14386. * @returns true if the control is in the root child list
  14387. */
  14388. GUI3DManager.prototype.containsControl = function (control) {
  14389. return this._rootContainer.containsControl(control);
  14390. };
  14391. /**
  14392. * Adds a control to the root child list
  14393. * @param control defines the control to add
  14394. * @returns the current manager
  14395. */
  14396. GUI3DManager.prototype.addControl = function (control) {
  14397. this._rootContainer.addControl(control);
  14398. return this;
  14399. };
  14400. /**
  14401. * Removes a control from the root child list
  14402. * @param control defines the control to remove
  14403. * @returns the current container
  14404. */
  14405. GUI3DManager.prototype.removeControl = function (control) {
  14406. this._rootContainer.removeControl(control);
  14407. return this;
  14408. };
  14409. /**
  14410. * Releases all associated resources
  14411. */
  14412. GUI3DManager.prototype.dispose = function () {
  14413. this._rootContainer.dispose();
  14414. for (var materialName in this._sharedMaterials) {
  14415. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14416. continue;
  14417. }
  14418. this._sharedMaterials[materialName].dispose();
  14419. }
  14420. this._sharedMaterials = {};
  14421. if (this._pointerOutObserver && this._utilityLayer) {
  14422. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14423. this._pointerOutObserver = null;
  14424. }
  14425. this.onPickedPointChangedObservable.clear();
  14426. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14427. if (utilityLayerScene) {
  14428. if (this._pointerObserver) {
  14429. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14430. this._pointerObserver = null;
  14431. }
  14432. }
  14433. if (this._scene) {
  14434. if (this._sceneDisposeObserver) {
  14435. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14436. this._sceneDisposeObserver = null;
  14437. }
  14438. }
  14439. if (this._utilityLayer) {
  14440. this._utilityLayer.dispose();
  14441. }
  14442. };
  14443. return GUI3DManager;
  14444. }());
  14445. /***/ }),
  14446. /***/ "./3D/index.ts":
  14447. /*!*********************!*\
  14448. !*** ./3D/index.ts ***!
  14449. \*********************/
  14450. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14452. "use strict";
  14453. __webpack_require__.r(__webpack_exports__);
  14454. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14467. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14470. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14472. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14474. /***/ }),
  14475. /***/ "./3D/materials/fluentMaterial.ts":
  14476. /*!****************************************!*\
  14477. !*** ./3D/materials/fluentMaterial.ts ***!
  14478. \****************************************/
  14479. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14481. "use strict";
  14482. __webpack_require__.r(__webpack_exports__);
  14483. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14485. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14486. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  14487. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14488. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14489. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14490. /** @hidden */
  14491. var FluentMaterialDefines = /** @class */ (function (_super) {
  14492. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14493. function FluentMaterialDefines() {
  14494. var _this = _super.call(this) || this;
  14495. _this.INNERGLOW = false;
  14496. _this.BORDER = false;
  14497. _this.HOVERLIGHT = false;
  14498. _this.TEXTURE = false;
  14499. _this.rebuild();
  14500. return _this;
  14501. }
  14502. return FluentMaterialDefines;
  14503. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14504. /**
  14505. * Class used to render controls with fluent desgin
  14506. */
  14507. var FluentMaterial = /** @class */ (function (_super) {
  14508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14509. /**
  14510. * Creates a new Fluent material
  14511. * @param name defines the name of the material
  14512. * @param scene defines the hosting scene
  14513. */
  14514. function FluentMaterial(name, scene) {
  14515. var _this = _super.call(this, name, scene) || this;
  14516. /**
  14517. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14518. */
  14519. _this.innerGlowColorIntensity = 0.5;
  14520. /**
  14521. * Gets or sets the inner glow color (white by default)
  14522. */
  14523. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14524. /**
  14525. * Gets or sets alpha value (default is 1.0)
  14526. */
  14527. _this.alpha = 1.0;
  14528. /**
  14529. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14530. */
  14531. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14532. /**
  14533. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14534. */
  14535. _this.renderBorders = false;
  14536. /**
  14537. * Gets or sets border width (default is 0.5)
  14538. */
  14539. _this.borderWidth = 0.5;
  14540. /**
  14541. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14542. */
  14543. _this.edgeSmoothingValue = 0.02;
  14544. /**
  14545. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14546. */
  14547. _this.borderMinValue = 0.1;
  14548. /**
  14549. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14550. */
  14551. _this.renderHoverLight = false;
  14552. /**
  14553. * Gets or sets the radius used to render the hover light (default is 1.0)
  14554. */
  14555. _this.hoverRadius = 1.0;
  14556. /**
  14557. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14558. */
  14559. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14560. /**
  14561. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14562. */
  14563. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14564. return _this;
  14565. }
  14566. FluentMaterial.prototype.needAlphaBlending = function () {
  14567. return this.alpha !== 1.0;
  14568. };
  14569. FluentMaterial.prototype.needAlphaTesting = function () {
  14570. return false;
  14571. };
  14572. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14573. return null;
  14574. };
  14575. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14576. if (this.isFrozen) {
  14577. if (this._wasPreviouslyReady && subMesh.effect) {
  14578. return true;
  14579. }
  14580. }
  14581. if (!subMesh._materialDefines) {
  14582. subMesh._materialDefines = new FluentMaterialDefines();
  14583. }
  14584. var scene = this.getScene();
  14585. var defines = subMesh._materialDefines;
  14586. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14587. if (defines._renderId === scene.getRenderId()) {
  14588. return true;
  14589. }
  14590. }
  14591. if (defines._areTexturesDirty) {
  14592. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14593. defines.BORDER = this.renderBorders;
  14594. defines.HOVERLIGHT = this.renderHoverLight;
  14595. if (this._albedoTexture) {
  14596. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14597. return false;
  14598. }
  14599. else {
  14600. defines.TEXTURE = true;
  14601. }
  14602. }
  14603. else {
  14604. defines.TEXTURE = false;
  14605. }
  14606. }
  14607. var engine = scene.getEngine();
  14608. // Get correct effect
  14609. if (defines.isDirty) {
  14610. defines.markAsProcessed();
  14611. scene.resetCachedMaterial();
  14612. //Attributes
  14613. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14614. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14615. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14616. var shaderName = "fluent";
  14617. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14618. "hoverColor", "hoverPosition", "hoverRadius"
  14619. ];
  14620. var samplers = ["albedoSampler"];
  14621. var uniformBuffers = new Array();
  14622. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14623. uniformsNames: uniforms,
  14624. uniformBuffersNames: uniformBuffers,
  14625. samplers: samplers,
  14626. defines: defines,
  14627. maxSimultaneousLights: 4
  14628. });
  14629. var join = defines.toString();
  14630. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14631. attributes: attribs,
  14632. uniformsNames: uniforms,
  14633. uniformBuffersNames: uniformBuffers,
  14634. samplers: samplers,
  14635. defines: join,
  14636. fallbacks: null,
  14637. onCompiled: this.onCompiled,
  14638. onError: this.onError,
  14639. indexParameters: { maxSimultaneousLights: 4 }
  14640. }, engine));
  14641. }
  14642. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14643. return false;
  14644. }
  14645. defines._renderId = scene.getRenderId();
  14646. this._wasPreviouslyReady = true;
  14647. return true;
  14648. };
  14649. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14650. var scene = this.getScene();
  14651. var defines = subMesh._materialDefines;
  14652. if (!defines) {
  14653. return;
  14654. }
  14655. var effect = subMesh.effect;
  14656. if (!effect) {
  14657. return;
  14658. }
  14659. this._activeEffect = effect;
  14660. // Matrices
  14661. this.bindOnlyWorldMatrix(world);
  14662. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14663. if (this._mustRebind(scene, effect)) {
  14664. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14665. if (defines.INNERGLOW) {
  14666. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14667. }
  14668. if (defines.BORDER) {
  14669. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14670. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14671. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14672. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14673. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14674. }
  14675. if (defines.HOVERLIGHT) {
  14676. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14677. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14678. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14679. }
  14680. if (defines.TEXTURE) {
  14681. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14682. }
  14683. }
  14684. this._afterBind(mesh, this._activeEffect);
  14685. };
  14686. FluentMaterial.prototype.getActiveTextures = function () {
  14687. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14688. return activeTextures;
  14689. };
  14690. FluentMaterial.prototype.hasTexture = function (texture) {
  14691. if (_super.prototype.hasTexture.call(this, texture)) {
  14692. return true;
  14693. }
  14694. return false;
  14695. };
  14696. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14697. _super.prototype.dispose.call(this, forceDisposeEffect);
  14698. };
  14699. FluentMaterial.prototype.clone = function (name) {
  14700. var _this = this;
  14701. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14702. };
  14703. FluentMaterial.prototype.serialize = function () {
  14704. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14705. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14706. return serializationObject;
  14707. };
  14708. FluentMaterial.prototype.getClassName = function () {
  14709. return "FluentMaterial";
  14710. };
  14711. // Statics
  14712. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14713. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14714. };
  14715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14716. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14717. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14718. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14720. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14721. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14723. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14724. ], FluentMaterial.prototype, "alpha", void 0);
  14725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14726. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14727. ], FluentMaterial.prototype, "albedoColor", void 0);
  14728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14729. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14730. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14731. ], FluentMaterial.prototype, "renderBorders", void 0);
  14732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14733. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14734. ], FluentMaterial.prototype, "borderWidth", void 0);
  14735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14736. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14737. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14738. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14739. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14740. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14741. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14742. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14743. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14744. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14745. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14746. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14747. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14748. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14749. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14750. ], FluentMaterial.prototype, "hoverColor", void 0);
  14751. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14752. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14753. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14754. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14755. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14756. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14758. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14759. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14760. return FluentMaterial;
  14761. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14762. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14763. /***/ }),
  14764. /***/ "./3D/materials/index.ts":
  14765. /*!*******************************!*\
  14766. !*** ./3D/materials/index.ts ***!
  14767. \*******************************/
  14768. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14770. "use strict";
  14771. __webpack_require__.r(__webpack_exports__);
  14772. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14775. /***/ }),
  14776. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14777. /*!*************************************************!*\
  14778. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14779. \*************************************************/
  14780. /*! exports provided: fluentPixelShader */
  14781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14782. "use strict";
  14783. __webpack_require__.r(__webpack_exports__);
  14784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14785. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14786. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14787. var name = 'fluentPixelShader';
  14788. 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}";
  14789. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14790. /** @hidden */
  14791. var fluentPixelShader = { name: name, shader: shader };
  14792. /***/ }),
  14793. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14794. /*!***********************************************!*\
  14795. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14796. \***********************************************/
  14797. /*! exports provided: fluentVertexShader */
  14798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14799. "use strict";
  14800. __webpack_require__.r(__webpack_exports__);
  14801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14802. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  14803. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14804. var name = 'fluentVertexShader';
  14805. 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";
  14806. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14807. /** @hidden */
  14808. var fluentVertexShader = { name: name, shader: shader };
  14809. /***/ }),
  14810. /***/ "./3D/vector3WithInfo.ts":
  14811. /*!*******************************!*\
  14812. !*** ./3D/vector3WithInfo.ts ***!
  14813. \*******************************/
  14814. /*! exports provided: Vector3WithInfo */
  14815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14816. "use strict";
  14817. __webpack_require__.r(__webpack_exports__);
  14818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14819. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14820. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14821. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14822. /**
  14823. * Class used to transport Vector3 information for pointer events
  14824. */
  14825. var Vector3WithInfo = /** @class */ (function (_super) {
  14826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14827. /**
  14828. * Creates a new Vector3WithInfo
  14829. * @param source defines the vector3 data to transport
  14830. * @param buttonIndex defines the current mouse button index
  14831. */
  14832. function Vector3WithInfo(source,
  14833. /** defines the current mouse button index */
  14834. buttonIndex) {
  14835. if (buttonIndex === void 0) { buttonIndex = 0; }
  14836. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14837. _this.buttonIndex = buttonIndex;
  14838. return _this;
  14839. }
  14840. return Vector3WithInfo;
  14841. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14842. /***/ }),
  14843. /***/ "./index.ts":
  14844. /*!******************!*\
  14845. !*** ./index.ts ***!
  14846. \******************/
  14847. /*! 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, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14849. "use strict";
  14850. __webpack_require__.r(__webpack_exports__);
  14851. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14891. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14908. /***/ }),
  14909. /***/ "./legacy/legacy.ts":
  14910. /*!**************************!*\
  14911. !*** ./legacy/legacy.ts ***!
  14912. \**************************/
  14913. /*! 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, ScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14915. "use strict";
  14916. __webpack_require__.r(__webpack_exports__);
  14917. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14968. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14973. /**
  14974. * Legacy support, defining window.BABYLON.GUI (global variable).
  14975. *
  14976. * This is the entry point for the UMD module.
  14977. * The entry point for a future ESM package should be index.ts
  14978. */
  14979. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14980. if (typeof globalObject !== "undefined") {
  14981. globalObject.BABYLON = globalObject.BABYLON || {};
  14982. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14983. }
  14984. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14985. /***/ }),
  14986. /***/ "babylonjs/Maths/math":
  14987. /*!****************************************************************************************************!*\
  14988. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14989. \****************************************************************************************************/
  14990. /*! no static exports found */
  14991. /***/ (function(module, exports) {
  14992. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  14993. /***/ })
  14994. /******/ });
  14995. });
  14996. //# sourceMappingURL=babylon.gui.js.map