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.31 to 0.1.32

2

map/interactions.js

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

function a(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function b(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function c(a,b){this.options=f.deepMerge(c.options,b),this.containner=f.getContainer(a),this.detect()}var d=require('three'),e=Math.PI,f=require('./../core/utils'),g=require('bcore/event'),h=f.getPt,i=f.requestAnimationFrame,j=f.cancelAnimationFrame;c.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}}},c=g.extend(c,{linkTo:function(a){this.camera=a,this.initialize(this.options)},initPlane:function(){this.plane=new d.Plane(new d.Vector3(0,1,0),0)},updateOptions:function(a){a&&(this.options=f.deepMerge(this.options,a))},initialize:function(a){this.initPlane(),this.initVariables(),this.initEvents(),this.loop()},initVariables:function(){var b=this.options;this.mouse={x:0,y:0},this.mouseOnDown=a(this.mouse),this.rotationTargetOnDown=a(b.rotation.target),this.lookAtTargetOnDown=a(b.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,f=g.rotation,c=f.value,i=f.target;f.autoRotateSpeed&&!this.isMouseDown&&(i.x+=f.autoRotateSpeed),Math.abs(i.x-c.x)+Math.abs(i.y-c.y)>f.limit&&(b(c,i,f.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&&(b(k,l,l.speed),this.emit('move',this));var j=g.lookAt,d=j.value,h=j.target;Math.abs(h.x-d.x)+Math.abs(h.y-d.y)+Math.abs(h.z-d.z)>j.limit&&b(d,h,j.speed);var o=a.value*Math.sin(c.x)*Math.cos(c.y)+d.x,p=a.value*Math.sin(c.y)+d.y,q=a.value*Math.cos(c.x)*Math.cos(c.y)+d.z,e=this.camera;e.near/a.value>1e-4&&(e.far=Math.max(a.value*1e4,1),e.near=a.value/1e3,e.updateProjectionMatrix()),e.position.set(o,p,q),e.lookAt(d)},resetCamera:function(){},mouseDown:function(c){this.isMouseDown=!0,this.options.lookAt.target=a(this.options.lookAt.value),this.options.lookAt.speed=this.options.lookAt.speedMouseDown;var b=h(c);this.mouseOnDown.x=b[0],this.mouseOnDown.y=b[1];var d=b[2];this.rotationTargetOnDown=a(this.options.rotation.target),this.lookAtTargetOnDown=a(this.options.lookAt.target),this.cameraClone=this.camera.clone(),this.downPoint=this.unproject(this.mouseOnDown.x,this.mouseOnDown.y);var e=this.options.interactive;c.preventDefault()}}),c.prototype.mouseMove=function(r){if(!this.isMouseDown)return;r.preventDefault();var c=this.options,w=this.camera,l=h(r),b=this.mouse,v=this.mouseOnDown;b.x=l[0],b.y=l[1];var u=c.distance.value/1e3,a=c.rotation.target,j=this.rotationTargetOnDown,t=c.rotation.value,k=this.options.interactive,g=k.mouseX,i=k.mouseY,m=c.lookAt.target,n=this.lookAtTargetOnDown,s=this.mouse.x-this.mouseOnDown.x,q=this.mouse.y-this.mouseOnDown.y;g.type==='rotatex'&&(a.x=j.x-s*g.phi),i.type==='rotatey'&&(a.y=j.y+q*i.phi,a.y=a.y>e/2?e/2:a.y,a.y=a.y<-e/2?-e/2:a.y);var f=this.downPoint,d=this.unproject(b.x,b.y);if(!(d&&f))return;var p=d.z-f.z,o=d.x-f.x;g.type==='panx'&&(m.x=n.x-o),i.type==='pany'&&(m.z=n.z-p)},c.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,'\''))},c.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))},c.prototype.unproject=function(h,i){var e=this.containner.offsetWidth,f=this.containner.offsetHeight,g=this.cameraClone,c=new d.Vector3;c.set(h/e*2-1,-(i/f)*2+1,.5);var a=new d.Raycaster;a.setFromCamera(c.clone(),g);var j=a.ray.direction,k=a.ray.origin,b=a.ray.intersectPlane(this.plane);return b?new d.Vector3(b.x,0,b.z):void 0},c.prototype.mouseWheel=function(b){if(b.preventDefault&&b.preventDefault(),this.overRenderer){var a=1+b.wheelDeltaY*this.options.interactive.scroll.speed;a=Math.max(Math.min(a,1.5),0),this.zoom(a)}return!1},c.prototype.flyingTo=function(v,w,u,k){w=w||.75,u=u||0,k=k||0;var b,c;for(var r in v){var t=v[r],m=t.geometry;m.computeBoundingBox();var a=m.boundingBox;r===0&&(b=a.max.clone(),c=a.min.clone()),b.x<a.max.x&&(b.x=a.max.x),b.y<a.max.y&&(b.y=a.max.y),b.z<a.max.z&&(b.z=a.max.z),c.x>a.min.x&&(c.x=a.min.x),c.y>a.min.y&&(c.y=a.min.y),c.z>a.min.z&&(c.z=a.min.z)}var s=this.containner,A=s.width(),F=s.height(),f=b.x,g=b.y,p=b.z,j=c.x,i=c.y,l=c.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 d.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*e;this.lookAtTarget.x=-n+k,this.lookAtTarget.z=-o+k,this.lookAtTarget.y=0,this.rotation.x=e,this.rotation.y=e/2},c.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)},c.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},c.prototype.zoom=function(b){var a=this.options.distance;a.target=Math.max(Math.min(a.target*b,a.max),a.min)},module.exports=c
function a(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function b(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function c(a,b){this.options=f.deepMerge(c.options,b),this.containner=f.getContainer(a),this.detect()}var d=require('three'),e=Math.PI,f=require('./../core/utils'),g=require('bcore/event'),h=f.getPt,i=f.requestAnimationFrame,j=f.cancelAnimationFrame;c.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}}},c=g.extend(c,{linkTo:function(a){this.camera=a,this.initialize(this.options)},initPlane:function(){this.plane=new d.Plane(new d.Vector3(0,1,0),0)},updateOptions:function(a){a&&(this.options=f.deepMerge(this.options,a))},initialize:function(a){this.initPlane(),this.initVariables(),this.initEvents(),this.loop()},initVariables:function(){var b=this.options;this.mouse={x:0,y:0},this.mouseOnDown=a(this.mouse),this.rotationTargetOnDown=a(b.rotation.target),this.lookAtTargetOnDown=a(b.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,f=g.rotation,c=f.value,i=f.target;f.autoRotateSpeed&&!this.isMouseDown&&(i.x+=f.autoRotateSpeed),Math.abs(i.x-c.x)+Math.abs(i.y-c.y)>f.limit&&(b(c,i,f.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&&(b(k,l,l.speed),this.emit('move',this));var j=g.lookAt,d=j.value,h=j.target;Math.abs(h.x-d.x)+Math.abs(h.y-d.y)+Math.abs(h.z-d.z)>j.limit&&b(d,h,j.speed);var o=a.value*Math.sin(c.x)*Math.cos(c.y)+d.x,p=a.value*Math.sin(c.y)+d.y,q=a.value*Math.cos(c.x)*Math.cos(c.y)+d.z,e=this.camera;e.near/a.value>1e-4&&(e.far=Math.max(a.value*1e4,1),e.near=a.value/1e3,e.updateProjectionMatrix()),e.position.set(o,p,q),e.lookAt(d)},resetCamera:function(){},mouseDown:function(c){this.isMouseDown=!0,this.options.lookAt.target=a(this.options.lookAt.value),this.options.lookAt.speed=this.options.lookAt.speedMouseDown;var b=h(c);this.mouseOnDown.x=b[0],this.mouseOnDown.y=b[1];var d=b[2];this.rotationTargetOnDown=a(this.options.rotation.target),this.lookAtTargetOnDown=a(this.options.lookAt.target),this.cameraClone=this.camera.clone(),this.downPoint=this.unproject(this.mouseOnDown.x,this.mouseOnDown.y);var e=this.options.interactive;c.preventDefault()}}),c.prototype.mouseMove=function(r){if(!this.isMouseDown)return;r.preventDefault();var c=this.options,w=this.camera,l=h(r),b=this.mouse,v=this.mouseOnDown;b.x=l[0],b.y=l[1];var u=c.distance.value/1e3,a=c.rotation.target,j=this.rotationTargetOnDown,t=c.rotation.value,k=this.options.interactive,g=k.mouseX,i=k.mouseY,m=c.lookAt.target,n=this.lookAtTargetOnDown,s=this.mouse.x-this.mouseOnDown.x,q=this.mouse.y-this.mouseOnDown.y;g.type==='rotatex'&&(a.x=j.x-s*g.phi),i.type==='rotatey'&&(a.y=j.y+q*i.phi,a.y=a.y>e/2?e/2:a.y,a.y=a.y<-e/2?-e/2:a.y);var f=this.downPoint,d=this.unproject(b.x,b.y);if(!(d&&f))return;var p=d.z-f.z,o=d.x-f.x;g.type==='panx'&&(m.x=n.x-o),i.type==='pany'&&(m.z=n.z-p)},c.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,'\''))},c.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))},c.prototype.unproject=function(h,i){var e=this.containner.offsetWidth,f=this.containner.offsetHeight,g=this.cameraClone,c=new d.Vector3;c.set(h/e*2-1,-(i/f)*2+1,.5);var a=new d.Raycaster;a.setFromCamera(c.clone(),g);var j=a.ray.direction,k=a.ray.origin,b=a.ray.intersectPlane(this.plane);return b?new d.Vector3(b.x,0,b.z):void 0},c.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},c.prototype.flyingTo=function(v,w,u,k){w=w||.75,u=u||0,k=k||0;var b,c;for(var r in v){var t=v[r],m=t.geometry;m.computeBoundingBox();var a=m.boundingBox;r===0&&(b=a.max.clone(),c=a.min.clone()),b.x<a.max.x&&(b.x=a.max.x),b.y<a.max.y&&(b.y=a.max.y),b.z<a.max.z&&(b.z=a.max.z),c.x>a.min.x&&(c.x=a.min.x),c.y>a.min.y&&(c.y=a.min.y),c.z>a.min.z&&(c.z=a.min.z)}var s=this.containner,A=s.width(),F=s.height(),f=b.x,g=b.y,p=b.z,j=c.x,i=c.y,l=c.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 d.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*e;this.lookAtTarget.x=-n+k,this.lookAtTarget.z=-o+k,this.lookAtTarget.y=0,this.rotation.x=e,this.rotation.y=e/2},c.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)},c.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},c.prototype.zoom=function(b){var a=this.options.distance;a.target=Math.max(Math.min(a.target*b,a.max),a.min)},module.exports=c

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

"description": "3d map visualization lib",
"version": "0.1.31",
"version": "0.1.32",
"scripts": {

@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test"

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