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.49 to 0.1.50

2

layer/globe.js

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

'use strict';function b(a){a=this.options=c.deepMerge(b.options,a),this.initialize(a)}var a=require('three'),d=require('bcore/event'),c=require('./../core/utils');b.options={globe:{intensity:2,maxOpacity:.8,ratio:.98,xN:40,yN:40,imgbase:'http://datavmap-public.oss-cn-hangzhou.aliyuncs.com/mapping/',material:{map:'1/earth.topo.bathy.200407.3x4096x2048.dark.jpg',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',specular:'#0a121b',color:'#1a234d',emissive:'#203864',transparent:!0,opacity:1,normalScale:{x:1.5,y:1.5},bumpScale:1,shininess:1.5,combine:a.AddOperation,wireframeLinecap:'round',shading:a.SmoothShading}},intensity:4,maxOpacity:1},b=d.extend(b,{initialize:function(a){},addTo:function(b){if(!b)return;this.three3D=b.three3D;var a=this.projection=b.projection;if(a.type==='plane'||a.type==='mecator'||a.type==='origin')return;this.initGeo()},initGeo:function(m){var b=this.options.globe,e=this.three3D,l=this._map,i=this.projection,d=(i.radius||1)*b.ratio,h=this.globe=new a.SphereBufferGeometry(d,b.xN,b.yN);this.genMaterialGlobe(function(f){var d=this.materialGlobe=f,c=this.globeMesh=new a.Mesh(h,d);c.scale.set(b.ratio,b.ratio,b.ratio),e.add(c)}.bind(this));var g=this.options.atmosphere;if(!g)return;var j=this.atmosphere=new a.SphereBufferGeometry(d,b.xN,b.yN),k=this.materialAtmosphere=this.genMaterialAtmosphere(),f=this.meshAtomesphere=new a.Mesh(j,k),c=g.ratio;f.scale.set(c,c,c),e.add(f)}}),b.prototype.genMaterialGlobe=function(h){function f(){if(d>=4){var c=new a.MeshPhongMaterial(b);h(c)}}var g=this.options,b=g.globe.material;if(typeof b==='function'){var i=b();return h(i)}b=JSON.parse(JSON.stringify(b));var c=new a.TextureLoader;c.setCrossOrigin('*'),c.crossOrigin='*';var d=0,e=g.globe.imgbase;c.load(e+b.map,function(a){b.map=a,d++,f()}),c.load(e+b.specularMap,function(a){b.specularMap=a,d++,f()}),c.load(e+b.normalMap,function(a){b.normalMap=a,d++,f()}),c.load(e+b.bumpMap,function(a){b.bumpMap=a,d++,f()})},b.prototype.show=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!0),this.globeMesh&&(this.globeMesh.visible=!0)},b.prototype.hide=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!1),this.globeMesh&&(this.globeMesh.visible=!1)},b.prototype.genMaterialAtmosphere=function(){var b=this.options.atmosphere,c=b.maxOpacity,d=b.intensity,e='varying vec3 vNormal;void main() {vNormal = normalize( normalMatrix * normal );gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}',f=this.genFragAtmosphere();return new a.ShaderMaterial({uniforms:{intensity:{type:'f',value:d},maxOpacity:{type:'f',value:c}},vertexShader:e,fragmentShader:f,side:a.BackSide,transparent:!1})},b.prototype.genFragAtmosphere=function(){var b=this.options.atmosphere.color;b=new a.Color(b);var c=this.options.atmosphere.intensity;return'varying vec3 vNormal;uniform float intensity;uniform float maxOpacity;void main() {float k = pow( 0.51 - dot( vNormal, vec3(0, 0, 1.0 )), '+c.toFixed(1)+' );'+'gl_FragColor = vec4( '+b.r+', '+b.g+', '+b.b+', maxOpacity ) * k;'+'}'},b.prototype.updateShader=function(){var d=this.options,c=d.globe.material,b=this.materialGlobe;if(!b)return;b.normalScale=c.normalScale,b.color=new a.Color(c.color),b.specular=new a.Color(c.specular),b.emissive=new a.Color(c.emissive),b.needsUpdate=!0},b.prototype.updateOptions=function(b){b=this.options=c.deepMerge(this.options,b);var a=b.globe.ratio;this.globeMesh&&this.globeMesh.scale.set(a,a,a),this.updateShader(),this.updateAtmosphere()},b.prototype.updateAtmosphere=function(){var b=this.options.atmosphere;if(!b)return;var c=this.meshAtomesphere,a=b.ratio;c.scale.set(a,a,a),this.materialAtmosphere.fragmentShader=this.genFragAtmosphere(),this.materialAtmosphere.needsUpdate=!0},b.prototype.remove=function(){this.three3D.remove(this.globeMesh),this.three3D.remove(this.meshAtomesphere),this.globeMesh&&this.globeMesh.dispose&&this.globeMesh.dispose(),this.materialGlobe&&this.materialGlobe.dispose(),this.globe&&this.globe.dispose(),this.meshAtomesphere&&this.meshAtomesphere.dispose&&this.meshAtomesphere.dispose(),this.atmosphere&&this.atmosphere.dispose(),this.materialAtmosphere&&this.materialAtmosphere.dispose(),this.globeMesh=null,this.materialGlobe=null,this.globe=null,this.meshAtomesphere=null,this.atmosphere=null,this.materialAtmosphere=null},module.exports=b
'use strict';function b(a){a=this.options=c.deepMerge(b.options,a),this.initialize(a)}var a=require('three'),e=require('bcore/event'),c=require('./../core/utils'),d={卫星:{map:'1/earth.topo.bathy.200407.3x4096x2048.jpg',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',transparent:!1,cache:{}},地形:{map:'1/earth.topo.bathy.200407.3x4096x2048.dark.jpg',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',transparent:!1,cache:{}},行政区:{map:'v2/world04.png',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',transparent:!0,cache:{}},粒子:{map:'v2/particle02.png',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',transparent:!0,cache:{}}};b.options={globe:{textureType:'地形',intensity:2,maxOpacity:.8,ratio:.98,xN:40,yN:40,imgbase:'http://datavmap-public.oss-cn-hangzhou.aliyuncs.com/mapping/',material:{map:'1/earth.topo.bathy.200407.3x4096x2048.dark.jpg',specularMap:'1/earth_specularmap_flat_8192x4096.jpg',normalMap:'1/earth_normalmap_flat_8192x4096.jpg',bumpMap:'1/earth_bumpmap_flat_8192x4096aa.jpg',specular:'#0a121b',color:'#1a234d',emissive:'#203864',opacity:1,normalScale:{x:1.5,y:1.5},bumpScale:1,shininess:1.5,combine:a.AddOperation,wireframeLinecap:'round',depthTest:!0,shading:a.SmoothShading}},atmosphere:{color:'#0ff',ratio:1.05,maxOpacity:1,intensity:2,isAtmosphere:!1}},b=e.extend(b,{initialize:function(a){},addTo:function(b){if(!b)return;this.three3D=b.three3D;var a=this.projection=b.projection;if(a.type==='plane'||a.type==='mecator'||a.type==='origin')return;this.initGeo()},initGeo:function(m){var b=this.options.globe,d=this.three3D,l=this._map,i=this.projection,e=(i.radius||1)*b.ratio,h=this.globe=new a.SphereBufferGeometry(e,b.xN,b.yN);this.genMaterialGlobe(function(f){var g=this.materialGlobe=f;f.side=a.BackSide;var e=this.globeMesh=new a.Mesh(h,g);e.scale.set(b.ratio,b.ratio,b.ratio),e.castShadow=!0,e.receiveShadow=!0,d.add(e);var i=this.backMaterial=f.clone(),j=this.bcakGlobe=h.clone(),c=this.backGlobeMesh=new a.Mesh(j,i);c.scale.set(b.ratio,b.ratio,b.ratio),c.castShadow=!0,c.receiveShadow=!0,c.material.side=a.FrontSide,d.add(c)}.bind(this));var g=this.options.atmosphere;if(!g)return;var j=this.atmosphere=new a.SphereBufferGeometry(e,b.xN,b.yN),k=this.materialAtmosphere=this.genMaterialAtmosphere(),f=this.meshAtomesphere=new a.Mesh(j,k),c=g.ratio;f.scale.set(c,c,c),d.add(f),this.checkAtomesphere()}}),b.prototype.genMaterialGlobe=function(m){var h=this.options,n=h.globe.textureType||'地形',b=d[n],c=h.globe.material;if(c.transparent=b.transparent,typeof c==='function'){var f=c();return m(f)}c=JSON.parse(JSON.stringify(c));var e=new a.TextureLoader;e.setCrossOrigin('*'),e.crossOrigin='*';var g=h.globe.imgbase;if(!b.cache.map){var l=e.load(g+b.map,function(){l.needsUpdate=!0});b.cache.map=l}if(!b.cache.specularMap){var i=e.load(g+b.specularMap,function(){i.needsUpdate=!0});b.cache.specularMap=i}if(!b.cache.normalMap){var k=e.load(g+b.normalMap,function(){k.needsUpdate=!0});b.cache.normalMap=k}if(!b.cache.bumpMap){var j=e.load(g+b.bumpMap,function(){j.needsUpdate=!0});b.cache.bumpMap=j}c.map=b.cache.map,c.specularMap=b.cache.specularMap,c.normalMap=b.cache.normalMap,c.bumpMap=b.cache.bumpMap;var f=new a.MeshPhongMaterial(c);m(f)},b.prototype.checkAtomesphere=function(){var a=this.options.atmosphere,b=a.isAtmosphere;b?this.atomesphereShow():this.atomesphereHide()},b.prototype.atomesphereShow=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!0)},b.prototype.atomesphereHide=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!1)},b.prototype.show=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!0),this.globeMesh&&(this.globeMesh.visible=!0)},b.prototype.hide=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!1),this.globeMesh&&(this.globeMesh.visible=!1)},b.prototype.genMaterialAtmosphere=function(){var b=this.options.atmosphere,c=b.maxOpacity,d=b.intensity,e='varying vec3 vNormal;void main() {vNormal = normalize( normalMatrix * normal );gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}',f=this.genFragAtmosphere();return new a.ShaderMaterial({uniforms:{intensity:{type:'f',value:d},maxOpacity:{type:'f',value:c}},vertexShader:e,fragmentShader:f,side:a.BackSide,transparent:!1})},b.prototype.genFragAtmosphere=function(){var b=this.options.atmosphere.color;b=new a.Color(b);var c=this.options.atmosphere.intensity;return'varying vec3 vNormal;uniform float intensity;uniform float maxOpacity;void main() {float k = pow( 0.51 - dot( vNormal, vec3(0, 0, 1.0 )), '+c.toFixed(1)+' );'+'gl_FragColor = vec4( '+b.r+', '+b.g+', '+b.b+', maxOpacity ) * k;'+'}'},b.prototype.updateShader=function(){var d=this.options,b=d.globe.material,c=this.materialGlobe;if(!c)return;c.normalScale=b.normalScale,c.color=new a.Color(b.color),c.specular=new a.Color(b.specular),c.emissive=new a.Color(b.emissive),c.transparent=b.transparent,c.needsUpdate=!0,this.backMaterial.normalScale=b.normalScale,this.backMaterial.color=new a.Color(b.color),this.backMaterial.specular=new a.Color(b.specular),this.backMaterial.emissive=new a.Color(b.emissive),this.backMaterial.transparent=b.transparent,this.backMaterial.needsUpdate=!0},b.prototype.updateOptions=function(b){b&&(b=this.options=c.deepMerge(this.options,b));var a=b.globe.ratio;this.globeMesh&&this.globeMesh.scale.set(a,a,a),this.backGlobeMesh&&this.backGlobeMesh.scale.set(a,a,a),this.updateShader(),this.checkAtomesphere(),this.updateAtmosphere(),this.updateGlobeMaterial()},b.prototype.updateGlobeMaterial=function(){var b=this.options;this.genMaterialGlobe(function(b){var e=this.materialGlobe=b,c=this.globeMesh;b.side=a.BackSide,c.material=b,c.material.needsUpdate=!0;var d=this.backMaterial=b.clone();d.side=a.FrontSide,this.backGlobeMesh.material=d,this.backGlobeMesh.material.needsUpdate=!0}.bind(this))},b.prototype.updateAtmosphere=function(){var b=this.options.atmosphere;if(!b)return;var c=this.meshAtomesphere,a=b.ratio;c.scale.set(a,a,a),this.materialAtmosphere.fragmentShader=this.genFragAtmosphere(),this.materialAtmosphere.needsUpdate=!0},b.prototype.remove=function(){this.three3D.remove(this.globeMesh),this.three3D.remove(this.backGlobeMesh),this.three3D.remove(this.meshAtomesphere),this.globeMesh&&this.globeMesh.dispose&&this.globeMesh.dispose(),this.materialGlobe&&this.materialGlobe.dispose(),this.globe&&this.globe.dispose(),this.backGlobeMesh&&this.backGlobeMesh.dispose&&this.backGlobeMesh.dispose(),this.backMaterial&&this.backMaterial.dispose(),this.bcakGlobe&&this.bcakGlobe.dispose(),this.meshAtomesphere&&this.meshAtomesphere.dispose&&this.meshAtomesphere.dispose(),this.atmosphere&&this.atmosphere.dispose(),this.materialAtmosphere&&this.materialAtmosphere.dispose(),this.globeMesh=null,this.materialGlobe=null,this.globe=null,this.backGlobeMesh=null,this.backMaterial=null,this.bcakGlobe=null,this.meshAtomesphere=null,this.atmosphere=null,this.materialAtmosphere=null,d.cache=null},module.exports=b

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

"description": "3d map visualization lib",
"version": "0.1.49",
"version": "0.1.50",
"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