@here/harp-examples
Version:
harp.gl Examples
1 lines • 6.7 kB
JavaScript
(()=>{"use strict";var e={711:(e,n,o)=>{n.Y=void 0;const t=o(8428),r=o(3860),a=o(1929),i=o(4428);!function(e){const n=new a,o=new r.GUI({hideable:!1}),d={input:"Type to start...",fontName:"",gridEnabled:!0,boundsEnabled:!0,color:{r:0,g:0,b:0},backgroundColor:{r:0,g:0,b:0}};let l,c,s,u,h=!1,w=d.input;const g=new i.Vector3(Math.floor(-window.innerWidth/4),0,0),f=new i.Box2(new i.Vector2,new i.Vector2),p=[];let b,m,C,y;const x=g.clone();let S,k,v=!1;var E;l=new(null!==(E=i.WebGL1Renderer)&&void 0!==E?E:i.WebGLRenderer)({canvas:document.getElementById("mapCanvas")}),l.domElement.addEventListener("contextmenu",(e=>e.preventDefault())),l.autoClear=!1,l.setClearColor(16777215),l.setPixelRatio(window.devicePixelRatio),l.setSize(window.innerWidth,window.innerHeight),document.body.appendChild(l.domElement),document.body.appendChild(n.dom),window.addEventListener("resize",(function(){l.setSize(window.innerWidth,window.innerHeight),c.left=-window.innerWidth/2,c.right=window.innerWidth/2,c.bottom=-window.innerHeight/2,c.top=window.innerHeight/2,c.updateProjectionMatrix()})),window.addEventListener("keydown",(function(e){const n=e.keyCode||e.which;if(8===n)w=w.slice(0,w.length-1);else if(16===n)v=!0;else{const e=v?String.fromCharCode(n):String.fromCharCode(n).toLowerCase();w+=e,h=!1,s.fontCatalog.loadCharset(e,u).then((()=>{h=!0}))}})),window.addEventListener("keyup",(function(e){16===(e.keyCode||e.which)&&(v=!1)})),c=new i.OrthographicCamera(-window.innerWidth/2,window.innerWidth/2,window.innerHeight/2,-window.innerHeight/2),c.position.z=1,c.near=0,c.updateProjectionMatrix(),u=new t.TextRenderStyle({fontSize:{unit:t.FontUnit.Pixel,size:64,backgroundSize:8},color:new i.Color(16711680),backgroundColor:new i.Color(0),backgroundOpacity:1}),t.FontCatalog.load("resources/fonts/Default_FontCatalog.json",2048).then((e=>{s=new t.TextCanvas({renderer:l,fontCatalog:e,minGlyphCount:16,maxGlyphCount:256}),e.loadCharset(w,u).then((()=>{h=!0}))})),b=new i.Scene,m=new i.BufferAttribute(new Float32Array(32768),4),m.setUsage(i.DynamicDrawUsage),C=new i.BufferGeometry,C.setAttribute("position",m),y=new i.Line(C,new i.LineBasicMaterial({color:16711680,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.2})),b.add(y),S=new i.Scene,S.add(new i.LineSegments(new i.WireframeGeometry(new i.PlaneBufferGeometry(window.innerWidth-1,window.innerHeight-1,window.innerWidth/16,window.innerHeight/16)),new i.LineBasicMaterial({color:10066329,depthWrite:!1,depthTest:!1})),new i.LineSegments(new i.WireframeGeometry(new i.PlaneBufferGeometry(window.innerWidth-1,window.innerHeight-1,2,2)),new i.LineBasicMaterial({color:16711680,depthWrite:!1,depthTest:!1}))),k=new i.Mesh(new i.SphereBufferGeometry(4,4,4),new i.MeshBasicMaterial({color:16711680})),S.add(k),d.color.r=255*u.color.r,d.color.g=255*u.color.g,d.color.b=255*u.color.b,d.backgroundColor.r=255*u.backgroundColor.r,d.backgroundColor.g=255*u.backgroundColor.g,d.backgroundColor.b=255*u.backgroundColor.b,o.add(d,"input").onFinishChange((e=>{w=t.ContextualArabicConverter.instance.convert(e),h=!1,s.fontCatalog.loadCharset(w,u).then((()=>{h=!0}))})),o.add(d,"gridEnabled"),o.add(d,"boundsEnabled"),o.add(u.fontSize,"unit",{Em:t.FontUnit.Em,Pixel:t.FontUnit.Pixel,Point:t.FontUnit.Point,Percent:t.FontUnit.Percent}).onChange((e=>{u.fontSize.unit=Number(e)})),o.add(u.fontSize,"size",.1,100,.1),o.add(u.fontSize,"backgroundSize",0,100,.1),o.addColor(d,"color").onChange((()=>{u.color.r=d.color.r/255,u.color.g=d.color.g/255,u.color.b=d.color.b/255})),o.add(u,"opacity",0,1,.01),o.addColor(d,"backgroundColor").onChange((()=>{u.backgroundColor.r=d.backgroundColor.r/255,u.backgroundColor.g=d.backgroundColor.g/255,u.backgroundColor.b=d.backgroundColor.b/255})),o.add(u,"backgroundOpacity",0,1,.1),o.add(d,"fontName").onFinishChange((e=>{u.fontName=e,h=!1,s.fontCatalog.loadCharset(w,u).then((()=>{h=!0}))})),o.add(u,"fontStyle",{Regular:t.FontStyle.Regular,Bold:t.FontStyle.Bold,Italic:t.FontStyle.Italic,BoldItalic:t.FontStyle.BoldItalic}).onChange((e=>{u.fontStyle=Number(e),h=!1,s.fontCatalog.loadCharset(w,u).then((()=>{h=!0}))})),o.add(u,"fontVariant",{Regular:t.FontVariant.Regular,AllCaps:t.FontVariant.AllCaps,SmallCaps:t.FontVariant.SmallCaps}).onChange((e=>{u.fontVariant=Number(e),h=!1,s.fontCatalog.loadCharset(w,u).then((()=>{h=!0}))})),function e(){requestAnimationFrame(e),l.clear(),d.gridEnabled&&(k.position.set(g.x,g.y,-4),l.render(S,c)),g.set(Math.floor(-window.innerWidth/4),0,0),x.copy(g),h&&(s.clear(),s.textRenderStyle=u,d.boundsEnabled&&s.measureText(w,f,{outputCharacterBounds:p}),s.addText(w,g,{updatePosition:!0}),s.render(c)),d.boundsEnabled&&(function(e){const n=m.array;let o=0;n[o++]=f.min.x,n[o++]=f.min.y,n[o++]=0,n[o++]=1,n[o++]=f.min.x,n[o++]=f.max.y,n[o++]=0,n[o++]=1,n[o++]=f.max.x,n[o++]=f.max.y,n[o++]=0,n[o++]=1,n[o++]=f.max.x,n[o++]=f.min.y,n[o++]=0,n[o++]=1,n[o++]=f.min.x,n[o++]=f.min.y,n[o++]=0,n[o++]=1;for(const e of p)n[o++]=e.min.x,n[o++]=e.min.y,n[o++]=0,n[o++]=1,n[o++]=e.min.x,n[o++]=e.max.y,n[o++]=0,n[o++]=1,n[o++]=e.max.x,n[o++]=e.max.y,n[o++]=0,n[o++]=1,n[o++]=e.max.x,n[o++]=e.min.y,n[o++]=0,n[o++]=1,n[o++]=e.min.x,n[o++]=e.min.y,n[o++]=0,n[o++]=1;m.needsUpdate=!0,m.updateRange.offset=0,m.updateRange.count=o,C.setDrawRange(0,o/4),y.position.x=e.x,y.position.y=e.y}(x),l.render(b,c)),n.update()}()}(n.Y||(n.Y={}))},4428:e=>{e.exports=THREE}},n={};function o(t){if(n[t])return n[t].exports;var r=n[t]={exports:{}};return e[t].call(r.exports,r,r.exports,o),r.exports}o.m=e,o.x=e=>{},o.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return o.d(n,{a:n}),n},o.d=(e,n)=>{for(var t in n)o.o(n,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.j=546,(()=>{var e={546:0,738:0},n=[[711,592]],t=e=>{},r=(r,a)=>{for(var i,d,[l,c,s,u]=a,h=0,w=[];h<l.length;h++)d=l[h],o.o(e,d)&&e[d]&&w.push(e[d][0]),e[d]=0;for(i in c)o.o(c,i)&&(o.m[i]=c[i]);for(s&&s(o),r&&r(a);w.length;)w.shift()();return u&&n.push.apply(n,u),t()},a=self.webpackChunk_here_harp_examples=self.webpackChunk_here_harp_examples||[];function i(){for(var t,r=0;r<n.length;r++){for(var a=n[r],i=!0,d=1;d<a.length;d++){var l=a[d];0!==e[l]&&(i=!1)}i&&(n.splice(r--,1),t=o(o.s=a[0]))}return 0===n.length&&(o.x(),o.x=e=>{}),t}a.forEach(r.bind(null,0)),a.push=r.bind(null,a.push.bind(a));var d=o.x;o.x=()=>(o.x=d||(e=>{}),(t=i)())})(),o.x()})();