Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dmap

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmap - npm Package Compare versions

Comparing version 0.1.47 to 0.1.48

layer/addons/marker.js

2

map/interactions.js

@@ -1,1 +0,1 @@

function e(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function f(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function a(b,c){this.options=d.deepMerge(a.options,c),this.containner=d.getContainer(b),this.detect()}var c=require('three'),b=Math.PI,d=require('./../core/utils'),h=require('bcore/event'),g=d.getPt,i=d.requestAnimationFrame,j=d.cancelAnimationFrame;a.options={isDetect:!0,interactive:{mouseX:{type:'rotatex',phi:.005},mouseY:{type:'rotatey',phi:.005},scroll:{type:'distance',phi:.005,speed:.01}},distance:{value:100,target:1e3,speed:.003,max:2e8,min:1,limit:.01},center:{limit:.01,speed:2,value:{x:0,y:0,z:0},target:{x:0,y:0,z:0}},rotation:{limit:1e-4,speed:.1,value:{x:0,y:0},target:{x:9.801592653589791,y:.31579632679489666},autoRotateSpeed:0},lookAt:{limit:.01,speed:.6,speedMouseUp:.1,speedMouseDown:.6,value:{x:-500,y:400,z:0},target:{x:0,y:0,z:0}}},a=h.extend(a,{linkTo:function(a){this.camera=a,this.initialize(this.options)},initPlane:function(){this.plane=new c.Plane(new c.Vector3(0,1,0),0)},updateOptions:function(a){a&&(this.options=d.deepMerge(this.options,a))},initialize:function(a){this.initPlane(),this.initVariables(),this.initEvents(),this.loop()},initVariables:function(){var a=this.options;this.mouse={x:0,y:0},this.mouseOnDown=e(this.mouse),this.rotationTargetOnDown=e(a.rotation.target),this.lookAtTargetOnDown=e(a.lookAt.target),this.overRenderer=!1,this.changeBol=this.changingBol=this.changeBolOld=!1},initEvents:function(){var b=this,a=this.containner;a.addEventListener('mousewheel',this.mouseWheel.bind(this)),a.addEventListener('mousedown',this.mouseDown.bind(this)),a.addEventListener('touchstart',this.mouseDown.bind(this)),a.addEventListener('mousemove',this.mouseMove.bind(this)),a.addEventListener('touchmove',this.mouseMove.bind(this)),a.addEventListener('touchleave',this.mouseUp.bind(this)),a.addEventListener('touchup',this.mouseUp.bind(this)),a.addEventListener('mouseup',this.mouseUp.bind(this)),a.addEventListener('mouseover',function(){b.overRenderer=!0}),a.addEventListener('mouseout',function(){b.overRenderer=!1}),a.addEventListener('touchup',function(){b.overRenderer=!1})},loop:function(){this.update(),i(this.loop.bind(this))},update:function(){var g=this.options,s=this.containner,n=g.interactive,r=n.scroll,e=g.rotation,b=e.value,i=e.target;e.autoRotateSpeed&&!this.isMouseDown&&(i.x+=e.autoRotateSpeed),Math.abs(i.x-b.x)+Math.abs(i.y-b.y)>e.limit&&(f(b,i,e.speed),this.emit('rotate',this));var a=g.distance;Math.abs(a.target-a.value)>a.limit&&(a.value+=(a.target-a.value)*a.speed,this.emit('zoom',this));var m=g.center,k=m.value,l=m.target;Math.abs(l.x-k.x)+Math.abs(l.y-k.y)>k.limit&&(f(k,l,l.speed),this.emit('move',this));var j=g.lookAt,c=j.value,h=j.target;Math.abs(h.x-c.x)+Math.abs(h.y-c.y)+Math.abs(h.z-c.z)>j.limit&&f(c,h,j.speed);var o=a.value*Math.sin(b.x)*Math.cos(b.y)+c.x,p=a.value*Math.sin(b.y)+c.y,q=a.value*Math.cos(b.x)*Math.cos(b.y)+c.z,d=this.camera;d.near/a.value>1e-4&&(d.far=Math.max(a.value*1e4,1),d.near=a.value/1e3,d.updateProjectionMatrix()),d.position.set(o,p,q),d.lookAt(c)},resetCamera:function(){},mouseDown:function(b){this.isMouseDown=!0,this.options.lookAt.target=e(this.options.lookAt.value),this.options.lookAt.speed=this.options.lookAt.speedMouseDown;var a=g(b);this.mouseOnDown.x=a[0],this.mouseOnDown.y=a[1];var c=a[2];this.rotationTargetOnDown=e(this.options.rotation.target),this.lookAtTargetOnDown=e(this.options.lookAt.target),this.cameraClone=this.camera.clone(),this.downPoint=this.unproject(this.mouseOnDown.x,this.mouseOnDown.y);var d=this.options.interactive;b.preventDefault()}}),a.prototype.mouseMove=function(r){if(!this.isMouseDown)return;r.preventDefault();var d=this.options,w=this.camera,l=g(r),c=this.mouse,v=this.mouseOnDown;c.x=l[0],c.y=l[1];var u=d.distance.value/1e3,a=d.rotation.target,j=this.rotationTargetOnDown,t=d.rotation.value,k=this.options.interactive,h=k.mouseX,i=k.mouseY,m=d.lookAt.target,n=this.lookAtTargetOnDown,s=this.mouse.x-this.mouseOnDown.x,q=this.mouse.y-this.mouseOnDown.y;h.type==='rotatex'&&(a.x=j.x-s*h.phi),i.type==='rotatey'&&(a.y=j.y+q*i.phi,a.y=a.y>b/2?b/2:a.y,a.y=a.y<-b/2?-b/2:a.y);var f=this.downPoint,e=this.unproject(c.x,c.y);if(!(e&&f))return;var p=e.z-f.z,o=e.x-f.x;h.type==='panx'&&(m.x=n.x-o),i.type==='pany'&&(m.z=n.z-p)},a.prototype.mouseUp=function(b){b.preventDefault();var a=this.options;this.isMouseDown=!1;var c=this.containner;if(this.options.lookAt.speed=this.options.lookAt.speedMouseUp,!this.options.isDetect)return;console.log('\n'+JSON.stringify({center:a.lookAt.target,distance:a.distance.target,rotation:a.rotation.target}).replace(/\"/g,'\''))},a.prototype.detect=function(){var a=this.options.interactive;window.addEventListener('keydown',function(c){var b=navigator.appname=='Netscape'?event.which:window.event.keyCode;b===32?a.mouseX.type==='panx'?(a.mouseX.type='rotatex',a.mouseY.type='rotatey'):(a.mouseX.type='panx',a.mouseY.type='pany'):b===90?this.mouseWheel({wheelDeltaY:1}):b===67?this.mouseWheel({wheelDeltaY:-1}):b===38||b===40}.bind(this))},a.prototype.unproject=function(h,i){var e=this.containner.offsetWidth,f=this.containner.offsetHeight,g=this.cameraClone,d=new c.Vector3;d.set(h/e*2-1,-(i/f)*2+1,.5);var a=new c.Raycaster;a.setFromCamera(d.clone(),g);var j=a.ray.direction,k=a.ray.origin,b=a.ray.intersectPlane(this.plane);return b?new c.Vector3(b.x,0,b.z):void 0},a.prototype.mouseWheel=function(a){a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation();var b=0;if(a.wheelDelta!==undefined?b=a.wheelDelta:a.detail!==undefined&&(b=-a.detail),this.overRenderer){var c=1+(b>0?5:-5)*this.options.interactive.scroll.speed;c=Math.max(Math.min(c,1.5),0),this.zoom(c)}return!1},a.prototype.flyingTo=function(v,w,u,k){w=w||.75,u=u||0,k=k||0;var d,e;for(var r in v){var t=v[r],m=t.geometry;m.computeBoundingBox();var a=m.boundingBox;r===0&&(d=a.max.clone(),e=a.min.clone()),d.x<a.max.x&&(d.x=a.max.x),d.y<a.max.y&&(d.y=a.max.y),d.z<a.max.z&&(d.z=a.max.z),e.x>a.min.x&&(e.x=a.min.x),e.y>a.min.y&&(e.y=a.min.y),e.z>a.min.z&&(e.z=a.min.z)}var s=this.containner,A=s.width(),F=s.height(),f=d.x,g=d.y,p=d.z,j=e.x,i=e.y,l=e.z,q=Math.abs(f-j),h=Math.abs(g-i),o=(f+j)/2,n=(g+i)/2,x=(p+l)/2,B=f-j,C=g-i,D=p-l,E=new c.Vector3(n,x,o);h&&q/h>self.w/self.h&&(q=h*self.w/self.h);var y=this.getCamera(),z=y.fov/360*b;this.lookAtTarget.x=-n+k,this.lookAtTarget.z=-o+k,this.lookAtTarget.y=0,this.rotation.x=b,this.rotation.y=b/2},a.prototype.flying=function(a){var b=this.options;b.distance.target=a.distance,b.lookAt.target=a.lookAt,b.rotation.target=a.rotation,a.autoRotateSpeed&&(b.rotation.autoRotateSpeed=a.autoRotateSpeed)},a.prototype.flyingDirect=function(b){var a=this.options;a.distance.target=b.distance,a.lookAt.target=b.lookAt,a.rotation.target=b.rotation,a.distance.value=b.distance,a.lookAt.value=b.lookAt,a.rotation.value=b.rotation},a.prototype.zoom=function(b){var a=this.options.distance;a.target=Math.max(Math.min(a.target*b,a.max),a.min)},module.exports=a
function e(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function f(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function a(b,c){this.options=d.deepMerge(a.options,c),this.containner=d.getContainer(b),this.detect()}var c=require('three'),b=Math.PI,d=require('./../core/utils'),h=require('bcore/event'),g=d.getPt,i=d.requestAnimationFrame,j=d.cancelAnimationFrame;a.options={isDetect:!0,interactive:{mouseX:{type:'rotatex',phi:.005},mouseY:{type:'rotatey',phi:.005},scroll:{type:'distance',phi:.005,speed:.01}},distance:{value:100,target:1e3,speed:.003,max:2e8,min:1,limit:.01},center:{limit:.01,speed:2,value:{x:0,y:0,z:0},target:{x:0,y:0,z:0}},rotation:{limit:1e-4,speed:.1,value:{x:0,y:0},target:{x:9.801592653589791,y:.31579632679489666},autoRotateSpeed:0},lookAt:{limit:.01,speed:.6,speedMouseUp:.1,speedMouseDown:.6,value:{x:-500,y:400,z:0},target:{x:0,y:0,z:0}}},a=h.extend(a,{linkTo:function(a){this.camera=a,this.initialize(this.options)},initPlane:function(){this.plane=new c.Plane(new c.Vector3(0,1,0),0)},updateOptions:function(a){a&&(this.options=d.deepMerge(this.options,a))},initialize:function(a){this.initPlane(),this.initVariables(),this.initEvents(),this.loop()},initVariables:function(){var a=this.options;this.mouse={x:0,y:0},this.mouseOnDown=e(this.mouse),this.rotationTargetOnDown=e(a.rotation.target),this.lookAtTargetOnDown=e(a.lookAt.target),this.overRenderer=!1,this.changeBol=this.changingBol=this.changeBolOld=!1},initEvents:function(){var b=this,a=this.containner;a.addEventListener('mousewheel',this.mouseWheel.bind(this)),a.addEventListener('mousedown',this.mouseDown.bind(this)),a.addEventListener('touchstart',this.mouseDown.bind(this)),a.addEventListener('mousemove',this.mouseMove.bind(this)),a.addEventListener('touchmove',this.mouseMove.bind(this)),a.addEventListener('touchleave',this.mouseUp.bind(this)),a.addEventListener('touchup',this.mouseUp.bind(this)),a.addEventListener('mouseup',this.mouseUp.bind(this)),a.addEventListener('mouseover',function(){b.overRenderer=!0}),a.addEventListener('mouseout',function(){b.overRenderer=!1}),a.addEventListener('touchup',function(){b.overRenderer=!1})},loop:function(){this.update(),i(this.loop.bind(this))},update:function(){var g=this.options,s=this.containner,n=g.interactive,r=n.scroll,e=g.rotation,b=e.value,i=e.target;e.autoRotateSpeed&&!this.isMouseDown&&(i.x+=e.autoRotateSpeed),Math.abs(i.x-b.x)+Math.abs(i.y-b.y)>e.limit&&(f(b,i,e.speed),this.emit('rotate',this));var a=g.distance;Math.abs(a.target-a.value)>a.limit&&(a.value+=(a.target-a.value)*a.speed,this.emit('zoom',this));var m=g.center,k=m.value,l=m.target;Math.abs(l.x-k.x)+Math.abs(l.y-k.y)>k.limit&&(f(k,l,l.speed),this.emit('move',this));var j=g.lookAt,c=j.value,h=j.target;Math.abs(h.x-c.x)+Math.abs(h.y-c.y)+Math.abs(h.z-c.z)>j.limit&&f(c,h,j.speed);var o=a.value*Math.sin(b.x)*Math.cos(b.y)+c.x,p=a.value*Math.sin(b.y)+c.y,q=a.value*Math.cos(b.x)*Math.cos(b.y)+c.z,d=this.camera;d.near/a.value>1e-4&&(d.far=Math.max(a.value*1e4,1),d.near=a.value/1e3,d.updateProjectionMatrix()),d.position.set(o,p,q),d.lookAt(c)},resetCamera:function(){},mouseDown:function(b){this.isMouseDown=!0,this.options.lookAt.target=e(this.options.lookAt.value),this.options.lookAt.speed=this.options.lookAt.speedMouseDown;var a=g(b);this.mouseOnDown.x=a[0],this.mouseOnDown.y=a[1];var c=a[2];this.rotationTargetOnDown=e(this.options.rotation.target),this.lookAtTargetOnDown=e(this.options.lookAt.target),this.cameraClone=this.camera.clone(),this.downPoint=this.unproject(this.mouseOnDown.x,this.mouseOnDown.y);var d=this.options.interactive;b.preventDefault()}}),a.prototype.mouseMove=function(r){if(!this.isMouseDown)return;r.preventDefault();var d=this.options,w=this.camera,l=g(r),c=this.mouse,v=this.mouseOnDown;c.x=l[0],c.y=l[1];var u=d.distance.value/1e3,a=d.rotation.target,j=this.rotationTargetOnDown,t=d.rotation.value,k=this.options.interactive,h=k.mouseX,i=k.mouseY,m=d.lookAt.target,n=this.lookAtTargetOnDown,s=this.mouse.x-this.mouseOnDown.x,q=this.mouse.y-this.mouseOnDown.y;h.type==='rotatex'&&(a.x=j.x-s*h.phi),i.type==='rotatey'&&(a.y=j.y+q*i.phi,a.y=a.y>b/2?b/2:a.y,a.y=a.y<-b/2?-b/2:a.y);var f=this.downPoint,e=this.unproject(c.x,c.y);if(!(e&&f))return;var p=e.z-f.z,o=e.x-f.x;h.type==='panx'&&(m.x=n.x-o),i.type==='pany'&&(m.z=n.z-p)},a.prototype.mouseUp=function(a){a.preventDefault();var b=this.options;this.isMouseDown=!1;var c=this.containner;return this.options.lookAt.speed=this.options.lookAt.speedMouseUp,void this.options.isDetect},a.prototype.detect=function(){var a=this.options.interactive;window.addEventListener('keydown',function(c){var b=navigator.appname=='Netscape'?event.which:window.event.keyCode;b===32?a.mouseX.type==='panx'?(a.mouseX.type='rotatex',a.mouseY.type='rotatey'):(a.mouseX.type='panx',a.mouseY.type='pany'):b===90?this.mouseWheel({wheelDeltaY:1}):b===67?this.mouseWheel({wheelDeltaY:-1}):b===38||b===40}.bind(this))},a.prototype.unproject=function(h,i){var e=this.containner.offsetWidth,f=this.containner.offsetHeight,g=this.cameraClone,d=new c.Vector3;d.set(h/e*2-1,-(i/f)*2+1,.5);var a=new c.Raycaster;a.setFromCamera(d.clone(),g);var j=a.ray.direction,k=a.ray.origin,b=a.ray.intersectPlane(this.plane);return b?new c.Vector3(b.x,0,b.z):void 0},a.prototype.mouseWheel=function(a){a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation();var b=0;if(a.wheelDelta!==undefined?b=a.wheelDelta:a.detail!==undefined&&(b=-a.detail),this.overRenderer){var c=1+(b>0?5:-5)*this.options.interactive.scroll.speed;c=Math.max(Math.min(c,1.5),0),this.zoom(c)}return!1},a.prototype.flyingTo=function(v,w,u,k){w=w||.75,u=u||0,k=k||0;var d,e;for(var r in v){var t=v[r],m=t.geometry;m.computeBoundingBox();var a=m.boundingBox;r===0&&(d=a.max.clone(),e=a.min.clone()),d.x<a.max.x&&(d.x=a.max.x),d.y<a.max.y&&(d.y=a.max.y),d.z<a.max.z&&(d.z=a.max.z),e.x>a.min.x&&(e.x=a.min.x),e.y>a.min.y&&(e.y=a.min.y),e.z>a.min.z&&(e.z=a.min.z)}var s=this.containner,A=s.width(),F=s.height(),f=d.x,g=d.y,p=d.z,j=e.x,i=e.y,l=e.z,q=Math.abs(f-j),h=Math.abs(g-i),o=(f+j)/2,n=(g+i)/2,x=(p+l)/2,B=f-j,C=g-i,D=p-l,E=new c.Vector3(n,x,o);h&&q/h>self.w/self.h&&(q=h*self.w/self.h);var y=this.getCamera(),z=y.fov/360*b;this.lookAtTarget.x=-n+k,this.lookAtTarget.z=-o+k,this.lookAtTarget.y=0,this.rotation.x=b,this.rotation.y=b/2},a.prototype.flying=function(a){var b=this.options;b.distance.target=a.distance,b.lookAt.target=a.lookAt,b.rotation.target=a.rotation,a.autoRotateSpeed&&(b.rotation.autoRotateSpeed=a.autoRotateSpeed)},a.prototype.flyingDirect=function(b){var a=this.options;a.distance.target=b.distance,a.lookAt.target=b.lookAt,a.rotation.target=b.rotation,a.distance.value=b.distance,a.lookAt.value=b.lookAt,a.rotation.value=b.rotation},a.prototype.zoom=function(b){var a=this.options.distance;a.target=Math.max(Math.min(a.target*b,a.max),a.min)},module.exports=a

@@ -5,3 +5,3 @@ {

"description": "3d map visualization lib",
"version": "0.1.47",
"version": "0.1.48",
"scripts": {

@@ -20,11 +20,8 @@ "test": "mocha -r jscoverage test"

"aliyun-map-utils": "0.0.29",
"bcore": "0.0.20",
"bcore": "0.0.21",
"dat-gui": "0.5.0",
"dom-to-image": "2.5.1",
"leaflet": "1.0.2",
"lodash": "4.17.2",
"ngeohash": "0.6.0",
"normalize.css": "4.2.0",
"three": "0.73.0",
"tween.js": "16.3.5"
"three": "0.73.0"
},

@@ -39,3 +36,5 @@ "devDependencies": {

"expect.js": "*",
"supertest": "*"
"supertest": "*",
"tween.js": "16.3.5",
"ngeohash": "0.6.0"
},

@@ -42,0 +41,0 @@ "cube": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc