@here/harp-examples
Version:
harp.gl Examples
1 lines • 5.01 kB
JavaScript
(()=>{"use strict";var e={886:(e,t,i)=>{t.B=void 0;const a=i(1526),n=i(8957),s=i(5636),o=i(3074),r=i(2998),p=i(4428),d=i(1830),h=i(4104),c=i(4565);!function(e){class t{constructor(e){this.options=e,this.helpers=[],this.mapView=new o.MapView(e),this.mapView.fog.enabled=!1;const t=new n.GeoCoordinates(46.207,6.147);this.mapView.lookAt({target:t,zoomLevel:16.5}),this.mapControls=new s.MapControls(this.mapView),this.mapControls.maxTiltAngle=90,this.mapControls.enabled=!1,o.CopyrightElementHandler.install("copyrightNotice",this.mapView),void 0!==e.geoCenter&&(this.mapView.geoCenter=e.geoCenter),this.mapView.resize(window.innerWidth,window.innerHeight),window.addEventListener("resize",(()=>{this.mapView.resize(window.innerWidth,window.innerHeight)}))}start(){const e=new r.VectorTileDataSource({baseUrl:"https://vector.hereapi.com/v2/vectortiles/base/mc",authenticationCode:c.apikey}),t=new a.DebugTileDataSource(n.webMercatorTilingScheme);this.mapView.addDataSource(e),this.mapView.addDataSource(t),this.initializeDebugView()}initializeDebugView(){const e=new p.PerspectiveCamera(this.mapView.camera.fov,this.mapView.canvas.width/this.mapView.canvas.height,100,4e5);this.mapView.scene.add(e);const t=new p.PerspectiveCamera;this.mapView.scene.add(t),e.position.set(0,-4e3,2700),this.mapView.pointOfView=e;const i=new h.TransformControls(e,this.mapView.canvas);i.setSpace("world"),i.attach(t);const a=()=>{this.mapView.camera.position.add(t.position);const e=o.MapViewUtils.extractAttitude(this.mapView,t);e.pitch=Math.max(Math.min(e.pitch,p.MathUtils.degToRad(this.mapControls.maxTiltAngle)),0),o.MapViewUtils.setRotation(this.mapView,p.MathUtils.radToDeg(e.yaw),p.MathUtils.radToDeg(e.pitch)),t.copy(this.mapView.camera),t.position.setScalar(0)};a();const n=()=>{t.copy(this.mapView.camera,!0),t.position.setScalar(0)};i.addEventListener("mouseDown",(()=>{r.enabled=!1})),i.addEventListener("mouseUp",(()=>{r.enabled=!0})),i.addEventListener("objectChange",(()=>{a(),this.mapView.update()})),this.mapView.scene.add(i);const s=new p.CameraHelper(t);s.renderOrder=5e3,this.mapView.scene.add(s),this.helpers.push(s);const r=new d.TrackballControls(e,this.mapView.canvas);r.target.set(0,0,-2e3),r.staticMoving=!0,r.rotateSpeed=3,r.zoomSpeed=4,r.panSpeed=2,r.addEventListener("start",(()=>{this.mapView.beginAnimation()})),r.addEventListener("end",(()=>{this.mapView.endAnimation()})),this.mapView.addEventListener(o.MapViewEventNames.Render,(()=>{r.update(),this.helpers.forEach((e=>e.update()))})),window.focus(),window.addEventListener("resize",(()=>{const{width:t,height:i}=this.mapView.canvas;e.aspect=t/i,e.updateProjectionMatrix(),this.mapView.update()})),window.addEventListener("keydown",(t=>{switch(t.code){case"KeyT":i.setMode("translate"),i.showX=!0,i.showY=!0,i.showZ=!0,this.mapView.update();break;case"KeyR":i.setMode("rotate"),i.showX=!0,i.showY=!1,i.showZ=!0,this.mapView.update();break;case"KeyV":void 0!==this.mapView.pointOfView?(this.mapView.pointOfView=void 0,this.mapControls.enabled=!0,i.enabled=!1,r.enabled=!1,a()):(this.mapView.pointOfView=e,this.mapControls.enabled=!1,i.enabled=!0,r.enabled=!0,n()),this.mapView.update()}}))}}e.FreeCameraApp=t,function(){const e=document.createElement("div");e.innerHTML="\nPress 'R' to rotate<br>\nPress 'T' to translate<br>\nPress 'V' to change the scene point of view<br>",e.style.position="absolute",e.style.cssFloat="right",e.style.top="10px",e.style.right="10px",document.body.appendChild(e);const i=document.getElementById("mapCanvas");new t({decoderUrl:"./decoder.bundle.js",canvas:i,theme:"./resources/berlin_tilezen_base.json"}).start()}()}(t.B||(t.B={}))},4428:e=>{e.exports=THREE}},t={};function i(a){if(t[a])return t[a].exports;var n=t[a]={exports:{}};return e[a].call(n.exports,n,n.exports,i),n.exports}i.m=e,i.x=e=>{},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var a in t)i.o(t,a)&&!i.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=262,(()=>{var e={262:0,738:0},t=[[886,592]],a=e=>{},n=(n,s)=>{for(var o,r,[p,d,h,c]=s,l=0,w=[];l<p.length;l++)r=p[l],i.o(e,r)&&e[r]&&w.push(e[r][0]),e[r]=0;for(o in d)i.o(d,o)&&(i.m[o]=d[o]);for(h&&h(i),n&&n(s);w.length;)w.shift()();return c&&t.push.apply(t,c),a()},s=self.webpackChunk_here_harp_examples=self.webpackChunk_here_harp_examples||[];function o(){for(var a,n=0;n<t.length;n++){for(var s=t[n],o=!0,r=1;r<s.length;r++){var p=s[r];0!==e[p]&&(o=!1)}o&&(t.splice(n--,1),a=i(i.s=s[0]))}return 0===t.length&&(i.x(),i.x=e=>{}),a}s.forEach(n.bind(null,0)),s.push=n.bind(null,s.push.bind(s));var r=i.x;i.x=()=>(i.x=r||(e=>{}),(a=o)())})(),i.x()})();