Comparing version 0.2.1 to 0.2.2
@@ -1,1 +0,1 @@ | ||
function a(b){this.options=c.deepMerge(a.options,b)}var b=require('three'),c=require('./../core/utils'),d=c.requestAnimationFrame;a.options={ambient:{color:'#fff',intensity:.5},spot:{color:'#333',intensity:10},isSolar:!1,radius:4e8,phi:10},a.prototype.addTo=function(a){this._map=a;var b=this.three3D=a.three3D;this.projection=a.projection,this.init(this.options),this.loop()},a.prototype.init=function(d){var f=this._map;this.lightMax=2;var g=this.three3D,a=this.spot=new b.SpotLight(d.spot.color,d.spot.intensity);a.lookAt(f.options.center||f.center),a.castShadow=!0,a.shadowMapWidth=1024,a.shadowMapHeight=1024,g.add(a);var c=new b.Color(d.ambient.color),e=d.ambient.intensity||1,h=this.ambient=new b.AmbientLight(c);h.color.setRGB(c.r*e,c.g*e,c.b*e),g.add(h)},a.prototype.updateOptions=function(a){a&&(this.options=c.deepMerge(this.options,a)),this.updateSolar()},a.prototype.updateSolar=function(){var a=this.options,c=new b.Color(a.ambient.color),d=a.ambient.intensity||1;this.ambient.color.setRGB(c.r*d,c.g*d,c.b*d);var e=new b.Color(a.spot.color);this.spot.color.setRGB(e.r,e.g,e.b),this.spot.intensity=a.spot.intensity},a.prototype.genMaterial=function(c){var a={side:b.BackSide,color:16711680};return new b.MeshBasicMaterial(a)},a.prototype.updateSolarPos=function(){var a=this.options.radius||this.projection.radius*8,b=this.options.phi,c=a*Math.cos(b),d=a*Math.sin(-.044444444444444446*Math.PI),e=a*Math.sin(b);this.spot.position.set(c,d,e)},a.prototype.update=function(){var b=this.three3D.camera,a=b.position,c=a.x,d=a.y,e=a.z;this.spot.position.set(c,d,e)},a.prototype.loop=function(){this.update(),this.loopId=d(this.loop.bind(this))},a.prototype.remove=function(){this.three3D.remove(this.spot),this.three3D.remove(this.ambient),this.spot&&this.spot.dispose&&this.spot.dispose(),this.ambient&&this.ambient.dispose&&this.ambient.dispose(),this.spot=null,this.ambient=null,window.cancelAnimationFrame(this.loopId)},module.exports=a | ||
function a(b){this.options=c.deepMerge(a.options,b)}var b=require('three'),c=require('./../core/utils'),d=c.requestAnimationFrame;a.options={ambient:{color:'#fff',intensity:.5},spot:{color:'#333',intensity:10},isSolar:!1,radius:4e8,phi:10},a.prototype.addTo=function(a){this._map=a;var b=this.three3D=a.three3D;this.projection=a.projection,this.init(this.options),this.loop()},a.prototype.init=function(d){var f=this._map;this.lightMax=2;var g=this.three3D,a=this.spot=new b.SpotLight(d.spot.color,d.spot.intensity);a.lookAt(f.options.center||f.center),a.castShadow=!0,a.shadow.mapSize.width=1024,a.shadow.mapSize.height=1024,g.add(a);var c=new b.Color(d.ambient.color),e=d.ambient.intensity||1,h=this.ambient=new b.AmbientLight(c);h.color.setRGB(c.r*e,c.g*e,c.b*e),g.add(h)},a.prototype.updateOptions=function(a){a&&(this.options=c.deepMerge(this.options,a)),this.updateSolar()},a.prototype.updateSolar=function(){var a=this.options,c=new b.Color(a.ambient.color),d=a.ambient.intensity||1;this.ambient.color.setRGB(c.r*d,c.g*d,c.b*d);var e=new b.Color(a.spot.color);this.spot.color.setRGB(e.r,e.g,e.b),this.spot.intensity=a.spot.intensity},a.prototype.genMaterial=function(c){var a={side:b.BackSide,color:16711680};return new b.MeshBasicMaterial(a)},a.prototype.updateSolarPos=function(){var a=this.options.radius||this.projection.radius*8,b=this.options.phi,c=a*Math.cos(b),d=a*Math.sin(-.044444444444444446*Math.PI),e=a*Math.sin(b);this.spot.position.set(c,d,e)},a.prototype.update=function(){var b=this.three3D.camera,a=b.position,c=a.x,d=a.y,e=a.z;this.spot.position.set(c,d,e)},a.prototype.loop=function(){this.update(),this.loopId=d(this.loop.bind(this))},a.prototype.remove=function(){this.three3D.remove(this.spot),this.three3D.remove(this.ambient),this.spot&&this.spot.dispose&&this.spot.dispose(),this.ambient&&this.ambient.dispose&&this.ambient.dispose(),this.spot=null,this.ambient=null,window.cancelAnimationFrame(this.loopId)},module.exports=a |
@@ -5,3 +5,3 @@ { | ||
"description": "3d map visualization lib", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test" |
@@ -1,1 +0,1 @@ | ||
'use strict';var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.requestAnimationFrame,f=c.cancelAnimationFrame;b.ImageUtils.crossOrigin='',b.Loader.crossOrigin='';var a=function(b,d){this.options=c.deepMerge(a.options,d),this.container=c.getContainer(b),this.width=b.offsetWidth,this.height=b.offsetHeight,this.initScene(),this.initCamera(),this.initRender(),this.initEvents(),this.loop()};a.options={clearAlpha:0,alpha:1,clearColor:0,background:'transparent',pointerEvents:'auto',camera:{angle:60,far:119378137,near:1}},a=d.extend(a,{}),a.prototype.initScene=function(){this.scene=new b.Scene},a.prototype.initCamera=function(){var d=this.width,e=this.height,c=this.options.camera,a=this.camera=new b.PerspectiveCamera(c.angle,d/e,c.far,c.near);a.up.x=0,a.up.y=1,a.up.z=0,a.lookAt(new b.Vector3(0,0,0)),this.scene.add(a)},a.prototype.initRender=function(){var c=this.options,d=this.renderer=new b.WebGLRenderer({preserveDrawingBuffer:!0,antialias:!0,alpha:!0});d.setClearColor(c.clearColor,c.clearAlpha),d.setSize(this.width,this.height),d.autoClear=!1;var e=this.canvas=d.domElement,a=e.style;a.position='absolute',a.top=0,a.left=0,a.height='100%',a.width='100%',a.opacity=c.alpha,a.background=c.background,a.pointerEvents=c.pointerEvents,this.container.style.pointerEvents=c.pointerEvents,this.container.appendChild(e)},a.prototype.initTarget=function(){var a=this.target=new b.WebGLRenderTarget(this.width,this.height);a.minFilter=b.LinearFilter,a.generateMipmaps=!1,this.renderer.setRenderTarget(a)},a.prototype.update=function(){var a=this.renderer;a.clear(),a.render(this.scene,this.camera)},a.prototype.loop=function(){this.update(),e(this.loop.bind(this))},a.prototype.add=function(a){this.scene.add(a)},a.prototype.remove=function(a){this.scene.remove(a)},a.prototype.children=function(){return this.scene.children},a.prototype.setClearColor=function(a){this.renderer.setClearColor(a)},a.prototype.setCameraPosition=function(a){this.camera.position.x=a.x,this.camera.position.y=a.y,this.camera.position.z=a.z},a.prototype.setCameraView=function(a){this.camera.lookAt(a)},a.prototype.getCamera=function(){return this.camera},a.prototype.setSize=function(a,b){this.renderer.setSize(a,b)},a.prototype.getContainer=function(){return this.container},a.prototype.initEvents=function(){window.addEventListener('resize',this.onWindowResize.bind(this))},a.prototype.updateOptions=function(a){a&&(this.options=c.deepMerge(this.options,a)),this.updateCSS()},a.prototype.updateCSS=function(){this.canvas.style.pointerEvents=this.container.style.pointerEvents=this.pointerEvents=this.options.pointerEvents},a.prototype.updateCamera=function(d){d&&typeof d==='object'&&(this.options=c.deepMerge(this.options,{camera:d}));var a=this.camera,b=this.options.camera;a.far=b.far,a.near=b.near,a.angle=b.angle,a.updateProjectionMatrix(),a.updateMatrixWorld()},a.prototype.onWindowResize=function(){var a=this.camera,b=this.container,c=b.offsetWidth,d=b.offsetHeight;a.aspect=c/d,a.updateProjectionMatrix(),this.renderer.setSize(c,d)},module.exports=a | ||
'use strict';var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.requestAnimationFrame,f=c.cancelAnimationFrame;b.ImageUtils.crossOrigin='',b.Loader.crossOrigin='';var a=function(b,d){this.options=c.deepMerge(a.options,d),this.container=c.getContainer(b),this.width=b.offsetWidth,this.height=b.offsetHeight,this.initScene(),this.initCamera(),this.initRender(),this.initEvents(),this.loop()};a.options={clearAlpha:0,alpha:1,clearColor:0,background:'transparent',pointerEvents:'auto',camera:{angle:60,far:119378137,near:1}},a=d.extend(a,{}),a.prototype.initScene=function(){this.scene=new b.Scene},a.prototype.initCamera=function(){var d=this.width,e=this.height,c=this.options.camera,a=this.camera=new b.PerspectiveCamera(c.angle,d/e,c.far,c.near);a.up.x=0,a.up.y=1,a.up.z=0,a.lookAt(new b.Vector3(0,0,0)),this.scene.add(a)},a.prototype.initCanvas=function(){let a=this.options;this.canvas=document.createElement('canvas'),this.canvas.style.position='absolute',this.canvas.style.top=0,this.canvas.style.left=0,this.canvas.style.height='100%',this.canvas.style.width='100%',this.canvas.style.opacity=a.alpha,this.canvas.style.background=a.background,this.canvas.style.pointerEvents=a.pointerEvents,this.container.style.pointerEvents=a.pointerEvents,this.container.appendChild(this.canvas)},a.prototype.initRender=function(){this.initCanvas();var c=this.options,a=this.renderer=new b.WebGLRenderer({preserveDrawingBuffer:!0,antialias:!0,alpha:!0,canvas:this.canvas});a.setClearColor(c.clearColor,c.clearAlpha),a.setSize(this.width,this.height),a.autoClear=!1},a.prototype.initTarget=function(){var a=this.target=new b.WebGLRenderTarget(this.width,this.height);a.minFilter=b.LinearFilter,a.generateMipmaps=!1,this.renderer.setRenderTarget(a)},a.prototype.update=function(){var a=this.renderer;a.clear(),a.render(this.scene,this.camera)},a.prototype.loop=function(){this.update(),e(this.loop.bind(this))},a.prototype.add=function(a){this.scene.add(a)},a.prototype.remove=function(a){this.scene.remove(a)},a.prototype.children=function(){return this.scene.children},a.prototype.setClearColor=function(a){this.renderer.setClearColor(a)},a.prototype.setCameraPosition=function(a){this.camera.position.x=a.x,this.camera.position.y=a.y,this.camera.position.z=a.z},a.prototype.setCameraView=function(a){this.camera.lookAt(a)},a.prototype.getCamera=function(){return this.camera},a.prototype.setSize=function(a,b){this.renderer.setSize(a,b)},a.prototype.getContainer=function(){return this.container},a.prototype.initEvents=function(){window.addEventListener('resize',this.onWindowResize.bind(this))},a.prototype.updateOptions=function(a){a&&(this.options=c.deepMerge(this.options,a)),this.updateCSS()},a.prototype.updateCSS=function(){this.canvas.style.pointerEvents=this.container.style.pointerEvents=this.pointerEvents=this.options.pointerEvents},a.prototype.updateCamera=function(d){d&&typeof d==='object'&&(this.options=c.deepMerge(this.options,{camera:d}));var a=this.camera,b=this.options.camera;a.far=b.far,a.near=b.near,a.angle=b.angle,a.updateProjectionMatrix(),a.updateMatrixWorld()},a.prototype.onWindowResize=function(){var a=this.camera,b=this.container,c=b.offsetWidth,d=b.offsetHeight;a.aspect=c/d,a.updateProjectionMatrix(),this.renderer.setSize(c,d)},module.exports=a |
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
271999