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

dmap

Package Overview
Dependencies
Maintainers
5
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.2.4 to 0.2.5

2

layer/globe.js

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

'use strict';function b(a){a=this.options=d.deepMerge(b.options,a),this.initialize(a)}var a=require('three'),e=require('bcore/event'),d=require('./../core/utils'),c={卫星:{transparent:!1,cache:{}},地形:{transparent:!1,cache:{}},行政区:{transparent:!0,cache:{}},粒子:{transparent:!0,cache:{}},自定义:{transparent:!0,cache:{}},specularMap:{cache:{}},normalMap:{cache:{}},bumpMap:{cache:{}}};b.options={globe:{textureType:'地形',intensity:2,maxOpacity:.8,ratio:.98,xN:40,yN:40,mapUrl:'',specularMapUrl:'',normalMapUrl:'',bumpMapUrl:'',material:{map:null,specularMap:null,normalMap:null,bumpMap:null,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 i=this.materialGlobe=f;f.side=a.BackSide;var e=this.globeMesh=new a.Mesh(h,i);e.scale.set(b.ratio,b.ratio,b.ratio),e.castShadow=!0,e.receiveShadow=!0,d.add(e);var g=this.backMaterial=f.clone(),j=this.bcakGlobe=h.clone(),c=this.backGlobeMesh=new a.Mesh(j,g);c.scale.set(b.ratio,b.ratio,b.ratio),c.castShadow=!0,c.receiveShadow=!0,c.material.side=a.FrontSide,d.add(c),f.needsUpdate=!0,g.needsUpdate=!0}.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(o){var h=this.options,l=h.globe.textureType||'地形',e=c[l],b=h.globe.material;b.transparent=e.transparent;var f=h.globe,i=f.mapUrl,r=f.bumpMapUrl,p=f.normalMapUrl,q=f.specularMapUrl;if(typeof b==='function'){var g=b();return o(g)}b=JSON.parse(JSON.stringify(b));var k=new a.TextureLoader;if(k.setCrossOrigin('*'),k.crossOrigin='*',l==='自定义'){var d=this.getTexture(i,function(){d.needsUpdate=!0});e.cache.map=d}else if(!e.cache.map){var d=this.getTexture(i,function(){d.needsUpdate=!0});e.cache.map=d}if(!c.specularMap.cache.specularMap){var m=this.getTexture(q,function(){m.needsUpdate=!0});c.specularMap.cache.specularMap=m}if(!c.normalMap.cache.normalMap){var n=this.getTexture(p,function(){n.needsUpdate=!0});c.normalMap.cache.normalMap=n}if(!c.bumpMap.cache.bumpMap){var j=this.getTexture(r,function(){j.needsUpdate=!0});c.bumpMap.cache.bumpMap=j}b.map=e.cache.map||null,b.bumpMap=c.bumpMap.cache.bumpMap||null,b.normalMap=c.normalMap.cache.normalMap||null,b.specularMap=c.specularMap.cache.specularMap||null;var g=new a.MeshPhongMaterial(b);o(g)},b.prototype.getTexture=function(d,e){var b=new a.Texture,c=new Image;return c.src=d,c.crossOrigin='*',b.image=c,c.onload=function(){var a=d.search(/\.(jpg|jpeg)$/)>0||d.search(/^data\:image\/jpeg/)===0;b.format=a?1022:1023,b.needsUpdate=!0,e(b)},b},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 e=this.options,b=e.globe.material,c=this.materialGlobe,d=this.backMaterial;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,d.normalScale=b.normalScale,d.color=new a.Color(b.color),d.specular=new a.Color(b.specular),d.emissive=new a.Color(b.emissive),d.transparent=b.transparent,d.needsUpdate=!0},b.prototype.updateOptions=function(b){b&&(b=this.options=d.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,c.cache=null},module.exports=b
'use strict';function b(a){a=this.options=d.deepMerge(b.options,a),this.initialize(a)}var a=require('three'),e=require('bcore/event'),d=require('./../core/utils'),c={卫星:{transparent:!1,cache:{}},地形:{transparent:!1,cache:{}},行政区:{transparent:!0,cache:{}},粒子:{transparent:!0,cache:{}},自定义:{transparent:!0,cache:{}},specularMap:{cache:{}},normalMap:{cache:{}},bumpMap:{cache:{}}};b.options={globe:{textureType:'地形',intensity:2,maxOpacity:.8,ratio:.98,xN:40,yN:40,mapUrl:'',specularMapUrl:'',normalMapUrl:'',bumpMapUrl:'',material:{map:null,specularMap:null,normalMap:null,bumpMap:null,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 i=this.materialGlobe=f;f.side=a.BackSide;var e=this.globeMesh=new a.Mesh(h,i);e.scale.set(b.ratio,b.ratio,b.ratio),e.castShadow=!0,e.receiveShadow=!0,d.add(e);var g=this.backMaterial=f.clone(),j=this.bcakGlobe=h.clone(),c=this.backGlobeMesh=new a.Mesh(j,g);c.scale.set(b.ratio,b.ratio,b.ratio),c.castShadow=!0,c.receiveShadow=!0,c.material.side=a.FrontSide,d.add(c),f.needsUpdate=!0,g.needsUpdate=!0}.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(o){var i=this.options,k=i.globe.textureType||'地形',f=c[k],b=i.globe.material;b.transparent=f.transparent;var g=i.globe,j=g.mapUrl,r=g.bumpMapUrl,p=g.normalMapUrl,q=g.specularMapUrl;if(typeof b==='function'){var h=b();return o(h)}b=JSON.parse(JSON.stringify(b));var d=new a.TextureLoader;if(d.setCrossOrigin('*'),d.crossOrigin='*',k==='自定义'){var e=d.load(j,function(){e.needsUpdate=!0});f.cache.map=e}else if(!f.cache.map){var e=d.load(j,function(){e.needsUpdate=!0});f.cache.map=e}if(!c.specularMap.cache.specularMap){var m=d.load(q,function(){m.needsUpdate=!0});c.specularMap.cache.specularMap=m}if(!c.normalMap.cache.normalMap){var n=d.load(p,function(){n.needsUpdate=!0});c.normalMap.cache.normalMap=n}if(!c.bumpMap.cache.bumpMap){var l=d.load(r,function(){l.needsUpdate=!0});c.bumpMap.cache.bumpMap=l}b.map=f.cache.map||null,b.bumpMap=c.bumpMap.cache.bumpMap||null,b.normalMap=c.normalMap.cache.normalMap||null,b.specularMap=c.specularMap.cache.specularMap||null;var h=new a.MeshPhongMaterial(b);o(h)},b.prototype.getTexture=function(d,e){var b=new a.Texture,c=new Image;return c.src=d,c.crossOrigin='*',b.image=c,c.onload=function(){var c=d.search(/\.(jpg|jpeg)$/)>0||d.search(/^data\:image\/jpeg/)===0;b.format=c?a.RGBFormat:a.RGBAFormat,console.log(b.format,d),b.needsUpdate=!0,e(b)},b},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 e=this.options,b=e.globe.material,c=this.materialGlobe,d=this.backMaterial;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,d.normalScale=b.normalScale,d.color=new a.Color(b.color),d.specular=new a.Color(b.specular),d.emissive=new a.Color(b.emissive),d.transparent=b.transparent,d.needsUpdate=!0},b.prototype.updateOptions=function(b){b&&(b=this.options=d.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,c.cache=null},module.exports=b

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

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