Comparing version 0.1.69 to 0.2.1
@@ -1,1 +0,1 @@ | ||
'use strict';const a=require('three');const c=require('bcore/event');const b=require('./../core/utils');const d={maxOpacity:.8,ratio:.98,color:16777215,xN:30,yN:30,width:2048,height:1024,material:{}};class e extends c{constructor(a){super(),this.options=b.deepMerge(d,a||{})}addTo(b){if(!b)return;this.three3D=b.three3D;let a=this.projection=b.projection;if(a.type==='plane'||a.type==='mecator'||a.type==='origin')return;this.initGlobe()}initGlobe(){let b=this.options;let d=this.projection;let e=(d.radius||1)*b.ratio;let f=this.globeGeometry=new a.SphereBufferGeometry(e,b.xN,b.yN);let g=this.material=this.createMaterial();let c=this.globeMesh=new a.Mesh(f,g);c.scale.set(b.ratio,b.ratio,b.ratio),this.three3D.add(c)}createMaterial(){let b=this.options;let c=new a.Color(b.color);let d=b.maxOpacity;let e=this.createTexture();return new a.MeshBasicMaterial({map:e,color:c,opacity:d,transparent:!0})}createTexture(){let c=this.createCanvas();let b=this.texture=new a.Texture(c);return b.needsUpdate=!0,b}createCanvas(){let b=this.options;let a=this.canvas=document.createElement('canvas');return a.width=b.width,a.height=b.height,a}getCanvas(){return this.canvas}update(){this.texture.needsUpdate=!0,this.material.needsUpdate=!0,this.material.map.needsUpdate=!0}updateOptions(a){this.options=b.deepMerge(this.options,a),this.updateGlobe()}updateGlobe(){let b=this.options;let c=b.ratio;let e=b.maxOpacity;let d=new a.Color(b.color);this.material&&this.material.color.setRGB(d.r,d.g,d.b),this.material&&(this.material.opacity=e),this.globeMesh&&this.globeMesh.scale.set(c,c,c)}remove(){this.three3D.remove(this.globeMesh),this.globeMesh&&this.globeMesh.dispose&&this.globeMesh.dispose(),this.globeMesh.material&&this.globeMesh.material.dispose(),this.globeMesh.geometry&&this.globeMesh.geometry.dispose(),this.material=null,this.globeMesh=null,this.globeGeometry=null,this.canvas=null,loopId&&window.cancelAnimationFrame(this.loopId)}loop(){this.update(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))}}module.exports=e | ||
'use strict';const a=require('three');const c=require('bcore/event');const b=require('./../core/utils');const d={maxOpacity:.8,ratio:.98,color:16777215,xN:30,yN:30,width:2048,height:1024,material:{}};class e extends c{constructor(a){super(),this.options=b.deepMerge(d,a||{})}addTo(b){if(!b)return;this.three3D=b.three3D;let a=this.projection=b.projection;if(a.type==='plane'||a.type==='mecator'||a.type==='origin')return;this.initGlobe()}initGlobe(){let b=this.options;let d=this.projection;let e=(d.radius||1)*b.ratio;let f=this.globeGeometry=new a.SphereBufferGeometry(e,b.xN,b.yN);let g=this.material=this.createMaterial();let c=this.globeMesh=new a.Mesh(f,g);c.scale.set(b.ratio,b.ratio,b.ratio),this.three3D.add(c)}createMaterial(){let b=this.options;let c=new a.Color(b.color);let d=b.maxOpacity;let e=this.createTexture();return new a.MeshBasicMaterial({map:e,color:c,opacity:d,transparent:!0})}createTexture(){let c=this.createCanvas();let b=this.texture=new a.Texture(c);return b.needsUpdate=!0,b}createCanvas(){let b=this.options;let a=this.canvas=document.createElement('canvas');return a.width=b.width,a.height=b.height,a}getCanvas(){return this.canvas}update(){this.texture.needsUpdate=!0,this.material.needsUpdate=!0,this.material.map.needsUpdate=!0}updateOptions(a){this.options=b.deepMerge(this.options,a),this.updateGlobe()}updateGlobe(){let b=this.options;let c=b.ratio;let e=b.maxOpacity;let d=new a.Color(b.color);this.material&&this.material.color.setRGB(d.r,d.g,d.b),this.material&&(this.material.opacity=e),this.globeMesh&&this.globeMesh.scale.set(c,c,c)}remove(){this.three3D.remove(this.globeMesh),this.globeMesh&&this.globeMesh.dispose&&this.globeMesh.dispose(),this.globeMesh.material&&this.globeMesh.material.dispose(),this.globeMesh.geometry&&this.globeMesh.geometry.dispose(),this.material=null,this.globeMesh=null,this.globeGeometry=null,this.canvas=null,this.loopId&&window.cancelAnimationFrame(this.loopId)}loop(){this.update(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))}}module.exports=e |
@@ -5,3 +5,3 @@ { | ||
"description": "3d map visualization lib", | ||
"version": "0.1.69", | ||
"version": "0.2.1", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
271754