Comparing version 0.1.56 to 0.1.57
@@ -1,1 +0,1 @@ | ||
'use strict';function p(c){c.originalEvent&&(c=c.originalEvent);var d=c.target,e=d.offsetWidth,f=d.offsetHeight,g=d.offsetLeft,h=d.offsetTop,a,b;if(c.type.indexOf('mouse')!==-1)return a=c.x||c.pageX,b=c.y||c.pageY,[a-g,b-h,'mouse'];var i=window.event.touches[0];return a=i.pageX-g,b=i.pageY-h,a=a<e?a:e,a=a>0?a:1,b=b<f?b:f,b=b>0?b:1,[a,b,'touch']}function s(g,h,b,c,d,f){return c=c||0,d=d||0,f=f||0,b=b||6378137,new a.Vector3(g/180*e*b+c,d,-b*o(n((90+h)*e/360))+f)}function v(o,p,b,h,i,g){var j=1;h=h||0,i=i||0,g=g||0,b=b||1;var k=-o*e/180,d=p*e/180,n=b*c(k)*c(d)*j+h,l=b*f(k)*c(d)*j+g,m=b*f(d)+i;return new a.Vector3(n,m,l)}function B(j,n,k,b,c,a,d){c=c||0,a=a||0,d=d||0,b=b||1;var i=j-c,g=n-a,h=k-d,f=l(g/b),e=m(h,i);return{lat:f,lng:e}}function A(c,a,d){var e=a.x-c.x,f=a.y-c.y,i=a.z-c.z,k=d.x-a.x,j=d.y-a.y,b=d.z-a.z;return.5*h(g(f*b-i*j,2)+g(e*b-i*k,2)+g(e*j-f*b,2))}function i(f,i,j,k,l){var c=f.x-j,d=f.y-k,e=f.z-l,g=h(c*c+d*d+e*e),b=g<i?i/g:1;return new a.Vector3(j+c*b,k+d*b,l+e*b)}function z(f,A){var B=A.x0,s=A.y0,z=A.z0,v=A.radius,e={},H=f.faces,n=[],c=f.vertices;for(var t=H.length-1;t>=0;t--){var j=H[t],k=j.a,g=j.b,h=j.c,o=j.normal,q=j.color,p=j.materialIndex,G=c[k],F=c[g],E=c[h],r,l,m,C=d(k,g)+'_'+b(k,g);if(!e[C]){var y=new a.Vector3().addVectors(G,F).divideScalar(2);y=i(y,v,B,s,z),r=e[C]=c.length,c.push(y)}else r=e[C];var x=d(g,h)+'_'+b(g,h);if(!e[x]){var w=new a.Vector3().addVectors(F,E).divideScalar(2);w=i(w,B,s,z,v);var l=e[x]=c.length;c.push(w)}else l=e[x];var u=d(k,h)+'_'+b(k,h);if(!e[u]){var D=new a.Vector3().addVectors(E,G).divideScalar(2);D=i(D,B,s,z,v);var m=e[u]=c.length;c.push(D)}else m=e[u];var J=new a.Face3(k,r,m,o,q,p),K=new a.Face3(r,g,l,o,q,p),L=new a.Face3(m,l,h,o,q,p),I=new a.Face3(r,l,m,o,q,p);n.push(J),n.push(K),n.push(L),n.push(I)}return f.vertices=c,f.faces=n,f.computeFaceNormals(),f.computeVertexNormals(),console.log(f),f}function y(f,l){var b=[];for(var d in f){var e=l[d],h=e.bound;if(h)b.push(f[d]);else{var i=e.adj,c=new a.Vector3(0,0,0),g=0;for(var k in i){var j=f[k];c.add(j),g++}c.divideScalar(g),b.push(c)}}return b}function r(i){var q=i.faces,l=i.vertices,a={},e={},g;for(var k=0;k<q.length;k++){var o=q[k],c=o.a,f=o.b,h=o.c;a[c]||(a[c]={adj:{}}),g=a[c].adj,g[f]=1,g[h]=1,a[f]||(a[f]={adj:{}}),g=a[c].adj,g[c]=1,g[h]=1,a[h]||(a[h]={adj:{}}),g=a[c].adj,g[c]=1,g[f]=1;var m=d(c,f)+'_'+b(c,f),n=d(f,h)+'_'+b(f,h),j=d(h,c)+'_'+b(h,c);e[m]?delete e[m]:e[m]=1,e[n]?delete e[n]:e[n]=1,e[j]?delete e[j]:e[j]=1}for(var s in e){var r=s.split('_'),t=r[0],u=r[1];a[t].bound=1,a[u].bound=1}for(var p=0;p<15;p++)l=y(l,a);return i.vertices=l,i.computeFaceNormals(),i}function w(o,q,p){var h=new a.Geometry,j=h.vertices;for(var b=p-1;b>=0;b--){var g=o+f(1e3*b)*q,i=e*k(),d=e*2*k(),m=g*f(i)*c(d),l=g*f(d),n=g*c(i)*c(d);j.push(new a.Vector3(m,l,n))}return h}function q(){try{var a=document.createElement('canvas'),b=a.getContext('webgl')||a.getContext('experimental-webgl');if(!b)throw'您的浏览器不支持webgl'}catch(a){alert('您的浏览器不支持webgl')}}function D(a){return typeof a==='function'?a:a==='sphere'?Sphere.project:void 0}function u(a){return a===null||a===undefined}function t(d,a){a=u(a)?.9:a;var e=d.getContext('2d'),f=e.getImageData(0,0,d.width,d.height),b=f.data,h=b.length,g;for(var c=0;c<h/4;c++)g=c*4+3,b[g]=b[g]*a;e.putImageData(f,0,0)}function x(a,c){typeof a==='String'&&(a=parseFloat(a));var b=c?Math.pow(10,c):1;return Math.floor(a*b)/b}function C(g,a,h){var b='',c=a,d=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];g&&(c=Math.round(Math.random()*(h-a))+a);for(var e=0;e<c;e++){var f=Math.round(Math.random()*(d.length-1));b+=d[f]}return b}var a=require('three'),j=require('aliyun-common-utils'),c=Math.cos,f=Math.sin,m=Math.atan2,l=Math.asin,h=Math.sqrt,k=Math.random,g=Math.pow,d=Math.min,n=Math.tan,e=Math.PI,o=Math.log,b=Math.max;q(),module.exports=j.extend(j,{genSphereParticles:w,getAreaTriangle3d:A,subdivideOnSphere:z,laplacian:r,getLatlngSphere:B,mercator:s,sphere:v,getPt:p,getScreenPt:p,detect:q,darken:t,parseNumber:x,randomWord:C}) | ||
'use strict';function b(c){c.originalEvent&&(c=c.originalEvent);var d=c.target,e=d.offsetWidth,f=d.offsetHeight,g=d.offsetLeft,h=d.offsetTop,a,b;if(c.type.indexOf('mouse')!==-1)return a=c.x||c.pageX,b=c.y||c.pageY,[a-g,b-h,'mouse'];var i=window.event.touches[0];return a=i.pageX-g,b=i.pageY-h,a=a<e?a:e,a=a>0?a:1,b=b<f?b:f,b=b>0?b:1,[a,b,'touch']}function p(e,f,a,b,c,d){return b=b||0,c=c||0,d=d||0,a=a||6378137,new q.Vector3(e/180*B*a+b,c,-a*C(A((90+f)*B/360))+d)}function c(k,l,a,d,e,c){var f=1;d=d||0,e=e||0,c=c||0,a=a||1;var g=-k*B/180,b=l*B/180,j=a*s(g)*s(b)*f+d,h=a*t(g)*s(b)*f+c,i=a*t(b)+e;return new q.Vector3(j,i,h)}function d(j,l,k,b,c,a,d){c=c||0,a=a||0,d=d||0,b=b||1;var i=j-c,g=l-a,h=k-d,f=v(g/b),e=u(h,i);return{lat:f,lng:e}}function e(c,a,d){var e=a.x-c.x,f=a.y-c.y,g=a.z-c.z,i=d.x-a.x,h=d.y-a.y,b=d.z-a.z;return.5*w(y(f*b-g*h,2)+y(e*b-g*i,2)+y(e*h-f*b,2))}function f(e,g,h,i,j){var b=e.x-h,c=e.y-i,d=e.z-j,f=w(b*b+c*c+d*d),a=f<g?g/f:1;return new q.Vector3(h+b*a,i+c*a,j+d*a)}function g(c,y){var A=y.x0,p=y.y0,x=y.z0,t=y.radius,b={},H=c.faces,k=[],a=c.vertices;for(var r=H.length-1;r>=0;r--){var g=H[r],h=g.a,d=g.b,e=g.c,l=g.normal,n=g.color,m=g.materialIndex,G=a[h],F=a[d],E=a[e],o,i,j,B=z(h,d)+'_'+D(h,d);if(!b[B]){var w=new q.Vector3().addVectors(G,F).divideScalar(2);w=f(w,t,A,p,x),o=b[B]=a.length,a.push(w)}else o=b[B];var v=z(d,e)+'_'+D(d,e);if(!b[v]){var u=new q.Vector3().addVectors(F,E).divideScalar(2);u=f(u,A,p,x,t);var i=b[v]=a.length;a.push(u)}else i=b[v];var s=z(h,e)+'_'+D(h,e);if(!b[s]){var C=new q.Vector3().addVectors(E,G).divideScalar(2);C=f(C,A,p,x,t);var j=b[s]=a.length;a.push(C)}else j=b[s];var J=new q.Face3(h,o,j,l,n,m),K=new q.Face3(o,d,i,l,n,m),L=new q.Face3(j,i,e,l,n,m),I=new q.Face3(o,i,j,l,n,m);k.push(J),k.push(K),k.push(L),k.push(I)}return c.vertices=a,c.faces=k,c.computeFaceNormals(),c.computeVertexNormals(),console.log(c),c}function h(e,k){var a=[];for(var c in e){var d=k[c],g=d.bound;if(g)a.push(e[c]);else{var h=d.adj,b=new q.Vector3(0,0,0),f=0;for(var j in h){var i=e[j];b.add(i),f++}b.divideScalar(f),a.push(b)}}return a}function i(g){var p=g.faces,k=g.vertices,a={},c={},e;for(var j=0;j<p.length;j++){var n=p[j],b=n.a,d=n.b,f=n.c;a[b]||(a[b]={adj:{}}),e=a[b].adj,e[d]=1,e[f]=1,a[d]||(a[d]={adj:{}}),e=a[b].adj,e[b]=1,e[f]=1,a[f]||(a[f]={adj:{}}),e=a[b].adj,e[b]=1,e[d]=1;var l=z(b,d)+'_'+D(b,d),m=z(d,f)+'_'+D(d,f),i=z(f,b)+'_'+D(f,b);c[l]?delete c[l]:c[l]=1,c[m]?delete c[m]:c[m]=1,c[i]?delete c[i]:c[i]=1}for(var r in c){var q=r.split('_'),s=q[0],t=q[1];a[s].bound=1,a[t].bound=1}for(var o=0;o<15;o++)k=h(k,a);return g.vertices=k,g.computeFaceNormals(),g}function j(j,l,k){var d=new q.Geometry,f=d.vertices;for(var a=k-1;a>=0;a--){var c=j+t(1e3*a)*l,e=B*x(),b=B*2*x(),h=c*t(e)*s(b),g=c*t(b),i=c*s(e)*s(b);f.push(new q.Vector3(h,g,i))}return d}function k(){try{var a=document.createElement('canvas'),b=a.getContext('webgl')||a.getContext('experimental-webgl');if(!b)throw'您的浏览器不支持webgl'}catch(a){alert('您的浏览器不支持webgl')}}function l(a){return typeof a==='function'?a:a==='sphere'?Sphere.project:void 0}function m(a){return a===null||a===undefined}function n(d,a){a=m(a)?.9:a;var e=d.getContext('2d'),f=e.getImageData(0,0,d.width,d.height),b=f.data,h=b.length,g;for(var c=0;c<h/4;c++)g=c*4+3,b[g]=b[g]*a;e.putImageData(f,0,0)}function o(a,c){typeof a==='String'&&(a=parseFloat(a));var b=c?Math.pow(10,c):1;return Math.floor(a*b)/b}function a(g,a,h){var b='',c=a,d=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];g&&(c=Math.round(Math.random()*(h-a))+a);for(var e=0;e<c;e++){var f=Math.round(Math.random()*(d.length-1));b+=d[f]}return b}var q=require('three'),r=require('aliyun-common-utils'),s=Math.cos,t=Math.sin,u=Math.atan2,v=Math.asin,w=Math.sqrt,x=Math.random,y=Math.pow,z=Math.min,A=Math.tan,B=Math.PI,C=Math.log,D=Math.max;k(),module.exports=r.extend(r,{genSphereParticles:j,getAreaTriangle3d:e,subdivideOnSphere:g,laplacian:i,getLatlngSphere:d,mercator:p,sphere:c,getPt:b,getScreenPt:b,detect:k,darken:n,parseNumber:o,randomWord:a}) |
@@ -1,1 +0,1 @@ | ||
function b(d,c){c=this.options=a.deepMerge(b.options,c),this.getCanvas(d),this.init(),this.sprite=this.updateSprite()}var a=require('./../core/utils'),c=require('bcore/event'),d=require('./../map/projection/origin_2d'),e=require('./../render/canvas'),f=a.getSprite;b.options={speedRatio:.19,lifeMax:1,lifeJitter:.9,lifeSpeed:.02,weight:3},b=c.extend(b,{getCanvas:function(b){b=this.canvas=a.getContainer(b);var c=this.ctx=b.getContext('2d')},init:function(){this.reset()},data:function(a){this._data=a},draw:function(){var d=this.options,b=this.sprite||this.options.sprite;if(!b)return;b=a.switchValue(b,this.force),b=a.getSprite(b);var c=a.switchValue(d.weight,this.force);this.ctx.drawImage(b,this.x-c/2,this.y-c/2,c,c)},reset:function(){this.life=0;var a=this.options,b=this.canvas,c=b.width,d=b.height;this.x=c*Math.random(),this.y=d*Math.random(),this.lifeMax=a.lifeMax*(1-a.lifeJitter)+a.lifeJitter*Math.random()},updateLife:function(){var b=this.options;if(this.life+=b.lifeSpeed,this.life>this.lifeMax)return this.reset();var c=b.speedRatio,a=this.force=this.vectorFunc(this.x/this.canvas.width,this.y/this.canvas.height)||{};if(a.len=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),!a)return this.reset();this.x+=a.x*c,this.y+=a.y*c;var d=this.canvas.width,e=this.canvas.height;this.x=(this.x+d)%d,this.y=(this.y+e)%e,this.draw()},updateOptions:function(b){this.options=a.deepMerge(this.options,b)},update:function(){},updateSprite:function(a){this.sprite=a},render:function(a){},pause:function(){window.cancelAnimationFrame(this.loopId),this.loopId=null},loop:function(){if(this.loopId!==null)return;this.draw(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))},clean:function(){}}),module.exports=b | ||
function a(d,c){c=this.options=b.deepMerge(a.options,c),this.getCanvas(d),this.init(),this.sprite=this.updateSprite()}var b=require('./../core/utils'),c=require('bcore/event'),d=require('./../map/projection/origin_2d'),e=require('./../render/canvas'),f=b.getSprite;a.options={speedRatio:.19,lifeMax:1,lifeJitter:.9,lifeSpeed:.02,weight:3},a=c.extend(a,{getCanvas:function(a){a=this.canvas=b.getContainer(a);var c=this.ctx=a.getContext('2d')},init:function(){this.reset()},data:function(a){this._data=a},draw:function(){var d=this.options,a=this.sprite||this.options.sprite;if(!a)return;a=b.switchValue(a,this.force),a=b.getSprite(a);var c=b.switchValue(d.weight,this.force);this.ctx.drawImage(a,this.x-c/2,this.y-c/2,c,c)},reset:function(){this.life=0;var a=this.options,b=this.canvas,c=b.width,d=b.height;this.x=c*Math.random(),this.y=d*Math.random(),this.lifeMax=a.lifeMax*(1-a.lifeJitter)+a.lifeJitter*Math.random()},updateLife:function(){var b=this.options;if(this.life+=b.lifeSpeed,this.life>this.lifeMax)return this.reset();var c=b.speedRatio,a=this.force=this.vectorFunc(this.x/this.canvas.width,this.y/this.canvas.height)||{};if(a.len=Math.sqrt(Math.pow(a.x,2)+Math.pow(a.y,2)),!a)return this.reset();this.x+=a.x*c,this.y+=a.y*c;var d=this.canvas.width,e=this.canvas.height;this.x=(this.x+d)%d,this.y=(this.y+e)%e,this.draw()},updateOptions:function(a){this.options=b.deepMerge(this.options,a)},update:function(){},updateSprite:function(a){this.sprite=a},render:function(a){},pause:function(){window.cancelAnimationFrame(this.loopId),this.loopId=null},loop:function(){if(this.loopId!==null)return;this.draw(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))},clean:function(){}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
function a(d,c){c=this.options=b.deepMerge(a.options,c),this.getCanvas(d),this.init(),this.updateSprite()}var b=require('./../core/utils'),c=require('bcore/event'),e=require('./../map/projection/origin_2d'),f=require('./../render/canvas'),d=require('./flow');a.options={x:function(a){return a[0]||a.x},y:function(a){return a[1]||a.y},blending:'lighter',clearAlpha:null,clearColor:'rgba(0,0,0,0.1)',child:{weight:8.5,lifeSpeed:.0203,speedRatio:.17},childN:2e3,sprite:{width:200,height:200,isContinue:!1,drawN:7.4,type:'radian',color:{from:'rgba(0,255,161,0.99)',to:'rgba(0,150,255,0)',easing:'Linear.None.1.7',space:'rgb'}}},a=c.extend(a,{getCanvas:function(a){a=this.canvas=b.getContainer(a);var c=this.ctx=a.getContext('2d');this.canvasWidth=a.width,this.canvasHeight=a.height},getOptionsChild:function(){var a=this.options;return childO=a.child,childO},init:function(){var b=this.options.childN,c=this.canvas,e,f=this.flows=[],g=this.getOptionsChild();for(var a=0;a<b;a++)e=new d(c,g),f.push(e)},data:function(a){this._data=a},draw:function(){var a=this.options;this.each(function(a){a.updateLife()}),a.clearAlpha?b.darken(this.canvas,a.clearAlpha):(this.ctx.globalCompositeOperation='source-over',this.ctx.fillStyle=a.clearColor,this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.globalCompositeOperation=a.blending)},update:function(){this.updateSprite(),this.updateVectorFunc(),this.ctx.globalCompositeOperation=this.options.blending},updateSprite:function(a){a=a||this.options.sprite,this.each(function(b){b.updateSprite(a)})},render:function(a){if(a&&this.data(a),this.update(),this.loopId)return;this.loop()},each:function(d){var b,a=this.flows;for(var c in a)b=a[c],d(b)},updateVectorFunc:function(){var a=this.options,f=a.x,h=a.y,b,d,j=this._data,c=a.nx,i=a.ny,g=this,e=this.vectorFunc=function(k,l){var j=g._data;if(!j)return;if(a=Math.floor(k*c),e=Math.floor(l*i),d=e*c+a,b=j[d],!b)return null;var a=f(b),e=h(b);return{x:a,y:e}};this.each(function(a){a.vectorFunc=e})},updateOptions:function(c){this.options=b.deepMerge(this.options,c);var a=this.getOptionsChild();this.each(function(b){b.updateOptions(a)}),this.update()},pause:function(){window.cancelAnimationFrame(this.loopId),this.loopId=null},loop:function(){this.draw(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))},clean:function(){}}),module.exports=a | ||
function a(d,c){c=this.options=b.deepMerge(a.options,c),this.getCanvas(d),this.init(),this.updateSprite()}var b=require('./../core/utils'),c=require('bcore/event'),d=require('./../map/projection/origin_2d'),e=require('./../render/canvas'),f=require('./flow');a.options={x:function(a){return a[0]||a.x},y:function(a){return a[1]||a.y},blending:'lighter',clearAlpha:null,clearColor:'rgba(0,0,0,0.1)',child:{weight:8.5,lifeSpeed:.0203,speedRatio:.17},childN:2e3,sprite:{width:200,height:200,isContinue:!1,drawN:7.4,type:'radian',color:{from:'rgba(0,255,161,0.99)',to:'rgba(0,150,255,0)',easing:'Linear.None.1.7',space:'rgb'}}},a=c.extend(a,{getCanvas:function(a){a=this.canvas=b.getContainer(a);var c=this.ctx=a.getContext('2d');this.canvasWidth=a.width,this.canvasHeight=a.height},getOptionsChild:function(){var a=this.options;return childO=a.child,childO},init:function(){var b=this.options.childN,c=this.canvas,d,e=this.flows=[],g=this.getOptionsChild();for(var a=0;a<b;a++)d=new f(c,g),e.push(d)},data:function(a){this._data=a},draw:function(){var a=this.options;this.each(function(a){a.updateLife()}),a.clearAlpha?b.darken(this.canvas,a.clearAlpha):(this.ctx.globalCompositeOperation='source-over',this.ctx.fillStyle=a.clearColor,this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.ctx.globalCompositeOperation=a.blending)},update:function(){this.updateSprite(),this.updateVectorFunc(),this.ctx.globalCompositeOperation=this.options.blending},updateSprite:function(a){a=a||this.options.sprite,this.each(function(b){b.updateSprite(a)})},render:function(a){if(a&&this.data(a),this.update(),this.loopId)return;this.loop()},each:function(d){var b,a=this.flows;for(var c in a)b=a[c],d(b)},updateVectorFunc:function(){var a=this.options,f=a.x,h=a.y,b,d,j=this._data,c=a.nx,i=a.ny,g=this,e=this.vectorFunc=function(k,l){var j=g._data;if(!j)return;if(a=Math.floor(k*c),e=Math.floor(l*i),d=e*c+a,b=j[d],!b)return null;var a=f(b),e=h(b);return{x:a,y:e}};this.each(function(a){a.vectorFunc=e})},updateOptions:function(c){this.options=b.deepMerge(this.options,c);var a=this.getOptionsChild();this.each(function(b){b.updateOptions(a)}),this.update()},pause:function(){window.cancelAnimationFrame(this.loopId),this.loopId=null},loop:function(){this.draw(),this.loopId=window.requestAnimationFrame(this.loop.bind(this))},clean:function(){}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function f(a,b,c){return typeof a==='function'?a(b,c):a}function b(a){a=this.options=c.deepMerge(b.options,a)}var a=require('three'),c=require('bcore/utils'),d=require('bcore/event'),e=require('lodash');b.options={isVisible:!0,width:200,height:100,style:{offsetLeft:30,fontSize:25,color:'#fff',background:'rgba(240,0,0,0)',opacity:function(){return 1}},scaleSize:1e6},b=d.extend(b,{addTo:function(a){if(!a)return;this._map=a,this.three3D=a.three3D,this.init()},init:function(){var b=this.options,c=this.canvas=document.createElement('canvas'),h=this.ctx=c.getContext('2d');c.width=b.width,c.height=b.height;var f=this.texture=new a.Texture(c),g=this.material=new a.SpriteMaterial({map:f,opacity:1,transparent:!0,depthTest:!0,fog:!1}),d=b.scaleSize,e=this.object=new a.Sprite(g);e.scale.set(d,d*b.height/b.width),this.three3D.add(e)},updatePos:function(a){this.position=a,this.object.position.set(a.x,a.y,a.z)},clear:function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)},updateTexture:function(d){if(this.clear(),!d)return;var d=this.content=d,l=this,b=this.ctx,c=this.options,i=c.type,g=c.style;b.canvas.height=c.height,b.canvas.width=c.width;var n=b.canvas.width,o=b.canvas.height;if(c.updateCtx)return c.updateCtx(b);if(i==='text'){b.fillStyle=g.background,b.font=g.fontSize+'px Arial';var m=b.measureText(d);b.textBaseline='middle';var k=m.width,h=(n-k)/2;c.offsetLeft&&(h-=g.offsetLeft),b.fillRect(0,0,k+2*h,c.height),b.fillStyle=f(g.color),b.fillText(d,h,c.height/2,k),b.fill(),l.texture.needsUpdate=!0}else if(i==='image'){if(typeof d!=='string'){console.log('need urls of images');return}var j=new a.ImageLoader;j.setCrossOrigin('*'),j.crossOrigin='*',j.load(d,function(a){b.drawImage(a,0,0),l.texture.needsUpdate=!0})}else if(i==='dom'){if(!e.isPlainObject(d)){console.log('content must be object');return}this.drawHTML(b,d)}this.updateVisible()},drawHTML:function(c,b){var g=this,w=b.title||'标题',d=b.content||'这是正文',v=b.titleColor||'#FF0000',u=b.contentColor||'#000',n=b.width||400,s=b.height||300,j=b.titleFontSize||100,e=b.contentFontSize||80,l=b.fontFamily||'serif',p=b.bgImgUrl||'',o=b.paddingLeft||0,q=b.paddingRight||0,r=b.paddingTop||0,k=j,t=s-k,m,i,h,x,f=new a.ImageLoader;f.setCrossOrigin('*'),f.crossOrigin='*',f.load(p,function(s){c.drawImage(s,0,k,n,t),c.font=j+'px '+l,c.fillStyle=v,c.fillText(w,0,j),c.font=e+'px '+l,c.fillStyle=u,m=+(n-o-q)||1,d=d,h=d.split(''),x=h.length*e,i=Math.floor(m/e);for(var a=0;a<Math.ceil(x/m);a++){var b=a*i,f=(a+1)*i>=h.length?h.length:(a+1)*i,p=d.slice(b,f);c.fillText(p,o,r+e*(a+1))}g.texture.image=g.canvas,g.texture.needsUpdate=!0})},updateOptions:function(a){this.options=a,this.update()},updateScale:function(){var a=this.options,c=this.object,b=a.scaleSize;c.scale.set(b,b*a.height/a.width)},update:function(){this.updateVisible(),this.updateScale(),this.updateMaterial()},updateVisible:function(){var a=this.options,b=a.isVisible;b?this.show():this.hide()},show:function(){this.object.visible=!0},hide:function(){this.object.visible=!1},updateMaterial:function(){this.texture.needsUpdate=!0,this.material.needsUpdate=!0,this.material.map.needsUpdate=!0},updateOpacity:function(){var a=this._map.three3D.camera,b=a.position,c=b.distanceTo(this.position),d=this._map.projection.radius,e=this.options,f=e.style.opacity(c/d);this.material.opacity=f},remove:function(){this.three3D.remove(this.object),this.object&&this.object.dispose&&this.object.dispose(),this.material&&this.material.dispose(),this.texture&&this.texture.dispose(),this.object=null,this.material=null,this.texture=null}}),module.exports=b | ||
'use strict';function a(a,b,c){return typeof a==='function'?a(b,c):a}function b(a){a=this.options=d.deepMerge(b.options,a)}var c=require('three'),d=require('bcore/utils'),e=require('bcore/event'),f=require('lodash');b.options={isVisible:!0,width:200,height:100,style:{offsetLeft:30,fontSize:25,color:'#fff',background:'rgba(240,0,0,0)',opacity:function(){return 1}},scaleSize:1e6},b=e.extend(b,{addTo:function(a){if(!a)return;this._map=a,this.three3D=a.three3D,this.init()},init:function(){var a=this.options,b=this.canvas=document.createElement('canvas'),h=this.ctx=b.getContext('2d');b.width=a.width,b.height=a.height;var f=this.texture=new c.Texture(b),g=this.material=new c.SpriteMaterial({map:f,opacity:1,transparent:!0,depthTest:!0,fog:!1}),d=a.scaleSize,e=this.object=new c.Sprite(g);e.scale.set(d,d*a.height/a.width),this.three3D.add(e)},updatePos:function(a){this.position=a,this.object.position.set(a.x,a.y,a.z)},clear:function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)},updateTexture:function(e){if(this.clear(),!e)return;var e=this.content=e,l=this,b=this.ctx,d=this.options,i=d.type,g=d.style;b.canvas.height=d.height,b.canvas.width=d.width;var n=b.canvas.width,o=b.canvas.height;if(d.updateCtx)return d.updateCtx(b);if(i==='text'){b.fillStyle=g.background,b.font=g.fontSize+'px Arial';var m=b.measureText(e);b.textBaseline='middle';var k=m.width,h=(n-k)/2;d.offsetLeft&&(h-=g.offsetLeft),b.fillRect(0,0,k+2*h,d.height),b.fillStyle=a(g.color),b.fillText(e,h,d.height/2,k),b.fill(),l.texture.needsUpdate=!0}else if(i==='image'){if(typeof e!=='string'){console.log('need urls of images');return}var j=new c.ImageLoader;j.setCrossOrigin('*'),j.crossOrigin='*',j.load(e,function(a){b.drawImage(a,0,0),l.texture.needsUpdate=!0})}else if(i==='dom'){if(!f.isPlainObject(e)){console.log('content must be object');return}this.drawHTML(b,e)}this.updateVisible()},drawHTML:function(b,a){var g=this,w=a.title||'标题',d=a.content||'这是正文',v=a.titleColor||'#FF0000',u=a.contentColor||'#000',n=a.width||400,s=a.height||300,j=a.titleFontSize||100,e=a.contentFontSize||80,l=a.fontFamily||'serif',p=a.bgImgUrl||'',o=a.paddingLeft||0,q=a.paddingRight||0,r=a.paddingTop||0,k=j,t=s-k,m,i,h,x,f=new c.ImageLoader;f.setCrossOrigin('*'),f.crossOrigin='*',f.load(p,function(s){b.drawImage(s,0,k,n,t),b.font=j+'px '+l,b.fillStyle=v,b.fillText(w,0,j),b.font=e+'px '+l,b.fillStyle=u,m=+(n-o-q)||1,d=d,h=d.split(''),x=h.length*e,i=Math.floor(m/e);for(var a=0;a<Math.ceil(x/m);a++){var c=a*i,f=(a+1)*i>=h.length?h.length:(a+1)*i,p=d.slice(c,f);b.fillText(p,o,r+e*(a+1))}g.texture.image=g.canvas,g.texture.needsUpdate=!0})},updateOptions:function(a){this.options=a,this.update()},updateScale:function(){var a=this.options,c=this.object,b=a.scaleSize;c.scale.set(b,b*a.height/a.width)},update:function(){this.updateVisible(),this.updateScale(),this.updateMaterial()},updateVisible:function(){var a=this.options,b=a.isVisible;b?this.show():this.hide()},show:function(){this.object.visible=!0},hide:function(){this.object.visible=!1},updateMaterial:function(){this.texture.needsUpdate=!0,this.material.needsUpdate=!0,this.material.map.needsUpdate=!0},updateOpacity:function(){var a=this._map.three3D.camera,b=a.position,c=b.distanceTo(this.position),d=this._map.projection.radius,e=this.options,f=e.style.opacity(c/d);this.material.opacity=f},remove:function(){this.three3D.remove(this.object),this.object&&this.object.dispose&&this.object.dispose(),this.material&&this.material.dispose(),this.texture&&this.texture.dispose(),this.object=null,this.material=null,this.texture=null}}),module.exports=b |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(c){c=this.options=a.deepMerge(b.options,c),this.markers={}}var a=require('./../../core/utils'),e=a.mercator,f=a.sphere,c=require('./marker'),g=require('lodash'),h=a.isNone,i=require('three'),a=require('bcore/utils'),d=require('bcore/event');b.options={isAble:!0,markerN:100,isDynamic:!0,texture:function(a){return a.text},fog:!0,ratio:1.1,marker:{depthTest:!0,scaleSize:15e5,quality:3,style:{offsetLeft:30,fontSize:55,color:'#0ff',background:'rgba(0,0,0,0)'}},lat:function(a){return a.latlngs.lat},lng:function(a){return a.latlngs.lng},width:function(a){return a.content.width||900},height:function(a){return a.content.height||300},id:function(a,b){return a.id||b}},b=d.extend(b,{addTo:function(a){if(!a)return;this._map=a,this.three3D=a.three3D,this.projection=a.projection},onUpdate:function(a){if(typeof a!=='function')return console.log('必须是函数');this._updateCtx=this._opt.updateCtx=a},remove:function(){var b,a=this.markers;for(var c in a)b=a[c],b.remove();this._data=null,b=null,a=null},clean:function(){var a=this.markers;if(a)for(var b in a){var c=a[b];c.remove(),delete a[b]}},data:function(a){this._data=a},draw:function(){var h=this._data;if(!h)return;var m=this.projection,p=this._map,j=this.markers,f=this.getChildOptions(),a=this.options,g=a.ratio,u=a.texture,v=a.id,l=a.lat,q=a.lng,n=a.width,o=a.height,b,k,r,s,t,d,e;for(var i in h)b=h[i],k=v(b,i),r=u(b),s=l(b),t=q(b),e=m.project({lng:t,lat:s}),e.x=e.x*g,e.y=e.y*g,e.z=e.z*g,f.isVisible=a.isAble,f.type=b.type||'text',f.width=n(b)||900,f.height=o(b)||300,d=j[k],d||(d=new c(f),d.addTo(p),j[k]=d),d.updateOptions(f),d.updateTexture(r),d.updatePos(e,b)},each:function(b){var c,a=this.markers;for(var d in a)c=a[d],b&&b(c)},update:function(){this.each(function(a){a&&a.update()})},getChildOptions:function(){var a=this.options;return a.marker},updateOptions:function(b){b&&(this.options=a.deepMerge(this.options,b)),this.draw();var c=this.getChildOptions();c.isVisible=b.isAble,this.each(function(a){a.updateOptions(c)}.bind(this))},render:function(a){a&&this.data(a),this.clean(),this.draw()}}),module.exports=b | ||
'use strict';function b(c){c=this.options=a.deepMerge(b.options,c),this.markers={}}var a=require('./../../core/utils'),c=a.mercator,d=a.sphere,e=require('./marker'),f=require('lodash'),g=a.isNone,h=require('three'),a=require('bcore/utils'),i=require('bcore/event');b.options={isAble:!0,markerN:100,isDynamic:!0,texture:function(a){return a.text},fog:!0,ratio:1.1,marker:{depthTest:!0,scaleSize:15e5,quality:3,style:{offsetLeft:30,fontSize:55,color:'#0ff',background:'rgba(0,0,0,0)'}},lat:function(a){return a.latlngs.lat},lng:function(a){return a.latlngs.lng},width:function(a){return a.content.width||900},height:function(a){return a.content.height||300},id:function(a,b){return a.id||b}},b=i.extend(b,{addTo:function(a){if(!a)return;this._map=a,this.three3D=a.three3D,this.projection=a.projection},onUpdate:function(a){if(typeof a!=='function')return console.log('必须是函数');this._updateCtx=this._opt.updateCtx=a},remove:function(){var b,a=this.markers;for(var c in a)b=a[c],b.remove();this._data=null,b=null,a=null},clean:function(){var a=this.markers;if(a)for(var b in a){var c=a[b];c.remove(),delete a[b]}},data:function(a){this._data=a},draw:function(){var h=this._data;if(!h)return;var m=this.projection,p=this._map,j=this.markers,f=this.getChildOptions(),a=this.options,g=a.ratio,u=a.texture,v=a.id,l=a.lat,q=a.lng,n=a.width,o=a.height,b,k,r,s,t,c,d;for(var i in h)b=h[i],k=v(b,i),r=u(b),s=l(b),t=q(b),d=m.project({lng:t,lat:s}),d.x=d.x*g,d.y=d.y*g,d.z=d.z*g,f.isVisible=a.isAble,f.type=b.type||'text',f.width=n(b)||900,f.height=o(b)||300,c=j[k],c||(c=new e(f),c.addTo(p),j[k]=c),c.updateOptions(f),c.updateTexture(r),c.updatePos(d,b)},each:function(b){var c,a=this.markers;for(var d in a)c=a[d],b&&b(c)},update:function(){this.each(function(a){a&&a.update()})},getChildOptions:function(){var a=this.options;return a.marker},updateOptions:function(b){b&&(this.options=a.deepMerge(this.options,b)),this.draw();var c=this.getChildOptions();c.isVisible=b.isAble,this.each(function(a){a.updateOptions(c)}.bind(this))},render:function(a){a&&this.data(a),this.clean(),this.draw()}}),module.exports=b |
@@ -1,1 +0,1 @@ | ||
'use strict';function l(a,b){return typeof a==='function'?a(arguments[1],arguments[2],arguments[3],arguments[4]):a}function m(a,b,c){return typeof a==='function'?a(b,c):a}function j(a,b){return typeof a==='function'?a(b):a}function n(d,e){var c=d.faces,b=g.parse(e).arr;setTimeout(function(){var g;for(var e=0;e<c.length;e++){var g=c[e],h=Math.abs(Math.cos(e/10)),f=new a.Color('rgb('+b[0]+', '+Math.floor(b[1]+h*30)+', '+Math.floor(b[2]+50*h)+')');g.vertexColors.push(f,f,f)}d.colorsNeedUpdate=!0},10)}function b(a){this.options=c.deepMerge(b.options,a)}function d(a){return a===undefined?!1:!0}var a=require('three'),c=require('./../core/utils'),e=c.divideby,h=c.traver,d=c.isNone,g=c.format,f=require('./../map/projection/mecator'),k=c.getColorFunc,i=c.switchValue;b.options={geoid:function(b){if(b.id)return b.id;var a=b.properties;return a?a.id||a.adcode:void 0},lat:function(a){return a[1]},lng:function(a){return a[0]},value:function(a){return a&&a.value?a.value||0:a},id:function(a,b){return a.id||a.adcode||b},offset:function(){return{x:0,y:0,z:0}},ratio:1,shape:{fill:{type:'texture',url:''},stroke:null}},b.prototype.addTo=function(a){this._map=a,this.projection=a.projection,this.three3D=a.three3D},b.prototype.render=function(a){a&&this.data(a),this.draw()},b.prototype.data=function(a){if(!a)return;this.processing(a)},b.prototype.processing=function(f){var b,c,a,k,g,i=this.options.value,j=this.options.id,h={};for(var e in f)g=f[e],k=j(g,e),a=i(f[e]),h[k]=g,c=d(c)?a:c,b=d(b)?a:b,a>c&&(c=a),a<b&&(b=a);this.vMax=c,this.vMin=b,this._data=h},b.prototype.draw=function(){var a=this._data,c=this.options.id,d=this.geo,g,e,f;for(var b in a)e=a[b],f=c(e,b),g=d[f];this.updateFill(),this.updateStroke()},b.prototype.geoJson=function(n){var d=this.options,f=this;if(!n)return console.log('没有geojson');var g=this.options.shape,m=this.projection,q=g.fill,e=g.stroke;if(e)var l=this.genStroke(e);var i=this.geo=this.geo||{},c,k,o,b,a,p=this.traverArray.bind(this);h(n,function(t,q,g){if(t!=='geometry')return!0;if(k=d.geoid(g),a=i[k]=i[k]||{},c=g.properties,b=q.coordinate||g.cp||c.cp||c.coordinate,b){a.cp=b;var r=b.lat||b[0],s=b.lng||b[1];a.cp3D=m.project({lng:s,lat:r},1)}var h=c.cName||c.name;h&&(a.cName=h),e&&(l(a),a.strokeMesh=[]),f.fillFunc(a,function(a){a.fillMesh=[],p(o,a,n),f.updateScale()});var n;return d.offset?n=j(d.offset,c):n={x:0,y:0,z:0},o=q.coordinates,!1})},b.prototype.traverArray=function(a,c,d){for(var b in a)if(typeof a[b][0]!=='object'){this.pts2Mesh.bind(this)(a,c,d);break}else this.traverArray.bind(this)(a[b],c,d)},b.prototype.pts2Mesh=function(k,e,i){var l=this.projection,f=this.pts2MeshGeo(k,e);if(f){var h=this.three3D,c=f.fillGeometry,g=f.strokeGeometry;if(c){var d=e.material;if(!d)return;var b;typeof d==='function'?(b=d(c),c.buffersNeedUpdate=!0,c.uvsNeedUpdate=!0,c.computeFaceNormals()):typeof d==='object'&&(b=new a.Mesh(c,d)),b.position.set(i.x,i.y,i.z),h.add(b),e.fillMesh.push(b)}if(g){var j=e.strokeMaterial;g.computeLineDistances();var b;b=new a.Line(g,j),b.position.set(0,0,0),h.add(b),e.strokeMesh.push(b)}}},b.prototype.pts2MeshGeo=function(r,E){var A=this.projection,m=this.options,q=m.shape,C=q.stroke,D=q.fill,l=q.divide,s=new a.Shape,k=[],b,w,i,j,x,B=m.lat,z=m.lng,t=1e-5,u=1e-5,n,o;if(r.length<3)return console.log('less 3pts');for(var h=0;h<r.length;h++)n=B(r[h]),l&&(n=e(n,l)),o=z(r[h]),l&&(o=e(o,l)),b=A.project({lng:o,lat:n},m.ratio),w=f.project({lng:o,lat:n}),i=w.x,j=w.z,x=!d(i)&&!d(j),h===0&&x&&(s.moveTo(-j,-i),k.push(b),t=i,u=j),h!==0&&(t!==i||u!==j)&&x&&(s.lineTo(-j,-i),k.push(b),t=i,u=j);var p,g;if(k.length){var v,y;if(D){y=new a.ShapeGeometry(s),p=y.vertices;for(var c=0;c<p.length;c++)b=k[c],g=p[c],g&&b&&(g.x=b.x,g.z=b.z,g.y=b.y)}if(C){v=new a.Geometry,p=v.vertices;for(var c=0;c<k.length;c++)b=k[c],g=new a.Vector3,g.x=b.x,g.z=b.z,g.y=b.y,p.push(g)}return{strokeGeometry:v,fillGeometry:y}}return!1},b.prototype.hide=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!1;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!1})},b.prototype.show=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!0;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!0})},b.prototype.updateScale=function(){var a,b=this.options.ratio;this.each(function(d){if(a=d.fillMesh,a)for(var c in a)a[c].scale.set(b,b,b);if(a=d.strokeMesh,a)for(var c in a)a[c].scale.set(b,b,b)})},b.prototype.fillFunc=function(e,f){var c=this,d=this.options,g=d.shape.fill.url,h=d.shape.fill.mediumUrl,i=d.shape.fill.smallUrl,b=new a.TextureLoader;b.setCrossOrigin('*'),b.crossOrigin='*',b.load(g,function(d){b.load(i,function(g){b.load(h,function(b){var h=new a.MeshBasicMaterial({map:d,side:a.DoubleSide,overdraw:!0,blending:a.AdditiveBlending});d.minFilter=a.LinearFilter,d.wrapS=d.wrapT=a.RepeatWrapping,h.map.needsUpdate=!0;var i=new a.MeshBasicMaterial({map:b,side:a.DoubleSide,overdraw:!0,blending:a.AdditiveBlending});b.minFilter=a.LinearFilter,b.wrapS=b.wrapT=a.RepeatWrapping,i.map.needsUpdate=!0;var j=new a.MeshBasicMaterial({map:g,side:a.DoubleSide,overdraw:!0,blending:a.AdditiveBlending});g.minFilter=a.LinearFilter,g.wrapS=g.wrapT=a.RepeatWrapping,j.map.needsUpdate=!0,e.material=function(b){if(b.faces.length<70){var d=new a.Mesh(b,j);return c.uvGenerator(b),d}else if(b.faces.length>100){var d=new a.Mesh(b,h);return c.uvGenerator(b),d}else{var d=new a.Mesh(b,i);return c.uvGenerator(b),d}},f&&f(e)})})})},b.prototype.uvGenerator=function(b){b.computeBoundingBox();var i=b.boundingBox.max,g=b.boundingBox.min,o=i.x,q=i.y,p=i.z,e=g.x,r=g.y,d=g.z,j=o-e,f=p-d,l=new a.Vector2(0,0),m=new a.Vector2(0,0),n=new a.Vector2(0,0);b.faceVertexUvs[0]=[];for(var k=0;k<b.faces.length;++k){var h=b.faces[k],c=b.vertices[h.a];l.set((c.z-d)/f,(c.x-e)/j),c=b.vertices[h.b],m.set((c.z-d)/f,(c.x-e)/j),c=b.vertices[h.c],n.set((c.z-d)/f,(c.x-e)/j),b.faceVertexUvs[0].push([l.clone(),m.clone(),n.clone()])}b.uvsNeedUpdate=!0},b.prototype.update=function(){this.updateFill(),this.updateStroke()},b.prototype.updateFill=function(){var a=this.options,b=a.shape,c=a.value,d=b.fill;return void 0},b.prototype.updateStroke=function(){var k=this.options.shape,c=k.stroke;if(!c)return;var r=c.color,f=this.geo,p=this._data;for(var g in f){var j=f[g],m=p[g],h=j.strokeMesh;for(var n in h){var o=h[n],d=o.material,q=l(r,m),e=new a.Color(q);d.color.setRGB(e.r,e.g,e.b);var b=c.opacity;(b===null||b===undefined)&&(b=1),d.opacity=b,d.linewidth=i(c.linewidth)}}},b.prototype.updateOptions=function(a){this.options=c.deepMerge(this.options,a),this.updateStroke(),this.updateFill(),this.updateScale()},b.prototype.each=function(d){var a=this.geo;for(var b in a){var c=a[b];d(c)}},b.prototype.genStroke=function(b){if(typeof b==='function')return b;var d=this.options.shape.stroke,h=b.type||'default',e=b.color||16777215,c=b.opacity,f=b.width||b.linewidth||.01,g=c?!0:!1;return{dash:function(b){b.strokeMaterial=new a.LineDashedMaterial({linewidth:f,color:e,dashSize:d.dashSize,gapSize:d.gapSize,transparent:g,opacity:c,linejoin:'round',linecap:'round'})},default:function(b){b.strokeMaterial=new a.LineBasicMaterial({linewidth:f,color:e,transparent:g,opacity:c,linejoin:'round',linecap:'round'})}}[h]},b.prototype.loop=function(){},b.prototype.geojson=b.prototype.geoJson,module.exports=b | ||
'use strict';function f(a,b){return typeof a==='function'?a(arguments[1],arguments[2],arguments[3],arguments[4]):a}function h(a,b,c){return typeof a==='function'?a(b,c):a}function c(a,b){return typeof a==='function'?a(b):a}function d(c,d){var b=c.faces,a=k.parse(d).arr;setTimeout(function(){var f;for(var d=0;d<b.length;d++){var f=b[d],h=Math.abs(Math.cos(d/10)),e=new g.Color('rgb('+a[0]+', '+Math.floor(a[1]+h*30)+', '+Math.floor(a[2]+50*h)+')');f.vertexColors.push(e,e,e)}c.colorsNeedUpdate=!0},10)}function e(a){this.options=b.deepMerge(e.options,a)}function a(a){return a===undefined?!1:!0}var g=require('three'),b=require('./../core/utils'),i=b.divideby,j=b.traver,a=b.isNone,k=b.format,l=require('./../map/projection/mecator'),m=b.getColorFunc,n=b.switchValue;e.options={geoid:function(b){if(b.id)return b.id;var a=b.properties;return a?a.id||a.adcode:void 0},lat:function(a){return a[1]},lng:function(a){return a[0]},value:function(a){return a&&a.value?a.value||0:a},id:function(a,b){return a.id||a.adcode||b},offset:function(){return{x:0,y:0,z:0}},ratio:1,shape:{fill:{type:'texture',url:''},stroke:null}},e.prototype.addTo=function(a){this._map=a,this.projection=a.projection,this.three3D=a.three3D},e.prototype.render=function(a){a&&this.data(a),this.draw()},e.prototype.data=function(a){if(!a)return;this.processing(a)},e.prototype.processing=function(f){var c,d,b,k,g,i=this.options.value,j=this.options.id,h={};for(var e in f)g=f[e],k=j(g,e),b=i(f[e]),h[k]=g,d=a(d)?b:d,c=a(c)?b:c,b>d&&(d=b),b<c&&(c=b);this.vMax=d,this.vMin=c,this._data=h},e.prototype.draw=function(){var a=this._data,c=this.options.id,d=this.geo,g,e,f;for(var b in a)e=a[b],f=c(e,b),g=d[f];this.updateFill(),this.updateStroke()},e.prototype.geoJson=function(n){var e=this.options,g=this;if(!n)return console.log('没有geojson');var h=this.options.shape,m=this.projection,q=h.fill,f=h.stroke;if(f)var l=this.genStroke(f);var i=this.geo=this.geo||{},d,k,o,b,a,p=this.traverArray.bind(this);j(n,function(t,q,h){if(t!=='geometry')return!0;if(k=e.geoid(h),a=i[k]=i[k]||{},d=h.properties,b=q.coordinate||h.cp||d.cp||d.coordinate,b){a.cp=b;var r=b.lat||b[0],s=b.lng||b[1];a.cp3D=m.project({lng:s,lat:r},1)}var j=d.cName||d.name;j&&(a.cName=j),f&&(l(a),a.strokeMesh=[]),g.fillFunc(a,function(a){a.fillMesh=[],p(o,a,n),g.updateScale()});var n;return e.offset?n=c(e.offset,d):n={x:0,y:0,z:0},o=q.coordinates,!1})},e.prototype.traverArray=function(a,c,d){for(var b in a)if(typeof a[b][0]!=='object'){this.pts2Mesh.bind(this)(a,c,d);break}else this.traverArray.bind(this)(a[b],c,d)},e.prototype.pts2Mesh=function(k,d,i){var l=this.projection,e=this.pts2MeshGeo(k,d);if(e){var h=this.three3D,b=e.fillGeometry,f=e.strokeGeometry;if(b){var c=d.material;if(!c)return;var a;typeof c==='function'?(a=c(b),b.buffersNeedUpdate=!0,b.uvsNeedUpdate=!0,b.computeFaceNormals()):typeof c==='object'&&(a=new g.Mesh(b,c)),a.position.set(i.x,i.y,i.z),h.add(a),d.fillMesh.push(a)}if(f){var j=d.strokeMaterial;f.computeLineDistances();var a;a=new g.Line(f,j),a.position.set(0,0,0),h.add(a),d.strokeMesh.push(a)}}},e.prototype.pts2MeshGeo=function(r,E){var A=this.projection,m=this.options,q=m.shape,C=q.stroke,D=q.fill,k=q.divide,s=new g.Shape,j=[],b,w,f,h,x,B=m.lat,z=m.lng,t=1e-5,u=1e-5,n,o;if(r.length<3)return console.log('less 3pts');for(var e=0;e<r.length;e++)n=B(r[e]),k&&(n=i(n,k)),o=z(r[e]),k&&(o=i(o,k)),b=A.project({lng:o,lat:n},m.ratio),w=l.project({lng:o,lat:n}),f=w.x,h=w.z,x=!a(f)&&!a(h),e===0&&x&&(s.moveTo(-h,-f),j.push(b),t=f,u=h),e!==0&&(t!==f||u!==h)&&x&&(s.lineTo(-h,-f),j.push(b),t=f,u=h);var p,d;if(j.length){var v,y;if(D){y=new g.ShapeGeometry(s),p=y.vertices;for(var c=0;c<p.length;c++)b=j[c],d=p[c],d&&b&&(d.x=b.x,d.z=b.z,d.y=b.y)}if(C){v=new g.Geometry,p=v.vertices;for(var c=0;c<j.length;c++)b=j[c],d=new g.Vector3,d.x=b.x,d.z=b.z,d.y=b.y,p.push(d)}return{strokeGeometry:v,fillGeometry:y}}return!1},e.prototype.hide=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!1;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!1})},e.prototype.show=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!0;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!0})},e.prototype.updateScale=function(){var a,b=this.options.ratio;this.each(function(d){if(a=d.fillMesh,a)for(var c in a)a[c].scale.set(b,b,b);if(a=d.strokeMesh,a)for(var c in a)a[c].scale.set(b,b,b)})},e.prototype.fillFunc=function(d,e){var b=this,c=this.options,f=c.shape.fill.url,h=c.shape.fill.mediumUrl,i=c.shape.fill.smallUrl,a=new g.TextureLoader;a.setCrossOrigin('*'),a.crossOrigin='*',a.load(f,function(c){a.load(i,function(f){a.load(h,function(a){var h=new g.MeshBasicMaterial({map:c,side:g.DoubleSide,overdraw:!0,blending:g.AdditiveBlending});c.minFilter=g.LinearFilter,c.wrapS=c.wrapT=g.RepeatWrapping,h.map.needsUpdate=!0;var i=new g.MeshBasicMaterial({map:a,side:g.DoubleSide,overdraw:!0,blending:g.AdditiveBlending});a.minFilter=g.LinearFilter,a.wrapS=a.wrapT=g.RepeatWrapping,i.map.needsUpdate=!0;var j=new g.MeshBasicMaterial({map:f,side:g.DoubleSide,overdraw:!0,blending:g.AdditiveBlending});f.minFilter=g.LinearFilter,f.wrapS=f.wrapT=g.RepeatWrapping,j.map.needsUpdate=!0,d.material=function(a){if(a.faces.length<70){var c=new g.Mesh(a,j);return b.uvGenerator(a),c}else if(a.faces.length>100){var c=new g.Mesh(a,h);return b.uvGenerator(a),c}else{var c=new g.Mesh(a,i);return b.uvGenerator(a),c}},e&&e(d)})})})},e.prototype.uvGenerator=function(a){a.computeBoundingBox();var i=a.boundingBox.max,f=a.boundingBox.min,o=i.x,q=i.y,p=i.z,d=f.x,r=f.y,c=f.z,j=o-d,e=p-c,l=new g.Vector2(0,0),m=new g.Vector2(0,0),n=new g.Vector2(0,0);a.faceVertexUvs[0]=[];for(var k=0;k<a.faces.length;++k){var h=a.faces[k],b=a.vertices[h.a];l.set((b.z-c)/e,(b.x-d)/j),b=a.vertices[h.b],m.set((b.z-c)/e,(b.x-d)/j),b=a.vertices[h.c],n.set((b.z-c)/e,(b.x-d)/j),a.faceVertexUvs[0].push([l.clone(),m.clone(),n.clone()])}a.uvsNeedUpdate=!0},e.prototype.update=function(){this.updateFill(),this.updateStroke()},e.prototype.updateFill=function(){var a=this.options,b=a.shape,c=a.value,d=b.fill;return void 0},e.prototype.updateStroke=function(){var k=this.options.shape,b=k.stroke;if(!b)return;var r=b.color,e=this.geo,p=this._data;for(var h in e){var j=e[h],l=p[h],i=j.strokeMesh;for(var m in i){var o=i[m],c=o.material,q=f(r,l),d=new g.Color(q);c.color.setRGB(d.r,d.g,d.b);var a=b.opacity;(a===null||a===undefined)&&(a=1),c.opacity=a,c.linewidth=n(b.linewidth)}}},e.prototype.updateOptions=function(a){this.options=b.deepMerge(this.options,a),this.updateStroke(),this.updateFill(),this.updateScale()},e.prototype.each=function(d){var a=this.geo;for(var b in a){var c=a[b];d(c)}},e.prototype.genStroke=function(a){if(typeof a==='function')return a;var c=this.options.shape.stroke,h=a.type||'default',d=a.color||16777215,b=a.opacity,e=a.width||a.linewidth||.01,f=b?!0:!1;return{dash:function(a){a.strokeMaterial=new g.LineDashedMaterial({linewidth:e,color:d,dashSize:c.dashSize,gapSize:c.gapSize,transparent:f,opacity:b,linejoin:'round',linecap:'round'})},default:function(a){a.strokeMaterial=new g.LineBasicMaterial({linewidth:e,color:d,transparent:f,opacity:b,linejoin:'round',linecap:'round'})}}[h]},e.prototype.loop=function(){},e.prototype.geojson=e.prototype.geoJson,module.exports=e |
@@ -1,1 +0,1 @@ | ||
'use strict';function e(a,b){return typeof a==='function'?a(arguments[1],arguments[2],arguments[3],arguments[4]):a}function h(a,b,c){return typeof a==='function'?a(b,c):a}function n(a,b){return typeof a==='function'?a(b):a}function m(d,e){var c=d.faces,a=j.parse(e).arr;setTimeout(function(){var g;for(var e=0;e<c.length;e++){var g=c[e],h=Math.abs(Math.cos(e/10)),f=new b.Color('rgb('+a[0]+', '+Math.floor(a[1]+h*30)+', '+Math.floor(a[2]+50*h)+')');g.vertexColors.push(f,f,f)}d.colorsNeedUpdate=!0},10)}function a(b){this.options=c.deepMerge(a.options,b)}function d(a){return a===undefined?!1:!0}var b=require('three'),c=require('./../core/utils'),g=c.divideby,i=c.traver,d=c.isNone,j=c.format,k=require('./../map/projection/mecator'),f=c.getColorFunc,l=c.switchValue;a.options={geoid:function(b){if(b.id)return b.id;var a=b.properties;return a?a.id||a.adcode:void 0},lat:function(a){return a[1]},lng:function(a){return a[0]},value:function(a){return a&&a.value?a.value||0:a},id:function(a,b){return a.id||a.adcode||b},offset:function(){return{x:0,y:0,z:0}},ratio:1,shape:{fill:{transparent:!1,type:'flat',colorBack:2236962,hue:360,colorFront:'#07c',opacity:1},stroke:null}},a.prototype.addTo=function(a){this._map=a,this.projection=a.projection,this.three3D=a.three3D},a.prototype.render=function(a){a&&this.data(a),this.draw()},a.prototype.data=function(a){if(!a)return;this.processing(a)},a.prototype.processing=function(f){var b,c,a,k,g,i=this.options.value,j=this.options.id,h={};for(var e in f)g=f[e],k=j(g,e),a=i(f[e]),h[k]=g,c=d(c)?a:c,b=d(b)?a:b,a>c&&(c=a),a<b&&(b=a);this.vMax=c,this.vMin=b,this._data=h},a.prototype.draw=function(){var a=this._data,c=this.options.id,d=this.geo,g,e,f;for(var b in a)e=a[b],f=c(e,b),g=d[f];this.updateFill(),this.updateStroke()},a.prototype.geoJson=function(p){var d=this.options;if(!p)return console.log('没有geojson');var g=this.options.shape,m=this.projection,e=g.fill;if(e)var l=this.genFill(e);var f=g.stroke;if(f)var k=this.genStroke(f);var h=this.geo=this.geo||{},c,j,o,b,a,q=this.traverArray.bind(this);i(p,function(u,r,g){if(u!=='geometry')return!0;if(j=d.geoid(g),a=h[j]=h[j]||{},c=g.properties,b=r.coordinate||g.cp||c.cp||c.coordinate,b){a.cp=b;var s=b.lat||b[0],t=b.lng||b[1];a.cp3D=m.project({lng:t,lat:s},1)}var i=c.cName||c.name;i&&(a.cName=i),e&&(l(a),a.fillMesh=[]),f&&(k(a),a.strokeMesh=[]);var p;return d.offset?p=n(d.offset,c):p={x:0,y:0,z:0},o=r.coordinates,q(o,a,p),!1}),this.updateScale()},a.prototype.traverArray=function(a,c,d){for(var b in a)if(typeof a[b][0]!=='object'){this.pts2Mesh.bind(this)(a,c,d);break}else this.traverArray.bind(this)(a[b],c,d)},a.prototype.pts2Mesh=function(l,d,i){var j=this.projection,e=this.pts2MeshGeo(l,d);if(e){var h=this.three3D,f=e.fillGeometry,g=e.strokeGeometry;if(f){var c=d.material;if(!c)return;j.type==='sphere';var a;typeof c==='function'?a=c(f):typeof c==='object'&&(a=new b.Mesh(f,c)),a.position.set(i.x,i.y,i.z),h.add(a),d.fillMesh.push(a)}if(g){var k=d.strokeMaterial;g.computeLineDistances();var a;a=new b.Line(g,k),a.position.set(0,0,0),h.add(a),d.strokeMesh.push(a)}}},a.prototype.pts2MeshGeo=function(s,E){var D=this.projection,n=this.options,r=n.shape,C=r.stroke,B=r.fill,l=r.divide,q=new b.Shape,f=[],a,y,j,h,x,A=n.lat,z=n.lng,t=1e-5,u=1e-5,p,o;if(s.length<3)return console.log('less 3pts');for(var i=0;i<s.length;i++)p=A(s[i]),l&&(p=g(p,l)),o=z(s[i]),l&&(o=g(o,l)),a=D.project({lng:o,lat:p},n.ratio),y=k.project({lng:o,lat:p}),j=y.x,h=y.z,x=!d(j)&&!d(h),i===0&&x&&(q.moveTo(-h,-j),f.push(a),t=j,u=h),i!==0&&(t!==j||u!==h)&&x&&(q.lineTo(-h,-j),f.push(a),t=j,u=h);var m,c;if(f.length){if(B){var w=new b.ShapeGeometry(q);m=w.vertices;for(var e=0;e<m.length;e++)a=f[e],c=m[e],c&&a&&(c.x=a.x,c.z=a.z,c.y=a.y)}if(C){var v=new b.Geometry;m=v.vertices;for(var e=0;e<f.length;e++)a=f[e],c=new b.Vector3,c.x=a.x,c.z=a.z,c.y=a.y,m.push(c)}return{strokeGeometry:v,fillGeometry:w}}return!1},a.prototype.hide=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!1;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!1})},a.prototype.show=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!0;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!0})},a.prototype.updateScale=function(){var a,b=this.options.ratio;this.each(function(d){if(a=d.fillMesh,a)for(var c in a)a[c].scale.set(b,b,b);if(a=d.strokeMesh,a)for(var c in a)a[c].scale.set(b,b,b)})},a.prototype.genFill=function(a){if(typeof a==='function')return a;var g=this.options,j=this.projection,d=a.opacity,f={transparent:g.shape.fill.transparent},k=e(a.colorBack,0),l=e(a.colorFront,0);d=h(a.opacity,0);var n=c.extend({color:k,side:b.BackSide,vertexColors:b.VertexColors,opacity:d},f),o=c.extend({wireframe:!1,opacity:d,color:l,side:b.FrontSide,vertexColors:b.VertexColors},f),i=(a?a.type:'none')||'none';return{triangle:function(a){a.material=function(a){j.type==='mecator'&&m(a,g.shape.fill.colorFront);var c=new b.MeshPhongMaterial({vertexColors:b.VertexColors}),d=new b.MeshPhongMaterial({vertexColors:b.VertexColors});return b.SceneUtils.createMultiMaterialObject(a,[c,d])}},none:function(a){return a},flat:function(d){var a=new b.MeshBasicMaterial(n),c=new b.MeshBasicMaterial(o);d.material=function(d){return b.SceneUtils.createMultiMaterialObject(d,[a,c])}}}[i]},a.prototype.update=function(){this.updateFill(),this.updateStroke()},a.prototype.updateFill=function(){var q=this.options,C=q.shape,B=q.value,c=C.fill;if(!c)return;var A=f(c.colorFront),z=f(c.colorBack),w=this.vMax,l=this.vMin,t=this._data||{},n=this.geo;for(var o in n){var p=n[o],r=p.fillMesh,d=t[o],a=B(d);a&&(a=(a-l)/(w-l));var y=A(a,d),u=z(a,d);for(var v in r){var k=r[v],x=k.children[0],s=k.children[1],j=x.material,i=s.material,m=h(c.opacity,d,p),g=new b.Color(u);j.color.setRGB(g.r,g.g,g.b),j.opacity=m;var e=new b.Color(y);i.color.setRGB(e.r,e.g,e.b),i.opacity=m}}},a.prototype.updateStroke=function(){var k=this.options.shape,c=k.stroke;if(!c)return;var r=c.color,g=this.geo,p=this._data;for(var h in g){var j=g[h],m=p[h],i=j.strokeMesh;for(var n in i){var o=i[n],d=o.material,q=e(r,m),f=new b.Color(q);d.color.setRGB(f.r,f.g,f.b);var a=c.opacity;(a===null||a===undefined)&&(a=1),d.opacity=a,d.linewidth=l(c.linewidth)}}},a.prototype.updateOptions=function(a){this.options=c.deepMerge(this.options,a),this.updateStroke(),this.updateFill(),this.updateScale()},a.prototype.each=function(d){var a=this.geo;for(var b in a){var c=a[b];d(c)}},a.prototype.genStroke=function(a){if(typeof a==='function')return a;var d=this.options.shape.stroke,h=a.type||'default',e=a.color||16777215,c=a.opacity,f=a.width||a.linewidth||.01,g=c?!0:!1;return{dash:function(a){a.strokeMaterial=new b.LineDashedMaterial({linewidth:f,color:e,dashSize:d.dashSize,gapSize:d.gapSize,transparent:g,opacity:c,linejoin:'round',linecap:'round'})},default:function(a){a.strokeMaterial=new b.LineBasicMaterial({linewidth:f,color:e,transparent:g,opacity:c,linejoin:'round',linecap:'round'})}}[h]},a.prototype.loop=function(){},a.prototype.remove=function(){var a,b,c,d=this.three3D;this.each(function(f){if(a=f.fillMesh,a)for(var e in a)c=a[e],d.remove(c),c&&c.children&&c.children.forEach(function(a){d.remove(a),a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose()});if(a=f.strokeMesh,a)for(var e in a)b=a[e],d.remove(b),b.dispose&&b.dispose(),b.material&&b.material.dispose(),b.geometry&&b.geometry.dispose()}),a=null,b=null},a.prototype.geojson=a.prototype.geoJson,module.exports=a | ||
'use strict';function f(a,b){return typeof a==='function'?a(arguments[1],arguments[2],arguments[3],arguments[4]):a}function h(a,b,c){return typeof a==='function'?a(b,c):a}function c(a,b){return typeof a==='function'?a(b):a}function d(c,d){var b=c.faces,a=k.parse(d).arr;setTimeout(function(){var f;for(var d=0;d<b.length;d++){var f=b[d],h=Math.abs(Math.cos(d/10)),e=new g.Color('rgb('+a[0]+', '+Math.floor(a[1]+h*30)+', '+Math.floor(a[2]+50*h)+')');f.vertexColors.push(e,e,e)}c.colorsNeedUpdate=!0},10)}function e(a){this.options=b.deepMerge(e.options,a)}function a(a){return a===undefined?!1:!0}var g=require('three'),b=require('./../core/utils'),i=b.divideby,j=b.traver,a=b.isNone,k=b.format,l=require('./../map/projection/mecator'),m=b.getColorFunc,n=b.switchValue;e.options={geoid:function(b){if(b.id)return b.id;var a=b.properties;return a?a.id||a.adcode:void 0},lat:function(a){return a[1]},lng:function(a){return a[0]},value:function(a){return a&&a.value?a.value||0:a},id:function(a,b){return a.id||a.adcode||b},offset:function(){return{x:0,y:0,z:0}},ratio:1,shape:{fill:{transparent:!1,type:'flat',colorBack:2236962,hue:360,colorFront:'#07c',opacity:1},stroke:null}},e.prototype.addTo=function(a){this._map=a,this.projection=a.projection,this.three3D=a.three3D},e.prototype.render=function(a){a&&this.data(a),this.draw()},e.prototype.data=function(a){if(!a)return;this.processing(a)},e.prototype.processing=function(f){var c,d,b,k,g,i=this.options.value,j=this.options.id,h={};for(var e in f)g=f[e],k=j(g,e),b=i(f[e]),h[k]=g,d=a(d)?b:d,c=a(c)?b:c,b>d&&(d=b),b<c&&(c=b);this.vMax=d,this.vMin=c,this._data=h},e.prototype.draw=function(){var a=this._data,c=this.options.id,d=this.geo,g,e,f;for(var b in a)e=a[b],f=c(e,b),g=d[f];this.updateFill(),this.updateStroke()},e.prototype.geoJson=function(p){var e=this.options;if(!p)return console.log('没有geojson');var h=this.options.shape,n=this.projection,f=h.fill;if(f)var m=this.genFill(f);var g=h.stroke;if(g)var l=this.genStroke(g);var i=this.geo=this.geo||{},d,k,o,b,a,q=this.traverArray.bind(this);j(p,function(u,r,h){if(u!=='geometry')return!0;if(k=e.geoid(h),a=i[k]=i[k]||{},d=h.properties,b=r.coordinate||h.cp||d.cp||d.coordinate,b){a.cp=b;var s=b.lat||b[0],t=b.lng||b[1];a.cp3D=n.project({lng:t,lat:s},1)}var j=d.cName||d.name;j&&(a.cName=j),f&&(m(a),a.fillMesh=[]),g&&(l(a),a.strokeMesh=[]);var p;return e.offset?p=c(e.offset,d):p={x:0,y:0,z:0},o=r.coordinates,q(o,a,p),!1}),this.updateScale()},e.prototype.traverArray=function(a,c,d){for(var b in a)if(typeof a[b][0]!=='object'){this.pts2Mesh.bind(this)(a,c,d);break}else this.traverArray.bind(this)(a[b],c,d)},e.prototype.pts2Mesh=function(l,c,i){var j=this.projection,d=this.pts2MeshGeo(l,c);if(d){var h=this.three3D,e=d.fillGeometry,f=d.strokeGeometry;if(e){var b=c.material;if(!b)return;j.type==='sphere';var a;typeof b==='function'?a=b(e):typeof b==='object'&&(a=new g.Mesh(e,b)),a.position.set(i.x,i.y,i.z),h.add(a),c.fillMesh.push(a)}if(f){var k=c.strokeMaterial;f.computeLineDistances();var a;a=new g.Line(f,k),a.position.set(0,0,0),h.add(a),c.strokeMesh.push(a)}}},e.prototype.pts2MeshGeo=function(s,E){var D=this.projection,n=this.options,r=n.shape,C=r.stroke,B=r.fill,k=r.divide,q=new g.Shape,e=[],b,y,j,f,x,A=n.lat,z=n.lng,t=1e-5,u=1e-5,p,o;if(s.length<3)return console.log('less 3pts');for(var h=0;h<s.length;h++)p=A(s[h]),k&&(p=i(p,k)),o=z(s[h]),k&&(o=i(o,k)),b=D.project({lng:o,lat:p},n.ratio),y=l.project({lng:o,lat:p}),j=y.x,f=y.z,x=!a(j)&&!a(f),h===0&&x&&(q.moveTo(-f,-j),e.push(b),t=j,u=f),h!==0&&(t!==j||u!==f)&&x&&(q.lineTo(-f,-j),e.push(b),t=j,u=f);var m,c;if(e.length){if(B){var w=new g.ShapeGeometry(q);m=w.vertices;for(var d=0;d<m.length;d++)b=e[d],c=m[d],c&&b&&(c.x=b.x,c.z=b.z,c.y=b.y)}if(C){var v=new g.Geometry;m=v.vertices;for(var d=0;d<e.length;d++)b=e[d],c=new g.Vector3,c.x=b.x,c.z=b.z,c.y=b.y,m.push(c)}return{strokeGeometry:v,fillGeometry:w}}return!1},e.prototype.hide=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!1;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!1})},e.prototype.show=function(){var a;this.each(function(c){if(a=c.fillMesh,a)for(var b in a)a[b].visible=!0;if(a=c.strokeMesh,a)for(var b in a)a[b].visible=!0})},e.prototype.updateScale=function(){var a,b=this.options.ratio;this.each(function(d){if(a=d.fillMesh,a)for(var c in a)a[c].scale.set(b,b,b);if(a=d.strokeMesh,a)for(var c in a)a[c].scale.set(b,b,b)})},e.prototype.genFill=function(a){if(typeof a==='function')return a;var i=this.options,k=this.projection,c=a.opacity,e={transparent:i.shape.fill.transparent},l=f(a.colorBack,0),m=f(a.colorFront,0);c=h(a.opacity,0);var n=b.extend({color:l,side:g.BackSide,vertexColors:g.VertexColors,opacity:c},e),o=b.extend({wireframe:!1,opacity:c,color:m,side:g.FrontSide,vertexColors:g.VertexColors},e),j=(a?a.type:'none')||'none';return{triangle:function(a){a.material=function(a){k.type==='mecator'&&d(a,i.shape.fill.colorFront);var b=new g.MeshPhongMaterial({vertexColors:g.VertexColors}),c=new g.MeshPhongMaterial({vertexColors:g.VertexColors});return g.SceneUtils.createMultiMaterialObject(a,[b,c])}},none:function(a){return a},flat:function(c){var a=new g.MeshBasicMaterial(n),b=new g.MeshBasicMaterial(o);c.material=function(c){return g.SceneUtils.createMultiMaterialObject(c,[a,b])}}}[j]},e.prototype.update=function(){this.updateFill(),this.updateStroke()},e.prototype.updateFill=function(){var q=this.options,C=q.shape,B=q.value,b=C.fill;if(!b)return;var A=m(b.colorFront),z=m(b.colorBack),w=this.vMax,k=this.vMin,t=this._data||{},n=this.geo;for(var o in n){var p=n[o],r=p.fillMesh,c=t[o],a=B(c);a&&(a=(a-k)/(w-k));var y=A(a,c),u=z(a,c);for(var v in r){var j=r[v],x=j.children[0],s=j.children[1],i=x.material,f=s.material,l=h(b.opacity,c,p),e=new g.Color(u);i.color.setRGB(e.r,e.g,e.b),i.opacity=l;var d=new g.Color(y);f.color.setRGB(d.r,d.g,d.b),f.opacity=l}}},e.prototype.updateStroke=function(){var k=this.options.shape,b=k.stroke;if(!b)return;var r=b.color,e=this.geo,p=this._data;for(var h in e){var j=e[h],l=p[h],i=j.strokeMesh;for(var m in i){var o=i[m],c=o.material,q=f(r,l),d=new g.Color(q);c.color.setRGB(d.r,d.g,d.b);var a=b.opacity;(a===null||a===undefined)&&(a=1),c.opacity=a,c.linewidth=n(b.linewidth)}}},e.prototype.updateOptions=function(a){this.options=b.deepMerge(this.options,a),this.updateStroke(),this.updateFill(),this.updateScale()},e.prototype.each=function(d){var a=this.geo;for(var b in a){var c=a[b];d(c)}},e.prototype.genStroke=function(a){if(typeof a==='function')return a;var c=this.options.shape.stroke,h=a.type||'default',d=a.color||16777215,b=a.opacity,e=a.width||a.linewidth||.01,f=b?!0:!1;return{dash:function(a){a.strokeMaterial=new g.LineDashedMaterial({linewidth:e,color:d,dashSize:c.dashSize,gapSize:c.gapSize,transparent:f,opacity:b,linejoin:'round',linecap:'round'})},default:function(a){a.strokeMaterial=new g.LineBasicMaterial({linewidth:e,color:d,transparent:f,opacity:b,linejoin:'round',linecap:'round'})}}[h]},e.prototype.loop=function(){},e.prototype.remove=function(){var a,b,c,d=this.three3D;this.each(function(f){if(a=f.fillMesh,a)for(var e in a)c=a[e],d.remove(c),c&&c.children&&c.children.forEach(function(a){d.remove(a),a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose()});if(a=f.strokeMesh,a)for(var e in a)b=a[e],d.remove(b),b.dispose&&b.dispose(),b.material&&b.material.dispose(),b.geometry&&b.geometry.dispose()}),a=null,b=null},e.prototype.geojson=e.prototype.geoJson,module.exports=e |
@@ -1,1 +0,1 @@ | ||
function b(a){a=this.options=c.deepMerge(b.options,a),this.initialize(a)}var e=require('leaflet'),a=require('three'),d=require('bcore/event'),c=require('bcore/utils');b.options={simplify:{limit:7e-5},polygon:function(a){return a.latlngs},id:function(a,b){return a.id||b},height:function(a){return a.floor*4},isRenderShape:function(a){return a.floor===1},faceColor:function(c){var b=Math.min(-c.height/100,1);return b>.8?new a.Color('rgb(200,0,0)'):new a.Color('rgb(0,150,250)')},material:{color:'#999',emissive:'#222',specular:'#111',opacity:1}},b=d.extend(b,{initialize:function(a){},addTo:function(a){this._map=a,this.project=a.projection.project.bind(a.projection),this.three3D=a.three3D,this.initEvents()},data:function(a){this._data=a},drawBuilding:function(c){var e=this._map,f=this.options;if(!e)return;var g=this.geometry=new a.Geometry;c&&this.data(c),this.faceIndex=0,this.objects={};var d=0;for(var h in c)this.renderOne(c[h],d),d++;var b=f.material,i=this.material=new a.MeshPhongMaterial({color:b.color,vertexColors:a.FaceColors,side:a.DoubleSide,emissive:b.emissive,specular:b.specular,opacity:b.opacity,transparent:!0}),j=this.mesh=new a.Mesh(g,i);this.three3D.add(j)},renderOne:function(g,y){var i=this.options,s=i.simplify,o=s.limit,x=i.polygon,p=i.height,t=this.project,w=-p(g);g.height=w;var k=x(g),f,c,h=[],e,d,q,r,l,m,u,v,n,j;for(var b=0;b<k.length;b++){if(f=k[b],!f)continue;if(n=f.lat,j=f.lng,b===0&&(u=n,v=j),Math.abs(n-u)+Math.abs(j-v)<o&&b!==0)continue;if(c=t(f),e=c.x,d=c.z,b===0&&(l=e,m=d),e===q&&d===r)continue;c=new a.Vector2(e-l,d-m),h.push(c),q=e,r=d}h.length>=3&&this.createExtrudeGeometry(g,h,l,m,y)},createExtrudeGeometry:function(b,t,s,r,q){var c=this.options,i=c.id,j=c.isRenderShape(b),d,e=this.geometry,f=new a.Shape(t);j?d=new a.ShapeGeometry(f):d=new a.ExtrudeGeometry(f,{amount:b.height,steps:1,material:0,extrudeMaterial:1,bevelEnabled:!1});var n=d.faces,o=c.faceColor(b);n.forEach(function(a){a.color=o});var p=i(b,q),g=new a.Matrix4().makeRotationX(Math.PI/2),m=new a.Matrix4().makeTranslation(s,0,r),l=new a.Matrix4().multiply(m).multiply(g);e.merge(d,l);var k=this.fadeIndex,h=this.fadeIndex=e.faces.length;this.objects[p]={range:[k,h],data:b}},setBuildingColor:function(e,f){var c=this.geometry,b=this.objects[e].range,d=c.faces;for(var a=b[0];a<b[1];a++)d[a].color=f},updateFaceColor:function(){console.log(this.geometry);var e=this.objects,c,j,d,b,g,h,i=this.options.faceColor,f=this.geometry,k=f.faces;for(var l in e){c=e[l],j=c.data,d=c.range,g=d[0],h=d[1];for(var a=g;a<h;a++)b=i(j),k[a].color.setRGB(b.r,b.g,b.b)}f.colorsNeedUpdate=!0},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.updateMaterial(a.material),this.updateFaceColor()},updateMaterial:function(c){var b=this.material;b.color=new a.Color(c.color),b.emissive=new a.Color(c.emissive),b.specular=new a.Color(c.specular),b.opacity=c.opacity},initEvents:function(){}}),module.exports=b | ||
function a(b){b=this.options=e.deepMerge(a.options,b),this.initialize(b)}var b=require('leaflet'),c=require('three'),d=require('bcore/event'),e=require('bcore/utils');a.options={simplify:{limit:7e-5},polygon:function(a){return a.latlngs},id:function(a,b){return a.id||b},height:function(a){return a.floor*4},isRenderShape:function(a){return a.floor===1},faceColor:function(b){var a=Math.min(-b.height/100,1);return a>.8?new c.Color('rgb(200,0,0)'):new c.Color('rgb(0,150,250)')},material:{color:'#999',emissive:'#222',specular:'#111',opacity:1}},a=d.extend(a,{initialize:function(a){},addTo:function(a){this._map=a,this.project=a.projection.project.bind(a.projection),this.three3D=a.three3D,this.initEvents()},data:function(a){this._data=a},drawBuilding:function(b){var e=this._map,f=this.options;if(!e)return;var g=this.geometry=new c.Geometry;b&&this.data(b),this.faceIndex=0,this.objects={};var d=0;for(var h in b)this.renderOne(b[h],d),d++;var a=f.material,i=this.material=new c.MeshPhongMaterial({color:a.color,vertexColors:c.FaceColors,side:c.DoubleSide,emissive:a.emissive,specular:a.specular,opacity:a.opacity,transparent:!0}),j=this.mesh=new c.Mesh(g,i);this.three3D.add(j)},renderOne:function(g,y){var i=this.options,s=i.simplify,o=s.limit,x=i.polygon,p=i.height,t=this.project,w=-p(g);g.height=w;var k=x(g),f,b,h=[],e,d,q,r,l,m,u,v,n,j;for(var a=0;a<k.length;a++){if(f=k[a],!f)continue;if(n=f.lat,j=f.lng,a===0&&(u=n,v=j),Math.abs(n-u)+Math.abs(j-v)<o&&a!==0)continue;if(b=t(f),e=b.x,d=b.z,a===0&&(l=e,m=d),e===q&&d===r)continue;b=new c.Vector2(e-l,d-m),h.push(b),q=e,r=d}h.length>=3&&this.createExtrudeGeometry(g,h,l,m,y)},createExtrudeGeometry:function(a,t,s,r,q){var b=this.options,i=b.id,j=b.isRenderShape(a),d,e=this.geometry,f=new c.Shape(t);j?d=new c.ShapeGeometry(f):d=new c.ExtrudeGeometry(f,{amount:a.height,steps:1,material:0,extrudeMaterial:1,bevelEnabled:!1});var n=d.faces,o=b.faceColor(a);n.forEach(function(a){a.color=o});var p=i(a,q),g=new c.Matrix4().makeRotationX(Math.PI/2),m=new c.Matrix4().makeTranslation(s,0,r),l=new c.Matrix4().multiply(m).multiply(g);e.merge(d,l);var k=this.fadeIndex,h=this.fadeIndex=e.faces.length;this.objects[p]={range:[k,h],data:a}},setBuildingColor:function(e,f){var c=this.geometry,b=this.objects[e].range,d=c.faces;for(var a=b[0];a<b[1];a++)d[a].color=f},updateFaceColor:function(){console.log(this.geometry);var e=this.objects,c,j,d,b,g,h,i=this.options.faceColor,f=this.geometry,k=f.faces;for(var l in e){c=e[l],j=c.data,d=c.range,g=d[0],h=d[1];for(var a=g;a<h;a++)b=i(j),k[a].color.setRGB(b.r,b.g,b.b)}f.colorsNeedUpdate=!0},updateOptions:function(a){a=this.options=e.deepMerge(this.options,a),this.updateMaterial(a.material),this.updateFaceColor()},updateMaterial:function(b){var a=this.material;a.color=new c.Color(b.color),a.emissive=new c.Color(b.emissive),a.specular=new c.Color(b.specular),a.opacity=b.opacity},initEvents:function(){}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function o(a){return a===undefined||a===null}function g(a){if(typeof a==='string'&&a.indexOf(',')!==-1){a=a.split(',');var b=+a[1]||0,c=+a[0]||0;return{lat:b,lng:c}}return a}function m(a,b,c,d){return a+(b-a)*c}function e(d,e,a,b){b=b||1;var c=a*a;return a=3*c-2*c*a,a=Math.pow(a,b),d+(e-d)*a}function a(a){this.updateOptions(a);var b=this.id='flyingline_'+Math.floor(Math.random()*1e9);this.reset()}var c=require('./../core/utils'),f=require('bcore/event'),b=require('three'),i=c.mercator,j=c.sphere,k=c.requestAnimationFrame,l=c.cancelAnimationFrame,h=require('./cube_utils'),d={cube:h(),smooth:function(d){var g=this.options,a=this.ptFrom,c=this.ptTo,f=g.flying.indensty,h=e(a.x,c.x,d,f),i=m(a.y,c.y,d),j=e(a.z,c.z,d,f);return new b.Vector3(h,i,j)},flying:function(a){var b=this.options,c=b.flying,d=c.kHeight+(this.kHeightJitter||0),e=this.ptFrom,f=this.ptTo,g=this._getNormal(),h=(1-a)*a*d*this.distance,i=e.clone().lerp(f,a).add(g.multiplyScalar(h));return i}};a.options={ptN:10,range:.8,isUpdateWhenEndStart:!0,flying:{kHeight:2,kHeightJitter:.2,weight:2,style:{hue:.5,opacity:.2,color:function(a){var c=.5;return new b.Color().setHSL(c,1-a*.3,.3+Math.pow(a,8)*.6)}}},type:'flying',lifeSpeed:.002,delay:0,delayEnd:1,lifeMin:0,lifeMax:1,endType:'explodePts'},a=f.extend(a,{updateOptions:function(b){b=this.options=c.deepMerge(this.options||a.options,b),typeof b.lifeSpeed==='function'&&(b.lifeSpeed=b.lifeSpeed()),typeof b.delay==='function'&&(b.delay=b.delay());var e=b.type;this._getPt=(d[e]||d.flying).bind(this)},setLine:function(a,b){this.lineMerge=a,this.lineIndex=b},addTo:function(a){this._map=a;var c=this.three3D=a.three3D,b=this.projection=a.projection;this.setNormal(b)},checkStatus:function(){if(this.status==='end')return;var b=this.life,a=this.options,c=a.flying.range,d=a.delayEnd;return b<a.lifeMin?this.status='pre-living':b<=a.lifeMax?this.status='living':(b<=a.lifeMax+c?this.status='lifeend-start':this.status='lifeend-done',b>a.lifeMax+d?this.end():this.status)},setNormal:function(a){var c=a.type;if(c==='mecator'||c==='plane'||c==='origin'){var d=this._center=new b.Vector3(a.x0,a.y0,a.z0);this._getNormal=function(){return new b.Vector3(0,1,0)}}else if(c==='sphere'){var d=this._center=new b.Vector3(a.x0,a.y0,a.z0);this._getNormal=function(c){var a=c||this.ptFrom,b=this.ptTo;return a&&b?a.clone().lerp(b,.5).sub(d).normalize():void 0}}},data:function(b){if(!b)return;this._data=b;var c=g(b.to),a=g(b.from),d=b.cubeCenter,e=!a||!c||(!a.lat||!c.lat)&&(a.x===null||a.x===undefined),i=!d;if(i&&e)return this.end();if(!e){var f=this.ptFrom=this.projection.project(a),h=this.ptTo=this.projection.project(c);if(this.distance=f.distanceTo(h),!(f&&h))return this.end()}d&&(this.cubeCenter=d),this.reset(),this.emit('start')}}),a.prototype._getPt=function(a){},a.prototype.update=function(){if(!(this.lineMerge&&this._map))return;var b=this.options;this.life+=b.lifeSpeed;var c=b.endType,a=this.checkStatus();a==='pre-living'||a==='living'?this.updateLine():a==='lifeend-start'&&(b.isUpdateWhenEndStart&&this.updateLine(),this.pStatus==='living'&&this.emit('flying-end',{data:this._data,lineIndex:this.lineIndex})),this.pStatus=a},a.prototype.equalTo=function(a){return this.lineIndex===a.lineIndex},a.prototype.end=function(){this.status='end',this.emit('end');var b=this.options,c=b.ptN,d=this.lineMerge,e=this.lineIndex;for(var a=0;a<c;a++)d.setPt(e,a,0,0,0)};var n=0;a.prototype.resetLine=function(){var c=this.lineMerge,f=this.lineIndex,j=this._data;if(!c)return;var b=this.options.flying.style,h=b.color.bind(b),a=this.options.ptN;for(var d=0;d<a;d++)c.setPt(f,d,0,0,0);a=(a-1)*2;var g=[];for(var e=0;e<a;e++){var i=h(j,e/(a-1));g.push(i)}c.setColorArray(f,g,b.opacity)},a.prototype.updateLine=function(){var h=this.options,k=h.flying,b=k.range,g=h.ptN,i=this.lineMerge,j=this.lineIndex,a=this.life,e,f;for(var c=0;c<g;c++){var d=c/g;if(b>a)e=(1-d)*a;else if(a<1)e=a-d*b;else if(a>1&&a<1+b)e=1-(b-a+1)*d;else return;f=this._getPt(e),i.setPt(j,c,f.x,f.y,f.z)}},a.prototype.reset=function(){var a=this.options;this.status='ready',this.life=a.lifeMin-a.delay,this.targetList=null,this.kHeightJitter=a.flying.kHeight*a.flying.kHeightJitter*Math.random(),this.resetLine()},module.exports=a | ||
'use strict';function b(a){return a===undefined||a===null}function h(a){if(typeof a==='string'&&a.indexOf(',')!==-1){a=a.split(',');var b=+a[1]||0,c=+a[0]||0;return{lat:b,lng:c}}return a}function c(a,b,c,d){return a+(b-a)*c}function d(d,e,a,b){b=b||1;var c=a*a;return a=3*c-2*c*a,a=Math.pow(a,b),d+(e-d)*a}function e(a){this.updateOptions(a);var b=this.id='flyingline_'+Math.floor(Math.random()*1e9);this.reset()}var f=require('./../core/utils'),g=require('bcore/event'),a=require('three'),i=f.mercator,j=f.sphere,k=f.requestAnimationFrame,l=f.cancelAnimationFrame,m=require('./cube_utils'),n={cube:m(),smooth:function(f){var h=this.options,b=this.ptFrom,e=this.ptTo,g=h.flying.indensty,i=d(b.x,e.x,f,g),j=c(b.y,e.y,f),k=d(b.z,e.z,f,g);return new a.Vector3(i,j,k)},flying:function(a){var b=this.options,c=b.flying,d=c.kHeight+(this.kHeightJitter||0),e=this.ptFrom,f=this.ptTo,g=this._getNormal(),h=(1-a)*a*d*this.distance,i=e.clone().lerp(f,a).add(g.multiplyScalar(h));return i}};e.options={ptN:10,range:.8,isUpdateWhenEndStart:!0,flying:{kHeight:2,kHeightJitter:.2,weight:2,style:{hue:.5,opacity:.2,color:function(b){var c=.5;return new a.Color().setHSL(c,1-b*.3,.3+Math.pow(b,8)*.6)}}},type:'flying',lifeSpeed:.002,delay:0,delayEnd:1,lifeMin:0,lifeMax:1,endType:'explodePts'},e=g.extend(e,{updateOptions:function(a){a=this.options=f.deepMerge(this.options||e.options,a),typeof a.lifeSpeed==='function'&&(a.lifeSpeed=a.lifeSpeed()),typeof a.delay==='function'&&(a.delay=a.delay());var b=a.type;this._getPt=(n[b]||n.flying).bind(this)},setLine:function(a,b){this.lineMerge=a,this.lineIndex=b},addTo:function(a){this._map=a;var c=this.three3D=a.three3D,b=this.projection=a.projection;this.setNormal(b)},checkStatus:function(){if(this.status==='end')return;var b=this.life,a=this.options,c=a.flying.range,d=a.delayEnd;return b<a.lifeMin?this.status='pre-living':b<=a.lifeMax?this.status='living':(b<=a.lifeMax+c?this.status='lifeend-start':this.status='lifeend-done',b>a.lifeMax+d?this.end():this.status)},setNormal:function(b){var c=b.type;if(c==='mecator'||c==='plane'||c==='origin'){var d=this._center=new a.Vector3(b.x0,b.y0,b.z0);this._getNormal=function(){return new a.Vector3(0,1,0)}}else if(c==='sphere'){var d=this._center=new a.Vector3(b.x0,b.y0,b.z0);this._getNormal=function(c){var a=c||this.ptFrom,b=this.ptTo;return a&&b?a.clone().lerp(b,.5).sub(d).normalize():void 0}}},data:function(b){if(!b)return;this._data=b;var c=h(b.to),a=h(b.from),d=b.cubeCenter,e=!a||!c||(!a.lat||!c.lat)&&(a.x===null||a.x===undefined),i=!d;if(i&&e)return this.end();if(!e){var f=this.ptFrom=this.projection.project(a),g=this.ptTo=this.projection.project(c);if(this.distance=f.distanceTo(g),!(f&&g))return this.end()}d&&(this.cubeCenter=d),this.reset(),this.emit('start')}}),e.prototype._getPt=function(a){},e.prototype.update=function(){if(!(this.lineMerge&&this._map))return;var b=this.options;this.life+=b.lifeSpeed;var c=b.endType,a=this.checkStatus();a==='pre-living'||a==='living'?this.updateLine():a==='lifeend-start'&&(b.isUpdateWhenEndStart&&this.updateLine(),this.pStatus==='living'&&this.emit('flying-end',{data:this._data,lineIndex:this.lineIndex})),this.pStatus=a},e.prototype.equalTo=function(a){return this.lineIndex===a.lineIndex},e.prototype.end=function(){this.status='end',this.emit('end');var b=this.options,c=b.ptN,d=this.lineMerge,e=this.lineIndex;for(var a=0;a<c;a++)d.setPt(e,a,0,0,0)};var o=0;e.prototype.resetLine=function(){var c=this.lineMerge,f=this.lineIndex,j=this._data;if(!c)return;var b=this.options.flying.style,h=b.color.bind(b),a=this.options.ptN;for(var d=0;d<a;d++)c.setPt(f,d,0,0,0);a=(a-1)*2;var g=[];for(var e=0;e<a;e++){var i=h(j,e/(a-1));g.push(i)}c.setColorArray(f,g,b.opacity)},e.prototype.updateLine=function(){var h=this.options,k=h.flying,b=k.range,g=h.ptN,i=this.lineMerge,j=this.lineIndex,a=this.life,e,f;for(var c=0;c<g;c++){var d=c/g;if(b>a)e=(1-d)*a;else if(a<1)e=a-d*b;else if(a>1&&a<1+b)e=1-(b-a+1)*d;else return;f=this._getPt(e),i.setPt(j,c,f.x,f.y,f.z)}},e.prototype.reset=function(){var a=this.options;this.status='ready',this.life=a.lifeMin-a.delay,this.targetList=null,this.kHeightJitter=a.flying.kHeight*a.flying.kHeightJitter*Math.random(),this.resetLine()},module.exports=e |
@@ -1,1 +0,1 @@ | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c)}var b=require('./../core/utils'),c=require('three'),g=b.requestAnimationFrame,h=b.cancelAnimationFrame,d=require('./../render/line_merge'),e=require('./../layer/flying_line'),i=b.getColorFunc,f=require('bcore/event');a.options={lineN:1e3,ptN:30,maxOpacity:1,weight:2,blending:c.AdditiveBlending,flying:{range:.2,kHeight:2,kHeightJitter:.2,style:{hue:.5,color:function(a){var b=this.hue;return a=1-a,new c.Color().setHSL(b,1-a*.3,.3+Math.pow(a,8)*.6)}}}},a=f.extend(a,{addTo:function(a){this._map=a;var b=this.three3D=a.three3D;this.initLines(),this.loop()}}),a.prototype.initLines=function(){var h=this._map,a=this.options,f=a.lineN,i=a.ptN,g=this.lineMerge=new d({lineN:f,ptN:i,weight:a.weight,maxOpacity:a.maxOpacity,material:{blending:a.blending}});g.addTo(h);var m=this.using=[],j=this.unusing=[],k=this.all=[],b,l=a;for(var c=0;c<f;c++)b=new e(l,!0),b.addTo(h),b.setLine(g,c),this.initEventLine(b),j.push(b),k.push(b)},a.prototype.data=function(d){var b,c,a=this.unusing,e=this.using;if(!(a&&a.length))return;for(var f in d)b=d[f],a.length&&b&&(c=a.pop(),c.data(b),e.push(c))},a.prototype.checkIfEnd=function(){var c=this.using,d=this.unusing,a;for(var b=c.length-1;b>=0;b--)a=c[b],a.life>=a.options.lifeMax+a.options.range&&(c.splice(b,1),d.push(a))},a.prototype.render=function(a){a&&this.data(a)},a.prototype.clean=function(){var b=this.using,a=this.unusing,e;for(var f in b)e=b[f],e.reset();this.using=[],a=[];var c=this.all;for(var d in c)a[d]=c[d];this.unusing=a},a.prototype.updateOptions=function(a){a&&(a=this.options=b.deepMerge(this.options,a)),a=this.options;var c,d=this.using;for(var f in d)c=d[f],c.updateOptions(a);var e=this.unusing;for(var g in e)c=e[g],c.updateOptions(a);var h=this.lineMerge;h.updateOptions({weight:a.weight,maxOpacity:a.maxOpacity})},a.prototype.loop=function(){this.checkIfEnd(),this.update();var a=this.loopId=window.requestAnimationFrame(this.loop.bind(this))},a.prototype.update=function(){var a=this.using;if(!(a&&a.length))return;var b;for(var c in a)b=a[c],b.update();this.lineMerge.update()},a.prototype.updateSprite=function(){},a.prototype.initEventLine=function(b){var c=this.unusing,d=this.using,a=this;b.on('flying-end',function(b){a.emit('flying-end',b)})},a.prototype.remove=function(){this.clean(),window.cancelAnimationFrame(this.loopId),this.lineMerge&&this.lineMerge.remove()},module.exports=a | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c)}var b=require('./../core/utils'),c=require('three'),d=b.requestAnimationFrame,e=b.cancelAnimationFrame,f=require('./../render/line_merge'),g=require('./../layer/flying_line'),h=b.getColorFunc,i=require('bcore/event');a.options={lineN:1e3,ptN:30,maxOpacity:1,weight:2,blending:c.AdditiveBlending,flying:{range:.2,kHeight:2,kHeightJitter:.2,style:{hue:.5,color:function(a){var b=this.hue;return a=1-a,new c.Color().setHSL(b,1-a*.3,.3+Math.pow(a,8)*.6)}}}},a=i.extend(a,{addTo:function(a){this._map=a;var b=this.three3D=a.three3D;this.initLines(),this.loop()}}),a.prototype.initLines=function(){var h=this._map,a=this.options,d=a.lineN,i=a.ptN,e=this.lineMerge=new f({lineN:d,ptN:i,weight:a.weight,maxOpacity:a.maxOpacity,material:{blending:a.blending}});e.addTo(h);var m=this.using=[],j=this.unusing=[],k=this.all=[],b,l=a;for(var c=0;c<d;c++)b=new g(l,!0),b.addTo(h),b.setLine(e,c),this.initEventLine(b),j.push(b),k.push(b)},a.prototype.data=function(d){var b,c,a=this.unusing,e=this.using;if(!(a&&a.length))return;for(var f in d)b=d[f],a.length&&b&&(c=a.pop(),c.data(b),e.push(c))},a.prototype.checkIfEnd=function(){var c=this.using,d=this.unusing,a;for(var b=c.length-1;b>=0;b--)a=c[b],a.life>=a.options.lifeMax+a.options.range&&(c.splice(b,1),d.push(a))},a.prototype.render=function(a){a&&this.data(a)},a.prototype.clean=function(){var b=this.using,a=this.unusing,e;for(var f in b)e=b[f],e.reset();this.using=[],a=[];var c=this.all;for(var d in c)a[d]=c[d];this.unusing=a},a.prototype.updateOptions=function(a){a&&(a=this.options=b.deepMerge(this.options,a)),a=this.options;var c,d=this.using;for(var f in d)c=d[f],c.updateOptions(a);var e=this.unusing;for(var g in e)c=e[g],c.updateOptions(a);var h=this.lineMerge;h.updateOptions({weight:a.weight,maxOpacity:a.maxOpacity})},a.prototype.loop=function(){this.checkIfEnd(),this.update();var a=this.loopId=window.requestAnimationFrame(this.loop.bind(this))},a.prototype.update=function(){var a=this.using;if(!(a&&a.length))return;var b;for(var c in a)b=a[c],b.update();this.lineMerge.update()},a.prototype.updateSprite=function(){},a.prototype.initEventLine=function(b){var c=this.unusing,d=this.using,a=this;b.on('flying-end',function(b){a.emit('flying-end',b)})},a.prototype.remove=function(){this.clean(),window.cancelAnimationFrame(this.loopId),this.lineMerge&&this.lineMerge.remove()},module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function a(c){c=this.options=b.deepMerge(a.options,c),this.initialize(c)}var d=require('three'),b=require('./../core/utils'),e=require('bcore/event'),f=b.format,c=require('./../map/projection/mecator');a.options={transform:'normal',scale:1,offset:{x:0,y:0,z:0},u:{step:6,range:[0,360]},v:{step:6,range:[0,180]}},a=e.extend(a,{initialize:function(a){},addTo:function(a){if(!a)return;this.three3D=a.three3D,this.projection=a.projection,this.initGeometry()},initGeometry:function(){var a=this.options,q=this.projection,e=a.u.step||a.step,f=a.u.range,g=f[0],h=f[1],i=a.v.step||a.step,b=a.v.range,k=b[0],l=b[1],n=this.geometry=new d.BufferGeometry,m=Math.floor((l-k)/ i)*Math.floor((h-g)/e),o=new Float32Array(m*3),p=new Float32Array(m*2);for(var c=k;c<=l;c+=i)for(var j=g;j<h;j+=e);},updateTransform:function(){var a=this.options,b=a.transform;if(b==='mecator'){var d=c.project({lat:-85.05112877980659,lng:0}),e=c.project({lat:85.05112877980659,lng:180});this.transform=function(a,b){},this.unTransform=function(a,b){};return}this.transform=this.unTransform=function(a,b){return{lat:a,lng:b}}}}),module.exports=a | ||
'use strict';function a(b){b=this.options=c.deepMerge(a.options,b),this.initialize(b)}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.format,f=require('./../map/projection/mecator');a.options={transform:'normal',scale:1,offset:{x:0,y:0,z:0},u:{step:6,range:[0,360]},v:{step:6,range:[0,180]}},a=d.extend(a,{initialize:function(a){},addTo:function(a){if(!a)return;this.three3D=a.three3D,this.projection=a.projection,this.initGeometry()},initGeometry:function(){var a=this.options,q=this.projection,e=a.u.step||a.step,f=a.u.range,g=f[0],h=f[1],i=a.v.step||a.step,c=a.v.range,k=c[0],l=c[1],n=this.geometry=new b.BufferGeometry,m=Math.floor((l-k)/ i)*Math.floor((h-g)/e),o=new Float32Array(m*3),p=new Float32Array(m*2);for(var d=k;d<=l;d+=i)for(var j=g;j<h;j+=e);},updateTransform:function(){var a=this.options,b=a.transform;if(b==='mecator'){var c=f.project({lat:-85.05112877980659,lng:0}),d=f.project({lat:85.05112877980659,lng:180});this.transform=function(a,b){},this.unTransform=function(a,b){};return}this.transform=this.unTransform=function(a,b){return{lat:a,lng:b}}}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(a){a=this.options=c.deepMerge(b.options,a),this.initTexture(a.image),this.initialize(a)}var a=require('three'),c=require('bcore/utils'),d=require('bcore/event');b.options={intensity:2,maxOpacity:.8,ratio:.98,xN:200,yN:200,type:'mesh',image:null,material:function(){return new a.MeshBasicMaterial({color:'#f00'})},atmosphere:!1},b=d.extend(b,{initialize:function(a){},initTexture:function(b){this.texture=new a.Texture(b)},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()},genUvs:function(){var c=[],d=this.options,e=d.xN,f=d.yN;for(var a=0;a<=e;a++)for(var b=0;b<=f;b++)c.push(b/f,1-a/e);return new Float32Array(c)},genNormals:function(){var h=[],f=this.options,g=f.xN,i=f.yN,a=Math.cos,e=Math.sin;for(var b=0;b<=g;b++){var k=1-b/g,c=(k-.5)*1*Math.PI;for(var d=0;d<=i;d++){var l=d/ i,j=-(l-.5)*2*Math.PI,n=a(j)*a(c),o=e(j)*a(c),m=e(c);h.push(n,m,o)}}return new Float32Array(h)},initGeo:function(){var b=this.options,n=this.three3D,m=b.type,l=this.projection,k=(l.radius||1)*b.ratio,e=new a.SphereBufferGeometry(k,b.xN,b.yN),h=b.xN*b.yN,f=new Float32Array(h*1),d=new Float32Array(h*4);for(var c=0;c<h;c++)d[c*4+0]=1,d[c*4+1]=1,d[c*4+2]=1,d[c*4+3]=1,f[c*1]=c;d=new a.BufferAttribute(d,4).setDynamic(!0),f=new a.BufferAttribute(f,1).setDynamic(!0);var i=this.genUvs();i=new a.BufferAttribute(i,2).setDynamic(!0);var j=this.genNormals();j=new a.BufferAttribute(j,3).setDynamic(!0),e.addAttribute('colors',d),e.addAttribute('indexes',f),e.addAttribute('uvs',i),e.addAttribute('normals1',j);var o=this.materialGlobe=b.material(),p={mesh:a.Mesh,pointCloud:a.Points,particle:a.Points,points:a.Points}[m],g=this.globeMesh=new p(e,o);g.scale.set(b.ratio,b.ratio,b.ratio),g.castShadow=!0,g.receiveShadow=!0,n.add(g)},updateOptions:function(){var b=this.options,a=b.globe.ratio;this.globeMesh.scale.set(a,a,a),this.updateShader()}}),module.exports=b | ||
'use strict';function a(b){b=this.options=c.deepMerge(a.options,b),this.initTexture(b.image),this.initialize(b)}var b=require('three'),c=require('bcore/utils'),d=require('bcore/event');a.options={intensity:2,maxOpacity:.8,ratio:.98,xN:200,yN:200,type:'mesh',image:null,material:function(){return new b.MeshBasicMaterial({color:'#f00'})},atmosphere:!1},a=d.extend(a,{initialize:function(a){},initTexture:function(a){this.texture=new b.Texture(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()},genUvs:function(){var c=[],d=this.options,e=d.xN,f=d.yN;for(var a=0;a<=e;a++)for(var b=0;b<=f;b++)c.push(b/f,1-a/e);return new Float32Array(c)},genNormals:function(){var h=[],f=this.options,g=f.xN,i=f.yN,a=Math.cos,e=Math.sin;for(var b=0;b<=g;b++){var k=1-b/g,c=(k-.5)*1*Math.PI;for(var d=0;d<=i;d++){var l=d/ i,j=-(l-.5)*2*Math.PI,n=a(j)*a(c),o=e(j)*a(c),m=e(c);h.push(n,m,o)}}return new Float32Array(h)},initGeo:function(){var a=this.options,n=this.three3D,m=a.type,l=this.projection,k=(l.radius||1)*a.ratio,e=new b.SphereBufferGeometry(k,a.xN,a.yN),h=a.xN*a.yN,f=new Float32Array(h*1),d=new Float32Array(h*4);for(var c=0;c<h;c++)d[c*4+0]=1,d[c*4+1]=1,d[c*4+2]=1,d[c*4+3]=1,f[c*1]=c;d=new b.BufferAttribute(d,4).setDynamic(!0),f=new b.BufferAttribute(f,1).setDynamic(!0);var i=this.genUvs();i=new b.BufferAttribute(i,2).setDynamic(!0);var j=this.genNormals();j=new b.BufferAttribute(j,3).setDynamic(!0),e.addAttribute('colors',d),e.addAttribute('indexes',f),e.addAttribute('uvs',i),e.addAttribute('normals1',j);var o=this.materialGlobe=a.material(),p={mesh:b.Mesh,pointCloud:b.Points,particle:b.Points,points:b.Points}[m],g=this.globeMesh=new p(e,o);g.scale.set(a.ratio,a.ratio,a.ratio),g.castShadow=!0,g.receiveShadow=!0,n.add(g)},updateOptions:function(){var b=this.options,a=b.globe.ratio;this.globeMesh.scale.set(a,a,a),this.updateShader()}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'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 | ||
'use strict';function a(b){b=this.options=d.deepMerge(a.options,b),this.initialize(b)}var b=require('three'),c=require('bcore/event'),d=require('./../core/utils'),e={卫星:{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:{}}};a.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:b.AddOperation,wireframeLinecap:'round',depthTest:!0,shading:b.SmoothShading}},atmosphere:{color:'#0ff',ratio:1.05,maxOpacity:1,intensity:2,isAtmosphere:!1}},a=c.extend(a,{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 a=this.options.globe,d=this.three3D,l=this._map,i=this.projection,e=(i.radius||1)*a.ratio,h=this.globe=new b.SphereBufferGeometry(e,a.xN,a.yN);this.genMaterialGlobe(function(f){var g=this.materialGlobe=f;f.side=b.BackSide;var e=this.globeMesh=new b.Mesh(h,g);e.scale.set(a.ratio,a.ratio,a.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 b.Mesh(j,i);c.scale.set(a.ratio,a.ratio,a.ratio),c.castShadow=!0,c.receiveShadow=!0,c.material.side=b.FrontSide,d.add(c)}.bind(this));var g=this.options.atmosphere;if(!g)return;var j=this.atmosphere=new b.SphereBufferGeometry(e,a.xN,a.yN),k=this.materialAtmosphere=this.genMaterialAtmosphere(),f=this.meshAtomesphere=new b.Mesh(j,k),c=g.ratio;f.scale.set(c,c,c),d.add(f),this.checkAtomesphere()}}),a.prototype.genMaterialGlobe=function(m){var h=this.options,n=h.globe.textureType||'地形',a=e[n],c=h.globe.material;if(c.transparent=a.transparent,typeof c==='function'){var f=c();return m(f)}c=JSON.parse(JSON.stringify(c));var d=new b.TextureLoader;d.setCrossOrigin('*'),d.crossOrigin='*';var g=h.globe.imgbase;if(!a.cache.map){var l=d.load(g+a.map,function(){l.needsUpdate=!0});a.cache.map=l}if(!a.cache.specularMap){var i=d.load(g+a.specularMap,function(){i.needsUpdate=!0});a.cache.specularMap=i}if(!a.cache.normalMap){var k=d.load(g+a.normalMap,function(){k.needsUpdate=!0});a.cache.normalMap=k}if(!a.cache.bumpMap){var j=d.load(g+a.bumpMap,function(){j.needsUpdate=!0});a.cache.bumpMap=j}c.map=a.cache.map,c.specularMap=a.cache.specularMap,c.normalMap=a.cache.normalMap,c.bumpMap=a.cache.bumpMap;var f=new b.MeshPhongMaterial(c);m(f)},a.prototype.checkAtomesphere=function(){var a=this.options.atmosphere,b=a.isAtmosphere;b?this.atomesphereShow():this.atomesphereHide()},a.prototype.atomesphereShow=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!0)},a.prototype.atomesphereHide=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!1)},a.prototype.show=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!0),this.globeMesh&&(this.globeMesh.visible=!0)},a.prototype.hide=function(){this.meshAtomesphere&&(this.meshAtomesphere.visible=!1),this.globeMesh&&(this.globeMesh.visible=!1)},a.prototype.genMaterialAtmosphere=function(){var a=this.options.atmosphere,c=a.maxOpacity,d=a.intensity,e='varying vec3 vNormal;void main() {vNormal = normalize( normalMatrix * normal );gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}',f=this.genFragAtmosphere();return new b.ShaderMaterial({uniforms:{intensity:{type:'f',value:d},maxOpacity:{type:'f',value:c}},vertexShader:e,fragmentShader:f,side:b.BackSide,transparent:!1})},a.prototype.genFragAtmosphere=function(){var a=this.options.atmosphere.color;a=new b.Color(a);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( '+a.r+', '+a.g+', '+a.b+', maxOpacity ) * k;'+'}'},a.prototype.updateShader=function(){var d=this.options,a=d.globe.material,c=this.materialGlobe;if(!c)return;c.normalScale=a.normalScale,c.color=new b.Color(a.color),c.specular=new b.Color(a.specular),c.emissive=new b.Color(a.emissive),c.transparent=a.transparent,c.needsUpdate=!0,this.backMaterial.normalScale=a.normalScale,this.backMaterial.color=new b.Color(a.color),this.backMaterial.specular=new b.Color(a.specular),this.backMaterial.emissive=new b.Color(a.emissive),this.backMaterial.transparent=a.transparent,this.backMaterial.needsUpdate=!0},a.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()},a.prototype.updateGlobeMaterial=function(){var a=this.options;this.genMaterialGlobe(function(a){var e=this.materialGlobe=a,c=this.globeMesh;a.side=b.BackSide,c.material=a,c.material.needsUpdate=!0;var d=this.backMaterial=a.clone();d.side=b.FrontSide,this.backGlobeMesh.material=d,this.backGlobeMesh.material.needsUpdate=!0}.bind(this))},a.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},a.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,e.cache=null},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(b,a){a=this.options=c.deepMerge(this.options,a),obj=obj||{},this.setLight(),this.ambientColor=obj.ambientColor||2236962,this.init(obj),this.loop()}var a=require('three'),c=require('./../core/utils'),d;b.prototype.prototype={init:function(a){},initShader:function(){},genMaterial:function(f,g){var b='attribute vec4 colors;attribute float indexes;varying vec4 c;varying float index;void main(){c = colors;index = indexes;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;gl_PointSize = 10.0;}',c='varying vec4 c;uniform float maxOpacity;varying float index;void main() {gl_FragColor = c * vec4(1, 1, 1, maxOpacity);}',d={maxOpacity:{type:'f',value:this._maxOpacity}},e={colors:{type:'v4',value:f},indexes:{type:'f',value:g}};return new a.ShaderMaterial({uniforms:d,attributes:e,vertexShader:b,fragmentShader:c,vertexColors:a.VertexColors,blending:a.AdditiveBlending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:a.SmoothShading,side:a.DoubleSide,linewidth:this._weight,linejoin:'round',linecap:'round',fog:!0})},loop:function(){this.update(),requestAnimationFrame(this.update.bind(this))}},b.options={},module.exports=b | ||
function a(b,a){a=this.options=c.deepMerge(this.options,a),obj=obj||{},this.setLight(),this.ambientColor=obj.ambientColor||2236962,this.init(obj),this.loop()}var b=require('three'),c=require('./../core/utils'),d;a.prototype.prototype={init:function(a){},initShader:function(){},genMaterial:function(f,g){var a='attribute vec4 colors;attribute float indexes;varying vec4 c;varying float index;void main(){c = colors;index = indexes;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;gl_PointSize = 10.0;}',c='varying vec4 c;uniform float maxOpacity;varying float index;void main() {gl_FragColor = c * vec4(1, 1, 1, maxOpacity);}',d={maxOpacity:{type:'f',value:this._maxOpacity}},e={colors:{type:'v4',value:f},indexes:{type:'f',value:g}};return new b.ShaderMaterial({uniforms:d,attributes:e,vertexShader:a,fragmentShader:c,vertexColors:b.VertexColors,blending:b.AdditiveBlending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:b.SmoothShading,side:b.DoubleSide,linewidth:this._weight,linejoin:'round',linecap:'round',fog:!0})},loop:function(){this.update(),requestAnimationFrame(this.update.bind(this))}},a.options={},module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(a){this.options=c.deepMerge(b.options,a)}var c=require('./../core/utils'),a=require('./../three'),e=require('bcore/event'),d=require('lodash'),f=c.randomWord;b.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:c.getLat,lng:c.getLng,id:function(a,b){return f(!1,4,10)},blending:a.AdditiveBlending},b=e.extend(b,{updateOptions:function(a){a&&(this.options=c.deepMerge(this.options||b.options,a)),this.update()},update:function(){if(!this.cubes)return;var b=this.options,e=b.size,f=b.maxHeight,c=new a.Color(b.color),g=b.opacity;d.forEach(this.cubes,function(b){var d=f*b.value,a=b.cube;a.material.color.setRGB(c.r,c.g,c.b),a.material.opacity=g,a.material.transparent=!0,a.scale.set(e,e,d)})},addTo:function(a){this.three3D=a.three3D,this.projection=a.projection},_createGeometry:function(){var c=this.options.ratio,b=new a.BoxGeometry(1,1,1);return b.vertices.forEach(function(a){a.z+=.5*c}),b},_createMaterial:function(){var c=this.options,d=new a.Color(c.color),e=c.opacity,f=c.blending,b=new a.MeshBasicMaterial({transparent:!0,blending:f,side:a.DoubleSide});return b.color.setRGB(d.r,d.g,d.b),b.opacity=e,b.needsUpdate=!0,b},render:function(a){a&&this.data(a),this.remove(),this.draw()},data:function(a){if(!a)return;this._data=a,this.processing(a)},processing:function(f){var c=this.options.value,a=c(f[0]),b=a,e;d.forEach(f,function(d){e=c(d),a=Math.min(a,e),b=Math.max(b,e)}),this.range=[a,b]},draw:function(){var p=this,t=this._data,b=this.options,g=b.size,v=b.lat,z=b.lng,A=b.value,k=b.id,l=b.maxHeight,m=this._createGeometry(),n=this._createMaterial(),o=this.three3D,r=this.cubes={},q=this.projection,h=this.range,s=h[1],i=h[0],u=s-i,e,w,x,y,j,f,c;d.forEach(t,function(b,h){x=v(b),y=z(b),j=k(b),e=A(b),e=(e-i)/u||1,c=new a.Mesh(m,n);var d={lat:x,lng:y};c.lookAt(p.getTarget(d)),f=q.project(d),c.position.set(f.x,f.y,f.z),w=l*e,c.scale.set(g,g,w),o.add(c),r[j]={data:b,id:j,cube:c,value:e}})},getTarget:function(c){var b=this.projection;return b.type==='plane'||b.type==='mecator'?new a.Vector3(0,1,0):b.type==='sphere'?b.getNormal(c):void 0},remove:function(){var a=this.cubes,b=this;d.forEach(a,function(c){var a=c.cube;b.three3D.remove(a),a&&a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose(),c.cube=null,c.data=null,c.id=null,c.value=null})}}),module.exports=b | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c)}var b=require('./../core/utils'),c=require('./../three'),d=require('bcore/event'),e=require('lodash'),f=b.randomWord;a.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,b){return f(!1,4,10)},blending:c.AdditiveBlending},a=d.extend(a,{updateOptions:function(c){c&&(this.options=b.deepMerge(this.options||a.options,c)),this.update()},update:function(){if(!this.cubes)return;var a=this.options,d=a.size,f=a.maxHeight,b=new c.Color(a.color),g=a.opacity;e.forEach(this.cubes,function(c){var e=f*c.value,a=c.cube;a.material.color.setRGB(b.r,b.g,b.b),a.material.opacity=g,a.material.transparent=!0,a.scale.set(d,d,e)})},addTo:function(a){this.three3D=a.three3D,this.projection=a.projection},_createGeometry:function(){var b=this.options.ratio,a=new c.BoxGeometry(1,1,1);return a.vertices.forEach(function(a){a.z+=.5*b}),a},_createMaterial:function(){var b=this.options,d=new c.Color(b.color),e=b.opacity,f=b.blending,a=new c.MeshBasicMaterial({transparent:!0,blending:f,side:c.DoubleSide});return a.color.setRGB(d.r,d.g,d.b),a.opacity=e,a.needsUpdate=!0,a},render:function(a){a&&this.data(a),this.remove(),this.draw()},data:function(a){if(!a)return;this._data=a,this.processing(a)},processing:function(f){var c=this.options.value,a=c(f[0]),b=a,d;e.forEach(f,function(e){d=c(e),a=Math.min(a,d),b=Math.max(b,d)}),this.range=[a,b]},draw:function(){var p=this,t=this._data,a=this.options,g=a.size,v=a.lat,z=a.lng,A=a.value,k=a.id,l=a.maxHeight,m=this._createGeometry(),n=this._createMaterial(),o=this.three3D,r=this.cubes={},q=this.projection,h=this.range,s=h[1],i=h[0],u=s-i,d,w,x,y,j,f,b;e.forEach(t,function(a,h){x=v(a),y=z(a),j=k(a),d=A(a),d=(d-i)/u||1,b=new c.Mesh(m,n);var e={lat:x,lng:y};b.lookAt(p.getTarget(e)),f=q.project(e),b.position.set(f.x,f.y,f.z),w=l*d,b.scale.set(g,g,w),o.add(b),r[j]={data:a,id:j,cube:b,value:d}})},getTarget:function(b){var a=this.projection;return a.type==='plane'||a.type==='mecator'?new c.Vector3(0,1,0):a.type==='sphere'?a.getNormal(b):void 0},remove:function(){var a=this.cubes,b=this;e.forEach(a,function(c){var a=c.cube;b.three3D.remove(a),a&&a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose(),c.cube=null,c.data=null,c.id=null,c.value=null})}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function c(a){this.options=b.deepMerge(c.options,a)}var b=require('./../core/utils'),a=require('./../three'),e=require('bcore/event'),d=require('lodash');c.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,c){return b.randomWord(!1,4,10)},blending:a.AdditiveBlending,faceColor:function(b){return new a.Color('rgb(0,150,250)')}},c=e.extend(c,{updateOptions:function(a){a&&(this.options=b.deepMerge(this.options,a)),this.update()},update:function(){if(!this.cubes)return;var b=this.options,e=b.size,f=b.maxHeight,c=new a.Color(b.color),g=b.opacity;d.forEach(this.cubes,function(b){var d=f*b.value,a=b.cube;a.material.color.setRGB(c.r,c.g,c.b),a.material.opacity=g,a.material.transparent=!0,a.scale.set(e,e,d)})},addTo:function(a){this.three3D=a.three3D;var b=this.projection=a.projection},_createGeometry:function(){var c=this.options.ratio,b=new a.BoxGeometry(1,1,1);return b.vertices.forEach(function(a){a.z+=.5*c}),b},_createMaterial:function(){var b=this.options,f=b.color,c=b.opacity,d=b.blending,e=new a.MeshPhongMaterial({color:16777215,opacity:c,transparent:!0,blending:d,vertexColors:a.FaceColors,side:a.DoubleSide});return e},render:function(a){a&&this.data(a),this.draw()},data:function(a){if(!a)return;var b=this._data=a;this.processing(a)},processing:function(f){var c=this.options.value,a=c(f[0]),b=a,e;d.forEach(f,function(d){e=c(d),a=Math.min(a,e),b=Math.max(b,e)}),this.range=[a,b]},draw:function(){var q=this,n=this._data,c=this.options,l=c.size,o=c.lat,p=c.lng,s=c.value,u=c.id,y=c.maxHeight,f=this._createGeometry(),i=this._createMaterial(),b,j=new a.Geometry,g=this.range,r=g[1],k=g[0],t=r-k,e,v,w,x,m,h,A=this.three3D,B=this.cubes={},C=this.projection;d.forEach(n,function(d,A){w=o(d),x=p(d),m=u(d),e=s(d),e=(e-k)/t||1,b=new a.Mesh(f,i);var n={lat:w,lng:x};b.lookAt(q.getTarget(n)),h=C.project(n),b.position.set(h.x,h.y,h.z),v=y*e,b.scale.set(l,l,v);var r=c.faceColor(d,g),z=f.faces;z.forEach(function(a){a.color=r}),f.colorsNeedUpdate=!0,b.updateMatrix(),j.merge(b.geometry,b.matrix),B[m]={data:d,id:m,cube:b,value:e}});var z=this.mergedMesh=new a.Mesh(j,i);A.add(z)},getTarget:function(c){var b=this.projection;return b.type==='plane'||b.type==='mecator'?new a.Vector3(0,1,0):b.type==='sphere'?b.getNormal(c):void 0},remove:function(){var a=this.cubes,b=this;d.forEach(a,function(c){var a=c.cube;b.three3D.remove(a),a&&a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose(),c.cube=null,c.data=null,c.id=null,c.value=null})}}),module.exports=c | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c)}var b=require('./../core/utils'),c=require('./../three'),d=require('bcore/event'),e=require('lodash');a.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,c){return b.randomWord(!1,4,10)},blending:c.AdditiveBlending,faceColor:function(a){return new c.Color('rgb(0,150,250)')}},a=d.extend(a,{updateOptions:function(a){a&&(this.options=b.deepMerge(this.options,a)),this.update()},update:function(){if(!this.cubes)return;var a=this.options,d=a.size,f=a.maxHeight,b=new c.Color(a.color),g=a.opacity;e.forEach(this.cubes,function(c){var e=f*c.value,a=c.cube;a.material.color.setRGB(b.r,b.g,b.b),a.material.opacity=g,a.material.transparent=!0,a.scale.set(d,d,e)})},addTo:function(a){this.three3D=a.three3D;var b=this.projection=a.projection},_createGeometry:function(){var b=this.options.ratio,a=new c.BoxGeometry(1,1,1);return a.vertices.forEach(function(a){a.z+=.5*b}),a},_createMaterial:function(){var a=this.options,f=a.color,b=a.opacity,d=a.blending,e=new c.MeshPhongMaterial({color:16777215,opacity:b,transparent:!0,blending:d,vertexColors:c.FaceColors,side:c.DoubleSide});return e},render:function(a){a&&this.data(a),this.draw()},data:function(a){if(!a)return;var b=this._data=a;this.processing(a)},processing:function(f){var c=this.options.value,a=c(f[0]),b=a,d;e.forEach(f,function(e){d=c(e),a=Math.min(a,d),b=Math.max(b,d)}),this.range=[a,b]},draw:function(){var q=this,n=this._data,b=this.options,l=b.size,o=b.lat,p=b.lng,s=b.value,u=b.id,y=b.maxHeight,f=this._createGeometry(),i=this._createMaterial(),a,j=new c.Geometry,g=this.range,r=g[1],k=g[0],t=r-k,d,v,w,x,m,h,A=this.three3D,B=this.cubes={},C=this.projection;e.forEach(n,function(e,A){w=o(e),x=p(e),m=u(e),d=s(e),d=(d-k)/t||1,a=new c.Mesh(f,i);var n={lat:w,lng:x};a.lookAt(q.getTarget(n)),h=C.project(n),a.position.set(h.x,h.y,h.z),v=y*d,a.scale.set(l,l,v);var r=b.faceColor(e,g),z=f.faces;z.forEach(function(a){a.color=r}),f.colorsNeedUpdate=!0,a.updateMatrix(),j.merge(a.geometry,a.matrix),B[m]={data:e,id:m,cube:a,value:d}});var z=this.mergedMesh=new c.Mesh(j,i);A.add(z)},getTarget:function(b){var a=this.projection;return a.type==='plane'||a.type==='mecator'?new c.Vector3(0,1,0):a.type==='sphere'?a.getNormal(b):void 0},remove:function(){var a=this.cubes,b=this;e.forEach(a,function(c){var a=c.cube;b.three3D.remove(a),a&&a.dispose&&a.dispose(),a.material&&a.material.dispose(),a.geometry&&a.geometry.dispose(),c.cube=null,c.data=null,c.id=null,c.value=null})}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function c(a){this.updateOptions(a)}var b=require('./../core/utils'),a=require('./../three'),e=require('bcore/event'),f=b.mercator,g=b.sphere,d=require('lodash');c.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,b){return a.id||b},blending:a.AdditiveBlending,faceColor:function(b){return new a.Color('rgb(0,150,250)')}},c=e.extend(c,{updateOptions:function(a){var a=this.options=b.deepMerge(this.options||c.options,a);this.update()},update:function(){if(!this.cubes)return;var b=this.options,e=b.size,f=b.maxHeight,c=new a.Color(b.color),g=b.opacity;d.forEach(this.cubes,function(b){var d=f*b.value,a=b.cube;a.material.color.setRGB(c.r,c.g,c.b),a.material.opacity=g,a.material.transparent=!0,a.scale.set(e,e,d)})},addTo:function(a){this.three3D=a.three3D;var b=this.projection=a.projection},_createGeometry:function(c,d){var b=this.options.ratio;return geometry=new a.BoxGeometry(1,1,1),geometry.vertices.forEach(function(a){a.z+=.5*b}),geometry},_createMaterial:function(){var b=this.options,f=b.color,c=b.opacity,d=b.blending,e=new a.MeshPhongMaterial({color:65280,opacity:c,transparent:!0,blending:d,side:a.DoubleSide});return e},render:function(a){a&&this.data(a),this.draw()},data:function(a){if(!a)return;var b=this._data=a;this.processing(a)},processing:function(f){var c=this.options.value,a=c(f[0]),b=a,e;d.forEach(f,function(d){e=c(d),a=Math.min(a,e),b=Math.max(b,e)}),this.range=[a,b]},draw:function(){var h=this,o=this._data,b=this.options,j=b.size,p=b.lat,r=b.lng,t=b.value,u=b.id,v=b.maxHeight,w=this._createMaterial(),g=this.range,n=g[1],i=g[0],q=n-i,e,s,k,l,m,f,c,y=this.three3D,z=this.cubes={},x=this.projection;d.forEach(o,function(b,n){k=p(b),l=r(b),m=u(b),e=t(b),e=(e-i)/q||1;var g=h._createGeometry(k,l);c=new a.Mesh(g,w);var d={lat:k,lng:l};c.lookAt(h.getTarget(d)),f=x.project(d),c.position.set(f.x,f.y,f.z),s=v*e,c.scale.set(j,j,s),y.add(c),z[m]={data:b,id:m,cube:c,value:e}})},getTarget:function(c){var b=this.projection;return b.type==='plane'||b.type==='mecator'?new a.Vector3(0,1,0):b.type==='sphere'?b.getNormal(c):void 0}}),module.exports=c | ||
'use strict';function a(a){this.updateOptions(a)}var b=require('./../core/utils'),c=require('./../three'),d=require('bcore/event'),e=b.mercator,f=b.sphere,g=require('lodash');a.options={maxHeight:5e6,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,b){return a.id||b},blending:c.AdditiveBlending,faceColor:function(a){return new c.Color('rgb(0,150,250)')}},a=d.extend(a,{updateOptions:function(c){var c=this.options=b.deepMerge(this.options||a.options,c);this.update()},update:function(){if(!this.cubes)return;var a=this.options,d=a.size,e=a.maxHeight,b=new c.Color(a.color),f=a.opacity;g.forEach(this.cubes,function(c){var g=e*c.value,a=c.cube;a.material.color.setRGB(b.r,b.g,b.b),a.material.opacity=f,a.material.transparent=!0,a.scale.set(d,d,g)})},addTo:function(a){this.three3D=a.three3D;var b=this.projection=a.projection},_createGeometry:function(b,d){var a=this.options.ratio;return geometry=new c.BoxGeometry(1,1,1),geometry.vertices.forEach(function(b){b.z+=.5*a}),geometry},_createMaterial:function(){var a=this.options,f=a.color,b=a.opacity,d=a.blending,e=new c.MeshPhongMaterial({color:65280,opacity:b,transparent:!0,blending:d,side:c.DoubleSide});return e},render:function(a){a&&this.data(a),this.draw()},data:function(a){if(!a)return;var b=this._data=a;this.processing(a)},processing:function(e){var c=this.options.value,a=c(e[0]),b=a,d;g.forEach(e,function(e){d=c(e),a=Math.min(a,d),b=Math.max(b,d)}),this.range=[a,b]},draw:function(){var h=this,o=this._data,a=this.options,j=a.size,p=a.lat,r=a.lng,t=a.value,u=a.id,v=a.maxHeight,w=this._createMaterial(),f=this.range,n=f[1],i=f[0],q=n-i,d,s,k,l,m,e,b,y=this.three3D,z=this.cubes={},x=this.projection;g.forEach(o,function(a,n){k=p(a),l=r(a),m=u(a),d=t(a),d=(d-i)/q||1;var g=h._createGeometry(k,l);b=new c.Mesh(g,w);var f={lat:k,lng:l};b.lookAt(h.getTarget(f)),e=x.project(f),b.position.set(e.x,e.y,e.z),s=v*d,b.scale.set(j,j,s),y.add(b),z[m]={data:a,id:m,cube:b,value:d}})},getTarget:function(b){var a=this.projection;return a.type==='plane'||a.type==='mecator'?new c.Vector3(0,1,0):a.type==='sphere'?a.getNormal(b):void 0}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c),this.scale=0,this.reverseScale=0,this.scaleOffsetIndex=0}var b=require('./../core/utils'),g=require('lodash'),h=b.isNone,d=require('./../render/particleMaterial3D'),c=require('./../three'),e=b.getSprite,i=b.getRange,f=b.randomWord;a.options={blending:c.AdditiveBlending,ratio:1,lat:b.getLat,lng:b.getLng,id:function(a,b){return f(!1,4,10)},scatterN:1e3,maxPtSize:5,minPtSize:2,maxOpacity:1,color:'#0ff',scaleOffset:1,scaleSpeed:.03,sprite:{drawN:1.15,width:128,height:128,color:{from:'hsla(20,100%,75%,0.8)',to:'hsla(120,100%,50%,0.1)',easing:'Linear.None.1.7',space:'rgb'}},offset:{x:0,y:2e5,z:0},value:function(a){return a.value},size:function(c,a,d){var b=(c.value-a)/(d-a);return b*(this.maxPtSize-this.minPtSize)+this.minPtSize},anim:{easing:'Bounce.In',time:3e3}},a.prototype.addTo=function(a){this._map=a,this.three3D=a.three3D,this.initParticles(),this.projection=a.projection},a.prototype.data=function(g){var f={},e,j,a,d=this.options,h=d.value.bind(d),i=d.id.bind(d),b,c;for(var k in g)e=g[k],j=i(e),f[j]=e,a=h(e),(b===null||b===undefined)&&(b=a),(c===null||c===undefined)&&(c=a),b>a&&(b=a),c<a&&(c=a);this._data=f,this.range=[b,c]},a.prototype.clean=function(){var c=this.options,d=c.scatterN,e=this.particleGeometry.getAttribute('sizes').array,b=this.particleGeometry.getAttribute('position').array;for(var a=0;a<d;a++)e[a*1]=0,b[a*3+0]=0,b[a*3+1]=0,b[a*3+2]=0},a.prototype.update=function(){if(!this.particles)return;var d=this.options,a=d.scaleOffset,b=d.scaleSpeed;if(!(b&&a))return;this.scaleOffsetIndex<a?(this.scale+=b,this.scaleOffsetIndex+=b):a<=this.scaleOffsetIndex&&this.scaleOffsetIndex<2*a?(this.scale-=b,this.scaleOffsetIndex+=b):this.scaleOffsetIndex>2*a&&(this.scale=0,this.scaleOffsetIndex=0),this.reverseScale=a-this.scale;var e=this.particles,f=this.particleGeometry.getAttribute('scales').array;for(var g in e){var h=e[g],c=h.attributesIndex;c%2===0?f[c*1]=this.scale+1:f[c*1]=this.reverseScale+1}this.updateScale()},a.prototype.draw=function(){if(!this._data)return;var i=this._data;this.clean();var q=this.particles=this.particles||{},t=this.projection.project.bind(this.projection),z=this.material,y=this.particleGeometry.vertices,p=this.particleGeometry.getAttribute('sizes').array,f=this.particleGeometry.getAttribute('position').array,a=this.options,g=a.ratio,v=a.lng,w=a.lat,m=a.size.bind(a),u=a.id.bind(a),o=a.scatterN,e=a.offset,h=this.range,r=h[0],s=h[1],c,d,k,l,x,n,b=0;for(var j in i){if(c=i[j],n=u(c,j),k=w(c),l=v(c),!(k&&l))continue;if(d=t({lat:k,lng:l},e.x,e.y,e.z),!d)continue;x=m(c,r,s),b<o&&(p[b]=x,f[3*b+0]=d.x*g,f[3*b+1]=d.y*g,f[3*b+2]=d.z*g,q[n]={attributesIndex:b}),b++}this.updatePosition(),this.updateSize()},a.prototype.render=function(a){a&&this.data(a),this.draw()},a.prototype.initParticles=function(){var k=this.options,b=k.scatterN,e=this.particleGeometry=new c.BufferGeometry,i=new Float32Array(b),f=new Float32Array(b*4),g=new Float32Array(b*3),j=new Float32Array(b);for(var a=0;a<b;a++)i[a*1]=0,f[a*4+0]=1,f[a*4+1]=1,f[a*4+2]=1,f[a*4+3]=1,j[a*1]=1,g[a*3+0]=0,g[a*3+1]=0,g[a*3+2]=0;e.addAttribute('sizes',new c.BufferAttribute(i,1,1).setDynamic(!0)),e.addAttribute('colors',new c.BufferAttribute(f,4,1).setDynamic(!0)),e.addAttribute('scales',new c.BufferAttribute(j,1,1).setDynamic(!0)),e.addAttribute('position',new c.BufferAttribute(g,3,1).setDynamic(!0));var l=this.particleMaterial=new d(this.getMatOptions()),m=this.material=l.getMaterial(),h=this.pointCloud=new c.Points(e,m);h.frustumCulled=!1,this.three3D.add(h),this.updateSize()},a.prototype.getMatOptions=function(){var a=this.options;return{sprite:e(a.sprite),scatterN:a.scatterN,maxPtSize:a.maxPtSize,maxOpacity:a.maxOpacity,reverseSpriteColor:a.reverseSpriteColor,blending:a.blending}},a.prototype.hide=function(){this.pointCloud.visible=!1},a.prototype.show=function(){this.pointCloud.visible=!0},a.prototype.updateOptions=function(a){this.options=b.deepMerge(this.options,a),this.particleMaterial.updateOptions(this.getMatOptions()),this.draw()},a.prototype.loop=function(){this.updateSize()},a.prototype.updateScale=function(){this.particleGeometry.getAttribute('scales').needsUpdate=!0},a.prototype.updateSize=function(){this.particleGeometry.getAttribute('sizes').needsUpdate=!0,this.material.needsUpdate=!0},a.prototype.updatePosition=function(){this.particleGeometry.verticesNeedUpdate=!0,this.particleGeometry.getAttribute('position').needsUpdate=!0},a.prototype.updateSprite=function(a){},a.prototype.remove=function(){this.three3D.remove(this.pointCloud),this.pointCloud&&this.pointCloud.dispose&&this.pointCloud.dispose(),this.particleGeometry&&this.particleGeometry.dispose(),this.material&&this.material.dispose(),this.pointCloud=null,this.particleGeometry=null,this.material=null,this.particles=null,this._data=null},module.exports=a | ||
'use strict';function a(c){this.options=b.deepMerge(a.options,c),this.scale=0,this.reverseScale=0,this.scaleOffsetIndex=0}var b=require('./../core/utils'),c=require('lodash'),d=b.isNone,e=require('./../render/particleMaterial3D'),f=require('./../three'),g=b.getSprite,h=b.getRange,i=b.randomWord;a.options={blending:f.AdditiveBlending,ratio:1,lat:b.getLat,lng:b.getLng,id:function(a,b){return i(!1,4,10)},scatterN:1e3,maxPtSize:5,minPtSize:2,maxOpacity:1,color:'#0ff',scaleOffset:1,scaleSpeed:.03,sprite:{drawN:1.15,width:128,height:128,color:{from:'hsla(20,100%,75%,0.8)',to:'hsla(120,100%,50%,0.1)',easing:'Linear.None.1.7',space:'rgb'}},offset:{x:0,y:2e5,z:0},value:function(a){return a.value},size:function(c,a,d){var b=(c.value-a)/(d-a);return b*(this.maxPtSize-this.minPtSize)+this.minPtSize},anim:{easing:'Bounce.In',time:3e3}},a.prototype.addTo=function(a){this._map=a,this.three3D=a.three3D,this.initParticles(),this.projection=a.projection},a.prototype.data=function(g){var f={},e,j,a,d=this.options,h=d.value.bind(d),i=d.id.bind(d),b,c;for(var k in g)e=g[k],j=i(e),f[j]=e,a=h(e),(b===null||b===undefined)&&(b=a),(c===null||c===undefined)&&(c=a),b>a&&(b=a),c<a&&(c=a);this._data=f,this.range=[b,c]},a.prototype.clean=function(){var c=this.options,d=c.scatterN,e=this.particleGeometry.getAttribute('sizes').array,b=this.particleGeometry.getAttribute('position').array;for(var a=0;a<d;a++)e[a*1]=0,b[a*3+0]=0,b[a*3+1]=0,b[a*3+2]=0},a.prototype.update=function(){if(!this.particles)return;var d=this.options,a=d.scaleOffset,b=d.scaleSpeed;if(!(b&&a))return;this.scaleOffsetIndex<a?(this.scale+=b,this.scaleOffsetIndex+=b):a<=this.scaleOffsetIndex&&this.scaleOffsetIndex<2*a?(this.scale-=b,this.scaleOffsetIndex+=b):this.scaleOffsetIndex>2*a&&(this.scale=0,this.scaleOffsetIndex=0),this.reverseScale=a-this.scale;var e=this.particles,f=this.particleGeometry.getAttribute('scales').array;for(var g in e){var h=e[g],c=h.attributesIndex;c%2===0?f[c*1]=this.scale+1:f[c*1]=this.reverseScale+1}this.updateScale()},a.prototype.draw=function(){if(!this._data)return;var i=this._data;this.clean();var q=this.particles=this.particles||{},t=this.projection.project.bind(this.projection),z=this.material,y=this.particleGeometry.vertices,p=this.particleGeometry.getAttribute('sizes').array,f=this.particleGeometry.getAttribute('position').array,a=this.options,g=a.ratio,v=a.lng,w=a.lat,m=a.size.bind(a),u=a.id.bind(a),o=a.scatterN,e=a.offset,h=this.range,r=h[0],s=h[1],c,d,k,l,x,n,b=0;for(var j in i){if(c=i[j],n=u(c,j),k=w(c),l=v(c),!(k&&l))continue;if(d=t({lat:k,lng:l},e.x,e.y,e.z),!d)continue;x=m(c,r,s),b<o&&(p[b]=x,f[3*b+0]=d.x*g,f[3*b+1]=d.y*g,f[3*b+2]=d.z*g,q[n]={attributesIndex:b}),b++}this.updatePosition(),this.updateSize()},a.prototype.render=function(a){a&&this.data(a),this.draw()},a.prototype.initParticles=function(){var k=this.options,b=k.scatterN,c=this.particleGeometry=new f.BufferGeometry,i=new Float32Array(b),d=new Float32Array(b*4),g=new Float32Array(b*3),j=new Float32Array(b);for(var a=0;a<b;a++)i[a*1]=0,d[a*4+0]=1,d[a*4+1]=1,d[a*4+2]=1,d[a*4+3]=1,j[a*1]=1,g[a*3+0]=0,g[a*3+1]=0,g[a*3+2]=0;c.addAttribute('sizes',new f.BufferAttribute(i,1,1).setDynamic(!0)),c.addAttribute('colors',new f.BufferAttribute(d,4,1).setDynamic(!0)),c.addAttribute('scales',new f.BufferAttribute(j,1,1).setDynamic(!0)),c.addAttribute('position',new f.BufferAttribute(g,3,1).setDynamic(!0));var l=this.particleMaterial=new e(this.getMatOptions()),m=this.material=l.getMaterial(),h=this.pointCloud=new f.Points(c,m);h.frustumCulled=!1,this.three3D.add(h),this.updateSize()},a.prototype.getMatOptions=function(){var a=this.options;return{sprite:g(a.sprite),scatterN:a.scatterN,maxPtSize:a.maxPtSize,maxOpacity:a.maxOpacity,reverseSpriteColor:a.reverseSpriteColor,blending:a.blending}},a.prototype.hide=function(){this.pointCloud.visible=!1},a.prototype.show=function(){this.pointCloud.visible=!0},a.prototype.updateOptions=function(a){this.options=b.deepMerge(this.options,a),this.particleMaterial.updateOptions(this.getMatOptions()),this.draw()},a.prototype.loop=function(){this.updateSize()},a.prototype.updateScale=function(){this.particleGeometry.getAttribute('scales').needsUpdate=!0},a.prototype.updateSize=function(){this.particleGeometry.getAttribute('sizes').needsUpdate=!0,this.material.needsUpdate=!0},a.prototype.updatePosition=function(){this.particleGeometry.verticesNeedUpdate=!0,this.particleGeometry.getAttribute('position').needsUpdate=!0},a.prototype.updateSprite=function(a){},a.prototype.remove=function(){this.three3D.remove(this.pointCloud),this.pointCloud&&this.pointCloud.dispose&&this.pointCloud.dispose(),this.particleGeometry&&this.particleGeometry.dispose(),this.material&&this.material.dispose(),this.pointCloud=null,this.particleGeometry=null,this.material=null,this.particles=null,this._data=null},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(a){this.options=c.deepMerge(b.options,a)}function e(a){var b=a.type;return b==='rect'?f(a):b==='box'?g(a):void 0}function f(b){var c=b.width||b.radius*2,d=b.height||b.width||b.radius*2;return new a.PlaneGeometry(c,d,1,1)}function g(b){var c=b.dx||b.radius*2,d=b.dy||b.dx||b.radius*2,e=b.dz||b.dx||b.radius*2;return new a.BoxGeometry(c,d,e,1,1,1)}var a=require('three'),c=require('./../core/utils'),d=require('bcore/event');b.options={N:100,transition:{x:0,y:0,z:0},shape:{type:'box',dx:1e6,dy:1e6,dz:1e5},material:function(){return new a.MeshBasicMaterial({color:'#f00'})}},b=d.extend(b,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init()},init:function(){var b=this.options,f=b.N,g=b.shape,h,c=new a.Geometry;for(var d=0;d<f;d++)h=e(g),c.merge(h);var i=b.material(),j=new a.Mesh(c,i);this.three3D.add(j)}}),module.exports=b | ||
function a(b){this.options=f.deepMerge(a.options,b)}function b(a){var b=a.type;return b==='rect'?c(a):b==='box'?d(a):void 0}function c(a){var b=a.width||a.radius*2,c=a.height||a.width||a.radius*2;return new e.PlaneGeometry(b,c,1,1)}function d(a){var b=a.dx||a.radius*2,c=a.dy||a.dx||a.radius*2,d=a.dz||a.dx||a.radius*2;return new e.BoxGeometry(b,c,d,1,1,1)}var e=require('three'),f=require('./../core/utils'),g=require('bcore/event');a.options={N:100,transition:{x:0,y:0,z:0},shape:{type:'box',dx:1e6,dy:1e6,dz:1e5},material:function(){return new e.MeshBasicMaterial({color:'#f00'})}},a=g.extend(a,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init()},init:function(){var a=this.options,f=a.N,g=a.shape,h,c=new e.Geometry;for(var d=0;d<f;d++)h=b(g),c.merge(h);var i=a.material(),j=new e.Mesh(c,i);this.three3D.add(j)}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
function a(b){this.options=c.deepMerge(a.options,b)}function e(a){var b=a.type;return b==='rect'?f(a):b==='box'?g(a):void 0}function f(a){var c=a.width||a.radius*2,d=a.height||a.width||a.radius*2;return new b.PlaneGeometry(c,d,1,1)}function g(a){var c=a.dx||a.radius*2,d=a.dy||a.dx||a.radius*2,e=a.dz||a.dx||a.radius*2;return new b.BoxGeometry(c,d,e,1,1,1)}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event');a.options={N:100,transition:{x:0,y:0,z:0},shape:{type:'box',dx:1e6,dy:1e6,dz:1e5},material:function(){return new b.MeshBasicMaterial({color:'#f00'})}},a=d.extend(a,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init()},init:function(){var g=this.three3D,a=this.options,h=this.shapes=[],i=a.N,j=a.shape,c,d,k=a.material();for(var f=0;f<i;f++)c=e(j),d=new b.Mesh(c,k),g.add(d),h.push({geometry:c,mesh:d})},updatePos:function(f){var b=this.shapes;for(var c in b){var d=b[c],e=d.mesh,a=f[c];e.position.set(a.x,a.y,a.z)}}}),module.exports=a | ||
function a(b){this.options=f.deepMerge(a.options,b)}function b(a){var b=a.type;return b==='rect'?c(a):b==='box'?d(a):void 0}function c(a){var b=a.width||a.radius*2,c=a.height||a.width||a.radius*2;return new e.PlaneGeometry(b,c,1,1)}function d(a){var b=a.dx||a.radius*2,c=a.dy||a.dx||a.radius*2,d=a.dz||a.dx||a.radius*2;return new e.BoxGeometry(b,c,d,1,1,1)}var e=require('three'),f=require('./../core/utils'),g=require('bcore/event');a.options={N:100,transition:{x:0,y:0,z:0},shape:{type:'box',dx:1e6,dy:1e6,dz:1e5},material:function(){return new e.MeshBasicMaterial({color:'#f00'})}},a=g.extend(a,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init()},init:function(){var g=this.three3D,a=this.options,h=this.shapes=[],i=a.N,j=a.shape,c,d,k=a.material();for(var f=0;f<i;f++)c=b(j),d=new e.Mesh(c,k),g.add(d),h.push({geometry:c,mesh:d})},updatePos:function(f){var b=this.shapes;for(var c in b){var d=b[c],e=d.mesh,a=f[c];e.position.set(a.x,a.y,a.z)}}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
function d(b){this.options=a.deepMerge(ShapeSystem.options,b)}var c=require('three'),a=require('./../core/utils'),b=require('bcore/event');ShapeSystem.options={type:'rect'},ShapeSystem=b.extend(ShapeSystem,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init(this.options)},init:function(b){var a=this._map}}),module.exports=ShapeSystem | ||
function a(a){this.options=c.deepMerge(ShapeSystem.options,a)}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event');ShapeSystem.options={type:'rect'},ShapeSystem=d.extend(ShapeSystem,{addTo:function(a){this._map=a,window.three3D=this.three3D=a.three3D,this.projection=a.projection,this.init(this.options)},init:function(b){var a=this._map}}),module.exports=ShapeSystem |
@@ -1,1 +0,1 @@ | ||
function b(){}var c=require('three'),a=require('./../core/utils'),d=require('bcore/event'),e=a.getColorFunc;b.options={} | ||
function a(){}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.getColorFunc;a.options={} |
@@ -1,1 +0,1 @@ | ||
function b(a){this.options=c.deepMerge(b.options,a)}var a=require('three'),c=require('./../core/utils'),f=require('bcore/event'),d=c.getColorFunc,e=' void main() {gl_Position = vec4( position, 1.0 );}',g=' uniform vec2 resolution; uniform sampler2D texture; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 color = texture2D(texture, uv).xyz; gl_FragColor = vec4(color, 1.0);}',h=' varying vec2 vUv; void main(){vUv = uv;gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}';b.options={xN:360,yN:181,grids:function(a){return a.data},ptN:16e3,speedScale:1e-5,width:3600,height:1800,heatValue:function(b,c){var a=Math.sqrt(b*b+c*c);return a/=20,Math.max(Math.min(a,1),0)},heatFill:{to:'#ff00ef',from:'#09f0f0',space:'rgb',easing:'linear.Out.1'}},b=f.extend(b,{addTo:function(a){this._map=a;var b=this.three3D=a.three3D;this.renderer=b.renderer,this.projection=a.projection,this.initScene()},data:function(a){this.processing(a)},processing:function(o){var b=this.options,e=b.heatFill;e&&(e=d(e));var j=b.grids.bind(b),g=this._data=j(o),f=b.xN,i=b.yN,l,k,h,m,n,c=this.dataF32V=new Float32Array(f*i*4);for(var a in g)l=Math.floor(a/f),k=a%f,h=g[a],m=c[a*4+0]=h[0],n=c[a*4+1]=h[1],c[a*4+2]=0,c[a*4+3]=1},init:function(b){var a=this.options.ptN;this.n=Math.floor(Math.sqrt(a))+1,this.initCopyShader(),this.initWindMap(),this.initParticleTexture(),this.initShaderVP(),this.initParticles(),this.initBlurShader(),this.isInited=!0},updateHeatTexture:function(){var g=this.options,m=g.xN,k=g.yN,j=this._data,h=this.heatF32=new Float32Array(m*k*4),e=g.heatFill,n=g.heatValue,l,f,o,i;if(e){e=d(e);for(var b in j)l=j[b],o=n(l[0],l[1]),i=e(o),i=c.parse(i),f=i.arr,h[b*4+0]=f[0]/255,h[b*4+1]=f[1]/255,h[b*4+2]=f[2]/255,h[b*4+3]=f[3]}this.heatTexture=new a.DataTexture(this.heatF32,m,k,a.RGBAFormat,a.FloatType),this.heatTexture.needsUpdate=!0},updateData:function(){if(!this.isInited){this.init(),this.updateHeatTexture();return}this.updateHeatTexture()},render:function(a){a&&this.data(a),this.updateData()},initWindMap:function(){this.textureV=new a.DataTexture(this.dataF32V,this.options.xN,this.options.yN,a.RGBAFormat,a.FloatType),this.textureV.needsUpdate=!0},initRandomMap:function(){},initParticleTexture:function(){var d=this.options,e=this.n,g=e*e,c=new Float32Array(g*4);for(var b=0;b<g;b++)c[4*b+0]=Math.random(),c[4*b+1]=Math.random(),c[4*b+2]=Math.random(),c[4*b+3]=Math.random();var f=this.textureRand=new a.DataTexture(c,e,e,a.RGBAFormat,a.FloatType);f.needsUpdate=!0,this.texturePt=this.createRenderTarget(),this.texturePt.needsUpdate=!0,this.copy(f,this.texturePt),this.texturePtCopy=this.createRenderTarget(),this.texturePtCopy.needsUpdate=!0,this.copy(f,this.texturePtCopy),this.textureWind=this.createRenderTarget(a.RGBAFormat,d.width,d.height),this.textureWind.needsUpdate=!0,this.textureWindCopy=this.createRenderTarget(a.RGBAFormat,d.width,d.height),this.textureWindCopy.needsUpdate=!0},createRenderTarget:function(c,d,e,b){return c=c||a.RGBAFormat,d=d||this.n,e=e||this.n,b=b||a.NearestFilter,new a.WebGLRenderTarget(d,e,{wrapS:a.RepeatWrapping,wrapT:a.RepeatWrapping,minFilter:b,magFilter:b,format:c,type:a.FloatType,stencilBuffer:!1})},initShaderVP:function(){this.shaderVP=new a.ShaderMaterial({uniforms:{random:{type:'f',value:1},textureV:{type:'t',value:this.textureV},textureRand:{type:'t',value:this.textureRand},texturePt:{type:'t',value:this.texturePt},speedScale:{type:'f',value:this.options.speedScale}},vertexShader:e,fragmentShader:this.initFragVP()})},initFragVP:function(){return' uniform sampler2D texturePt; uniform sampler2D textureRand; uniform sampler2D textureV; uniform float random; uniform float speedScale;const float width = '+this.n.toFixed(6)+';'+'const float height = '+this.n.toFixed(6)+';'+'void main() { vec2 uv = gl_FragCoord.xy / vec2(width, height); vec4 p = texture2D(texturePt, uv); vec2 pxy = p.xy; vec2 v = texture2D(textureV, pxy).xy; p.xy += speedScale * v * random; p.xy = fract(1.+ p.xy); p.w -= 0.002; if(p.w < 0.0) { p.xy = texture2D(textureRand, vec2 (fract(p.x * 41.1211332), fract(p.y * 11.32522 * random))).xy; p.w = fract(19. * p.x * random); } gl_FragColor = p; }'},initCopyShader:function(){var b=this.copyShader=new a.ShaderMaterial({uniforms:{resolution:{type:'v2',value:new a.Vector2(this.n,this.n)},texture:{type:'t',value:null}},vertexShader:e,fragmentShader:g});b.needsUpdate=!0},initScene:function(){var b=this.camera=new a.Camera;b.position.z=1,this.scene=new a.Scene;var c=new a.PlaneBufferGeometry(2,2),d=new a.MeshBasicMaterial,e=this.mesh=new a.Mesh(c,d);this.scene.add(e),this.scenePoints=new a.Scene;var f=new a.BufferGeometry},initParticleShader:function(){this.shaderPt=new a.ShaderMaterial({vertexShader:this.initVetexPt(),fragmentShader:this.initFragPt(),uniforms:{texturePt:{type:'t',value:this.texturePt}},transparent:!0})},initVetexPt:function(){return' uniform sampler2D texturePt; attribute vec2 uvs;void main(){vec4 p = texture2D(texturePt, uvs);gl_Position = vec4(2. * p.x - 1., 2. * p.y - 1., 0, 1.); gl_PointSize = 3.; } '},initFragPt:function(){return' void main(){ gl_FragColor = vec4(1.0, 1.0, 1.0, 1.); } '},initParticles:function(){this.initParticleShader();var d=this.options.ptN,e=this.n,h=this.n,f=new a.BufferGeometry,c=new Float32Array(d*3),g=new Float32Array(d*2);for(var b=0;b<d;b++)g[b*2]=b%e/e,g[b*2+1]=Math.floor(b/e)/h,c[b*3+0]=0,c[b*3+1]=0,c[b*3+2]=0;f.addAttribute('position',new a.BufferAttribute(c,3)),f.addAttribute('uvs',new a.BufferAttribute(g,2));var i=new a.Points(f,this.shaderPt);this.scenePoints.add(i)},updateAnim:function(){this.updatePt(),this.updateVP()},animate:function(){this.updateAnim(),requestAnimationFrame(this.animate.bind(this))},updatePt:function(){var a=this.shaderPt;if(!a)return;a.uniforms.texturePt.value=this.texturePt,a.uniforms.texturePt.needsUpdate=!0,this.renderer.setClearColor(0,0),this.isOrder?this.renderer.render(this.scenePoints,this.camera,this.textureWindCopy,!0):this.renderer.render(this.scenePoints,this.camera,this.textureWind,!0),this.updateBlur()},updateVP:function(){if(!this.shaderVP)return;this.mesh.material=this.shaderVP,this.shaderVP.uniforms.random.value=Math.random(),this.shaderVP.uniforms.random.needsUpdate=!0,this.shaderVP.uniforms.textureRand.value=this.textureRand,this.shaderVP.uniforms.textureRand.needsUpdate=!0,this.isOrder?(this.shaderVP.uniforms.texturePt.value=this.texturePtCopy,this.shaderVP.uniforms.texturePt.needsUpdate=!0,this.renderer.render(this.scene,this.camera,this.texturePt,!0)):(this.shaderVP.uniforms.texturePt.value=this.texturePt,this.shaderVP.uniforms.texturePt.needsUpdate=!0,this.renderer.render(this.scene,this.camera,this.texturePtCopy,!1)),this.isOrder=!this.isOrder},updateBlur:function(){var a=this.blurShader;if(!a)return;this.isOrer?(a.uniforms.texturePrev.value=this.textureWind,a.uniforms.texturePrev.needsUpdate=!0,a.uniforms.texture.value=this.textureWindCopy,a.uniforms.texture.needsUpdate=!0):(a.uniforms.texturePrev.value=this.textureWindCopy,a.uniforms.texturePrev.needsUpdate=!0,a.uniforms.texture.value=this.textureWind,a.uniforms.texture.needsUpdate=!0),a.needsUpdate=!0},initBlurShader:function(){this.blurShader=new a.ShaderMaterial({vertexShader:h,fragmentShader:this.initFragBlur(),uniforms:{texturePrev:{type:'t',value:null},texture:{type:'t',value:null}},transparent:!0})},initFragBlur:function(){return' varying vec2 vUv; uniform sampler2D texture; uniform sampler2D texturePrev;const float width = '+this.options.width.toFixed(6)+';'+'const float height = '+this.options.height.toFixed(6)+';'+'void main() { gl_FragColor = 0.7 * texture2D(texture, vUv) + 0.3 * texture2D(texturePrev, vUv);'+'gl_FragColor = vec4(1., 1., 1., 1) * gl_FragColor;'+'}'},copy:function(b,c){var a=this.mesh.material=this.copyShader;a.uniforms.texture.value=b,a.uniforms.texture.needsUpdate=!0,this.renderer.render(this.scene,this.camera,c,!0)}}),module.exports=b | ||
function a(b){this.options=c.deepMerge(a.options,b)}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.getColorFunc,f=' void main() {gl_Position = vec4( position, 1.0 );}',g=' uniform vec2 resolution; uniform sampler2D texture; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 color = texture2D(texture, uv).xyz; gl_FragColor = vec4(color, 1.0);}',h=' varying vec2 vUv; void main(){vUv = uv;gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );}';a.options={xN:360,yN:181,grids:function(a){return a.data},ptN:16e3,speedScale:1e-5,width:3600,height:1800,heatValue:function(b,c){var a=Math.sqrt(b*b+c*c);return a/=20,Math.max(Math.min(a,1),0)},heatFill:{to:'#ff00ef',from:'#09f0f0',space:'rgb',easing:'linear.Out.1'}},a=d.extend(a,{addTo:function(a){this._map=a;var b=this.three3D=a.three3D;this.renderer=b.renderer,this.projection=a.projection,this.initScene()},data:function(a){this.processing(a)},processing:function(o){var b=this.options,d=b.heatFill;d&&(d=e(d));var j=b.grids.bind(b),g=this._data=j(o),f=b.xN,i=b.yN,l,k,h,m,n,c=this.dataF32V=new Float32Array(f*i*4);for(var a in g)l=Math.floor(a/f),k=a%f,h=g[a],m=c[a*4+0]=h[0],n=c[a*4+1]=h[1],c[a*4+2]=0,c[a*4+3]=1},init:function(b){var a=this.options.ptN;this.n=Math.floor(Math.sqrt(a))+1,this.initCopyShader(),this.initWindMap(),this.initParticleTexture(),this.initShaderVP(),this.initParticles(),this.initBlurShader(),this.isInited=!0},updateHeatTexture:function(){var g=this.options,m=g.xN,k=g.yN,j=this._data,h=this.heatF32=new Float32Array(m*k*4),d=g.heatFill,n=g.heatValue,l,f,o,i;if(d){d=e(d);for(var a in j)l=j[a],o=n(l[0],l[1]),i=d(o),i=c.parse(i),f=i.arr,h[a*4+0]=f[0]/255,h[a*4+1]=f[1]/255,h[a*4+2]=f[2]/255,h[a*4+3]=f[3]}this.heatTexture=new b.DataTexture(this.heatF32,m,k,b.RGBAFormat,b.FloatType),this.heatTexture.needsUpdate=!0},updateData:function(){if(!this.isInited){this.init(),this.updateHeatTexture();return}this.updateHeatTexture()},render:function(a){a&&this.data(a),this.updateData()},initWindMap:function(){this.textureV=new b.DataTexture(this.dataF32V,this.options.xN,this.options.yN,b.RGBAFormat,b.FloatType),this.textureV.needsUpdate=!0},initRandomMap:function(){},initParticleTexture:function(){var d=this.options,e=this.n,g=e*e,c=new Float32Array(g*4);for(var a=0;a<g;a++)c[4*a+0]=Math.random(),c[4*a+1]=Math.random(),c[4*a+2]=Math.random(),c[4*a+3]=Math.random();var f=this.textureRand=new b.DataTexture(c,e,e,b.RGBAFormat,b.FloatType);f.needsUpdate=!0,this.texturePt=this.createRenderTarget(),this.texturePt.needsUpdate=!0,this.copy(f,this.texturePt),this.texturePtCopy=this.createRenderTarget(),this.texturePtCopy.needsUpdate=!0,this.copy(f,this.texturePtCopy),this.textureWind=this.createRenderTarget(b.RGBAFormat,d.width,d.height),this.textureWind.needsUpdate=!0,this.textureWindCopy=this.createRenderTarget(b.RGBAFormat,d.width,d.height),this.textureWindCopy.needsUpdate=!0},createRenderTarget:function(c,d,e,a){return c=c||b.RGBAFormat,d=d||this.n,e=e||this.n,a=a||b.NearestFilter,new b.WebGLRenderTarget(d,e,{wrapS:b.RepeatWrapping,wrapT:b.RepeatWrapping,minFilter:a,magFilter:a,format:c,type:b.FloatType,stencilBuffer:!1})},initShaderVP:function(){this.shaderVP=new b.ShaderMaterial({uniforms:{random:{type:'f',value:1},textureV:{type:'t',value:this.textureV},textureRand:{type:'t',value:this.textureRand},texturePt:{type:'t',value:this.texturePt},speedScale:{type:'f',value:this.options.speedScale}},vertexShader:f,fragmentShader:this.initFragVP()})},initFragVP:function(){return' uniform sampler2D texturePt; uniform sampler2D textureRand; uniform sampler2D textureV; uniform float random; uniform float speedScale;const float width = '+this.n.toFixed(6)+';'+'const float height = '+this.n.toFixed(6)+';'+'void main() { vec2 uv = gl_FragCoord.xy / vec2(width, height); vec4 p = texture2D(texturePt, uv); vec2 pxy = p.xy; vec2 v = texture2D(textureV, pxy).xy; p.xy += speedScale * v * random; p.xy = fract(1.+ p.xy); p.w -= 0.002; if(p.w < 0.0) { p.xy = texture2D(textureRand, vec2 (fract(p.x * 41.1211332), fract(p.y * 11.32522 * random))).xy; p.w = fract(19. * p.x * random); } gl_FragColor = p; }'},initCopyShader:function(){var a=this.copyShader=new b.ShaderMaterial({uniforms:{resolution:{type:'v2',value:new b.Vector2(this.n,this.n)},texture:{type:'t',value:null}},vertexShader:f,fragmentShader:g});a.needsUpdate=!0},initScene:function(){var a=this.camera=new b.Camera;a.position.z=1,this.scene=new b.Scene;var c=new b.PlaneBufferGeometry(2,2),d=new b.MeshBasicMaterial,e=this.mesh=new b.Mesh(c,d);this.scene.add(e),this.scenePoints=new b.Scene;var f=new b.BufferGeometry},initParticleShader:function(){this.shaderPt=new b.ShaderMaterial({vertexShader:this.initVetexPt(),fragmentShader:this.initFragPt(),uniforms:{texturePt:{type:'t',value:this.texturePt}},transparent:!0})},initVetexPt:function(){return' uniform sampler2D texturePt; attribute vec2 uvs;void main(){vec4 p = texture2D(texturePt, uvs);gl_Position = vec4(2. * p.x - 1., 2. * p.y - 1., 0, 1.); gl_PointSize = 3.; } '},initFragPt:function(){return' void main(){ gl_FragColor = vec4(1.0, 1.0, 1.0, 1.); } '},initParticles:function(){this.initParticleShader();var d=this.options.ptN,e=this.n,h=this.n,f=new b.BufferGeometry,c=new Float32Array(d*3),g=new Float32Array(d*2);for(var a=0;a<d;a++)g[a*2]=a%e/e,g[a*2+1]=Math.floor(a/e)/h,c[a*3+0]=0,c[a*3+1]=0,c[a*3+2]=0;f.addAttribute('position',new b.BufferAttribute(c,3)),f.addAttribute('uvs',new b.BufferAttribute(g,2));var i=new b.Points(f,this.shaderPt);this.scenePoints.add(i)},updateAnim:function(){this.updatePt(),this.updateVP()},animate:function(){this.updateAnim(),requestAnimationFrame(this.animate.bind(this))},updatePt:function(){var a=this.shaderPt;if(!a)return;a.uniforms.texturePt.value=this.texturePt,a.uniforms.texturePt.needsUpdate=!0,this.renderer.setClearColor(0,0),this.isOrder?this.renderer.render(this.scenePoints,this.camera,this.textureWindCopy,!0):this.renderer.render(this.scenePoints,this.camera,this.textureWind,!0),this.updateBlur()},updateVP:function(){if(!this.shaderVP)return;this.mesh.material=this.shaderVP,this.shaderVP.uniforms.random.value=Math.random(),this.shaderVP.uniforms.random.needsUpdate=!0,this.shaderVP.uniforms.textureRand.value=this.textureRand,this.shaderVP.uniforms.textureRand.needsUpdate=!0,this.isOrder?(this.shaderVP.uniforms.texturePt.value=this.texturePtCopy,this.shaderVP.uniforms.texturePt.needsUpdate=!0,this.renderer.render(this.scene,this.camera,this.texturePt,!0)):(this.shaderVP.uniforms.texturePt.value=this.texturePt,this.shaderVP.uniforms.texturePt.needsUpdate=!0,this.renderer.render(this.scene,this.camera,this.texturePtCopy,!1)),this.isOrder=!this.isOrder},updateBlur:function(){var a=this.blurShader;if(!a)return;this.isOrer?(a.uniforms.texturePrev.value=this.textureWind,a.uniforms.texturePrev.needsUpdate=!0,a.uniforms.texture.value=this.textureWindCopy,a.uniforms.texture.needsUpdate=!0):(a.uniforms.texturePrev.value=this.textureWindCopy,a.uniforms.texturePrev.needsUpdate=!0,a.uniforms.texture.value=this.textureWind,a.uniforms.texture.needsUpdate=!0),a.needsUpdate=!0},initBlurShader:function(){this.blurShader=new b.ShaderMaterial({vertexShader:h,fragmentShader:this.initFragBlur(),uniforms:{texturePrev:{type:'t',value:null},texture:{type:'t',value:null}},transparent:!0})},initFragBlur:function(){return' varying vec2 vUv; uniform sampler2D texture; uniform sampler2D texturePrev;const float width = '+this.options.width.toFixed(6)+';'+'const float height = '+this.options.height.toFixed(6)+';'+'void main() { gl_FragColor = 0.7 * texture2D(texture, vUv) + 0.3 * texture2D(texturePrev, vUv);'+'gl_FragColor = vec4(1., 1., 1., 1) * gl_FragColor;'+'}'},copy:function(b,c){var a=this.mesh.material=this.copyShader;a.uniforms.texture.value=b,a.uniforms.texture.needsUpdate=!0,this.renderer.render(this.scene,this.camera,c,!0)}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(a){return JSON.parse(JSON.stringify(a))}function f(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function a(c,d){this.options=b(e.deepMerge(a.options,d)),this.containner=e.getContainer(c),this.detect()}var d=require('three'),c=Math.PI,e=require('./../core/utils'),h=require('bcore/event'),g=e.getScreenPt,i=e.requestAnimationFrame,j=e.cancelAnimationFrame;a.options={isDetect:!1,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}}},a=h.extend(a,{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=b(e.deepMerge(this.options,a)))},initialize:function(a){this.initPlane(),this.initVariables(),this.initEvents(),this.loop()},initVariables:function(){var a=this.options;this.mouse={x:0,y:0},this.mouseOnDown=b(this.mouse),this.rotationTargetOnDown=b(a.rotation.target),this.lookAtTargetOnDown=b(a.lookAt.target),this.overRenderer=!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 j=this.options,e=j.rotation,b=e.value,i=e.target;e.autoRotateSpeed&&!this.isMouseDown&&(i.x+=e.autoRotateSpeed),Math.abs(i.x-b.x)+Math.abs(i.y-b.y)>e.limit&&f(b,i,e.speed);var a=j.distance;Math.abs(a.target-a.value)>a.limit&&(a.value+=(a.target-a.value)*a.speed);var m=j.center,l=m.value,g=m.target;Math.abs(g.x-l.x)+Math.abs(g.y-l.y)>m.limit&&f(l,g,g.speed);var k=j.lookAt,c=k.value,h=k.target;Math.abs(h.x-c.x)+Math.abs(h.y-c.y)+Math.abs(h.z-c.z)>k.limit&&f(c,h,k.speed);var n=a.value*Math.sin(b.x)*Math.cos(b.y)+c.x,o=a.value*Math.sin(b.y)+c.y,p=a.value*Math.cos(b.x)*Math.cos(b.y)+c.z,d=this.camera;d.near/a.value>1e-4&&(d.far=Math.max(a.value*1e4,1),d.near=a.value/1e3,d.updateProjectionMatrix()),d.position.set(n,o,p),d.lookAt(c)},mouseDown:function(c){this.isMouseDown=!0,this.options.lookAt.target=b(this.options.lookAt.value),this.options.lookAt.speed=this.options.lookAt.speedMouseDown;var a=g(c);this.mouseOnDown.x=a[0],this.mouseOnDown.y=a[1],this.rotationTargetOnDown=b(this.options.rotation.target),this.lookAtTargetOnDown=b(this.options.lookAt.target),this.cameraClone=this.camera.clone(),this.downPoint=this.unproject(this.mouseOnDown.x,this.mouseOnDown.y),c.preventDefault()}}),a.prototype.mouseMove=function(p){if(!this.isMouseDown)return;p.preventDefault();var d=this.options,k=g(p),b=this.mouse,u=this.mouseOnDown;b.x=k[0],b.y=k[1];var t=d.distance.value/1e3,a=d.rotation.target,n=this.rotationTargetOnDown,j=d.interactive,e=j.mouseX,h=j.mouseY,l=d.lookAt.target,m=this.lookAtTargetOnDown,q=this.mouse.x-this.mouseOnDown.x,r=this.mouse.y-this.mouseOnDown.y;e.type==='rotatex'&&(a.x=n.x-q*e.phi),h.type==='rotatey'&&(a.y=n.y+r*h.phi,a.y=a.y>c/2?c/2:a.y,a.y=a.y<-c/2?-c/2:a.y);var i=this.downPoint,f=this.unproject(b.x,b.y);if(!(f&&i))return;var o=f.z-i.z,s=f.x-i.x;e.type==='panx'&&(l.x=m.x-s),h.type==='pany'&&(l.z=m.z-o)},a.prototype.mouseUp=function(b){b.preventDefault();var a=this.options;if(this.isMouseDown=!1,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,'\''))},a.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))},a.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},a.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},a.prototype.flyingTo=function(v,w,u,k){w=w||.75,u=u||0,k=k||0;var b,e;for(var r in v){var t=v[r],m=t.geometry;m.computeBoundingBox();var a=m.boundingBox;r===0&&(b=a.max.clone(),e=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),e.x>a.min.x&&(e.x=a.min.x),e.y>a.min.y&&(e.y=a.min.y),e.z>a.min.z&&(e.z=a.min.z)}var s=this.containner,A=s.width(),F=s.height(),f=b.x,g=b.y,p=b.z,j=e.x,i=e.y,l=e.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*c;this.lookAtTarget.x=-n+k,this.lookAtTarget.z=-o+k,this.lookAtTarget.y=0,this.rotation.x=c,this.rotation.y=c/2},a.prototype.flying=function(b){var a=this.options;a.distance.target=b.distance||a.distance.target,a.lookAt.target=b.lookAt||a.lookAt.target,a.rotation.target=b.rotation||a.rotation.target,b.autoRotateSpeed&&(a.rotation.autoRotateSpeed=b.autoRotateSpeed)},a.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},a.prototype.zoom=function(b){var a=this.options.distance;a.target=Math.max(Math.min(a.target*b,a.max),a.min)},module.exports=a | ||
function a(a){return JSON.parse(JSON.stringify(a))}function b(b,c,d){for(var a in b)b[a]=(c[a]-b[a])*d+b[a]}function c(b,d){this.options=a(f.deepMerge(c.options,d)),this.containner=f.getContainer(b),this.detect()}var d=require('three'),e=Math.PI,f=require('./../core/utils'),g=require('bcore/event'),h=f.getScreenPt,i=f.requestAnimationFrame,j=f.cancelAnimationFrame;c.options={isDetect:!1,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(b){b&&(this.options=a(f.deepMerge(this.options,b)))},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},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 j=this.options,f=j.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);var a=j.distance;Math.abs(a.target-a.value)>a.limit&&(a.value+=(a.target-a.value)*a.speed);var m=j.center,l=m.value,g=m.target;Math.abs(g.x-l.x)+Math.abs(g.y-l.y)>m.limit&&b(l,g,g.speed);var k=j.lookAt,d=k.value,h=k.target;Math.abs(h.x-d.x)+Math.abs(h.y-d.y)+Math.abs(h.z-d.z)>k.limit&&b(d,h,k.speed);var n=a.value*Math.sin(c.x)*Math.cos(c.y)+d.x,o=a.value*Math.sin(c.y)+d.y,p=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(n,o,p),e.lookAt(d)},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],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),c.preventDefault()}}),c.prototype.mouseMove=function(p){if(!this.isMouseDown)return;p.preventDefault();var c=this.options,k=h(p),b=this.mouse,u=this.mouseOnDown;b.x=k[0],b.y=k[1];var t=c.distance.value/1e3,a=c.rotation.target,n=this.rotationTargetOnDown,j=c.interactive,d=j.mouseX,g=j.mouseY,l=c.lookAt.target,m=this.lookAtTargetOnDown,q=this.mouse.x-this.mouseOnDown.x,r=this.mouse.y-this.mouseOnDown.y;d.type==='rotatex'&&(a.x=n.x-q*d.phi),g.type==='rotatey'&&(a.y=n.y+r*g.phi,a.y=a.y>e/2?e/2:a.y,a.y=a.y<-e/2?-e/2:a.y);var i=this.downPoint,f=this.unproject(b.x,b.y);if(!(f&&i))return;var o=f.z-i.z,s=f.x-i.x;d.type==='panx'&&(l.x=m.x-s),g.type==='pany'&&(l.z=m.z-o)},c.prototype.mouseUp=function(b){b.preventDefault();var a=this.options;if(this.isMouseDown=!1,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(b){var a=this.options;a.distance.target=b.distance||a.distance.target,a.lookAt.target=b.lookAt||a.lookAt.target,a.rotation.target=b.rotation||a.rotation.target,b.autoRotateSpeed&&(a.rotation.autoRotateSpeed=b.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 |
@@ -1,1 +0,1 @@ | ||
function c(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function a(c,d){c=this.container=b.getContainer(c),d=this.options=b.deepMerge(a.options,d),this.setProjection(),this.initialize(c,d)}var g=require('three'),e=require('bcore/event'),b=require('bcore/utils'),f=require('./../render/three3d'),l=require('./interactions'),h=require('./projection/sphere'),i=require('./projection/mecator'),j=require('./projection/normal'),k=require('./projection/origin'),d=Math.PI/180;a.options={projection:'plane',rotation:{x:-1.53407346410207,y:Math.PI/4},rotateSpeed:.1,autoRotateSpeed:0,distance:19378137,distanceSpeed:.3,center:null,moveSpeed:.2,globalAlpha:1,clearAlpha:1,angle:50,far:1e7,near:10,clearColor:0,background:'transparent',pointerEvents:'auto'},a=e.extend(a,{init3d:function(a){var d=this.options,b=this.three3D=new f(a,this.getThree3dOptions()),c=this.interaction=new l(a,this.getInteractionOptions());c.linkTo(b.camera)},getInteractionOptions:function(){var a=this.options,b=a.center;return a?b&&(b=this.processingCenter(a.center)):a=this.options,{rotation:{target:a.rotation,speed:a.rotateSpeed,autoRotateSpeed:a.autoRotateSpeed},distance:{target:a.distance,speed:a.distanceSpeed},center:{target:b},lookAt:{target:b,speed:a.moveSpeed}}},getThree3dOptions:function(){var a=this.options;return{alpha:a.globalAlpha,clearAlpha:a.clearAlpha,clearColor:a.clearColor,background:a.background,camera:{angle:a.angle,far:a.far,near:a.near},pointerEvents:a.pointerEvents}},initialize:function(b,c){var a=this.options.center||{lat:40,lng:100};if(!a)return console.log('必须有中心点');this.setCenter(a),this.init3d(b)},setProjection:function(){var b=this.options,a=b.projection;if(typeof a==='object')return;if(typeof a!=='string')return console.log('可能projection格式有误');this.projection={normal:j,sphere:h,plane:i,origin:k}[a]},setCenter:function(a){this.center=a,this.updatePosition(a)},setView:function(){},setRadius:function(){},getCenter:function(){},openDetect:function(){this.interaction.openDetect()},closeDetect:function(){this.interaction.closeDetect()},processingCenter:function(a){return a?a.x!==undefined&&a.y!==null?new g.Vector3(a.x,a.y,a.z):this.projection.project(a):null},updatePosition:function(a){var b=this.options,a=this.processingCenter(a);this.interaction&&this.interaction.flying({rotation:b.rotation,center:a,lookAt:a,distance:b.distance})},sphereFlying:function(a){var b=this.options;if(b.projection!=='sphere')return console.log('目前只支持球形墨卡托');var c=(90+a.lng)*d,e=a.lat*d,f={x:c,y:e};this.interaction&&this.interaction.flying({rotation:f})},updateCamera:function(){var a=this.options;this.three3D.updateCamera({angle:a.angle,far:a.far,near:a.near})},updateOptions:function(a){a&&(this.options=b.deepMerge(this.options,a)),this.interaction&&this.interaction.updateOptions(this.getInteractionOptions()),this.three3D.updateOptions(this.getThree3dOptions())},initEvents:function(){var a=this.interaction,b=this.options;a.on('zoom',function(){b.distance=a.options.distance.target}).on('rotate',function(){b.rotation=c(a.options.rotation.target)}).on('move',function(){b.center=c(a.options.lookAt.target),b.lookAt=c(a.options.lookAt.target)})}}),module.exports=a | ||
function b(b){var a;Array.isArray(b)?a=[]:a={};for(var c in b)a[c]=b[c];return a}function g(a,b){a=this.container=e.getContainer(a),b=this.options=e.deepMerge(g.options,b),this.setProjection(),this.initialize(a,b)}var c=require('three'),d=require('bcore/event'),e=require('bcore/utils'),f=require('./../render/three3d'),a=require('./interactions'),h=require('./projection/sphere'),i=require('./projection/mecator'),j=require('./projection/normal'),k=require('./projection/origin'),l=Math.PI/180;g.options={projection:'plane',rotation:{x:-1.53407346410207,y:Math.PI/4},rotateSpeed:.1,autoRotateSpeed:0,distance:19378137,distanceSpeed:.3,center:null,moveSpeed:.2,globalAlpha:1,clearAlpha:1,angle:50,far:1e7,near:10,clearColor:0,background:'transparent',pointerEvents:'auto'},g=d.extend(g,{init3d:function(b){var e=this.options,c=this.three3D=new f(b,this.getThree3dOptions()),d=this.interaction=new a(b,this.getInteractionOptions());d.linkTo(c.camera)},getInteractionOptions:function(){var a=this.options,b=a.center;return a?b&&(b=this.processingCenter(a.center)):a=this.options,{rotation:{target:a.rotation,speed:a.rotateSpeed,autoRotateSpeed:a.autoRotateSpeed},distance:{target:a.distance,speed:a.distanceSpeed},center:{target:b},lookAt:{target:b,speed:a.moveSpeed}}},getThree3dOptions:function(){var a=this.options;return{alpha:a.globalAlpha,clearAlpha:a.clearAlpha,clearColor:a.clearColor,background:a.background,camera:{angle:a.angle,far:a.far,near:a.near},pointerEvents:a.pointerEvents}},initialize:function(b,c){var a=this.options.center||{lat:40,lng:100};if(!a)return console.log('必须有中心点');this.setCenter(a),this.init3d(b)},setProjection:function(){var b=this.options,a=b.projection;if(typeof a==='object')return;if(typeof a!=='string')return console.log('可能projection格式有误');this.projection={normal:j,sphere:h,plane:i,origin:k}[a]},setCenter:function(a){this.center=a,this.updatePosition(a)},setView:function(){},setRadius:function(){},getCenter:function(){},openDetect:function(){this.interaction.openDetect()},closeDetect:function(){this.interaction.closeDetect()},processingCenter:function(a){return a?a.x!==undefined&&a.y!==null?new c.Vector3(a.x,a.y,a.z):this.projection.project(a):null},updatePosition:function(a){var b=this.options,a=this.processingCenter(a);this.interaction&&this.interaction.flying({rotation:b.rotation,center:a,lookAt:a,distance:b.distance})},sphereFlying:function(a){var b=this.options;if(b.projection!=='sphere')return console.log('目前只支持球形墨卡托');var c=(90+a.lng)*l,d=a.lat*l,e={x:c,y:d};this.interaction&&this.interaction.flying({rotation:e})},updateCamera:function(){var a=this.options;this.three3D.updateCamera({angle:a.angle,far:a.far,near:a.near})},updateOptions:function(a){a&&(this.options=e.deepMerge(this.options,a)),this.interaction&&this.interaction.updateOptions(this.getInteractionOptions()),this.three3D.updateOptions(this.getThree3dOptions())},initEvents:function(){var a=this.interaction,c=this.options;a.on('zoom',function(){c.distance=a.options.distance.target}).on('rotate',function(){c.rotation=b(a.options.rotation.target)}).on('move',function(){c.center=b(a.options.lookAt.target),c.lookAt=b(a.options.lookAt.target)})}}),module.exports=g |
@@ -1,1 +0,1 @@ | ||
var c=require('three'),d=Math.log,e=Math.tan,f=Math.atan,g=Math.exp,b=Math.PI,h,i,a=b/180;module.exports={project:function(f,i,j,k){if(f.lat===null||f.lat===undefined)return;if(f.lng===null||f.lng===undefined)return;var h=this.radius,l=this.latMax,m=Math.max(Math.min(l,f.lat),-l),n=f.lng*a,g=m*a;g=d(e(b/4+g/2)),i=this.x+i||0,j=this.y+j||0,k=this.z+k||0;var o=new c.Vector3(h*g+i,j,h*n+k);return o},unProject:function(d,k,m,l){var c=1/this.radius,e=(d.z-(l||0))*c,j=(d.x-(k||0))*c;return i=e/a,h=(2*f(g(j))-b/2)/a,{lat:h,lng:i}},getNormal:function(){return new c.Vector3(0,1,0)},x:0,y:0,z:0,radius:6378137,type:'mecator',latMax:85.05112877980659} | ||
var a=require('three'),b=Math.log,c=Math.tan,e=Math.atan,f=Math.exp,g=Math.PI,h,i,j=g/180;module.exports={project:function(d,h,i,k){if(d.lat===null||d.lat===undefined)return;if(d.lng===null||d.lng===undefined)return;var f=this.radius,l=this.latMax,m=Math.max(Math.min(l,d.lat),-l),n=d.lng*j,e=m*j;e=b(c(g/4+e/2)),h=this.x+h||0,i=this.y+i||0,k=this.z+k||0;var o=new a.Vector3(f*e+h,i,f*n+k);return o},unProject:function(b,k,m,l){var a=1/this.radius,c=(b.z-(l||0))*a,d=(b.x-(k||0))*a;return i=c/j,h=(2*e(f(d))-g/2)/j,{lat:h,lng:i}},getNormal:function(){return new a.Vector3(0,1,0)},x:0,y:0,z:0,radius:6378137,type:'mecator',latMax:85.05112877980659} |
@@ -1,1 +0,1 @@ | ||
var b=require('three'),a=6378137;module.exports={project:function(e,c,d){return c=c||1,d=d||1,new b.Vector3(e.lng*a/180*c,0,-e.lat*a/180*d)},unProject:function(a,b,c){},radius:a,type:'origin_2d'} | ||
var a=require('three'),b=6378137;module.exports={project:function(e,c,d){return c=c||1,d=d||1,new a.Vector3(e.lng*b/180*c,0,-e.lat*b/180*d)},unProject:function(a,b,c){},radius:b,type:'origin_2d'} |
@@ -1,1 +0,1 @@ | ||
var b=require('three'),a=6378137;module.exports={project:function(c,d,e,f){return new b.Vector3(c.lng*a/180+(d||0),e||0,-c.lat*a/180*1.5+(f||0))},unProject:function(a,b,c){},radius:a,type:'origin'} | ||
var a=require('three'),b=6378137;module.exports={project:function(c,d,e,f){return new a.Vector3(c.lng*b/180+(d||0),e||0,-c.lat*b/180*1.5+(f||0))},unProject:function(a,b,c){},radius:b,type:'origin'} |
@@ -1,1 +0,1 @@ | ||
var l=require('three'),m=Math.PI,c=Math.cos,g=Math.sin,o=Math.asin,k=Math.atan,n=Math.exp,f,d,h,i,j,e,a,b=m/180;module.exports={project:function(k,n){if(n=n||1,k.lat===null||k.lat===undefined)return;if(k.lng===null||k.lng===undefined)return;if(!k)return;f=k.lat,d=k.lng,e=-d*b,a=f*b;var m=this.radius*n;h=m*c(e)*c(a)+this.x0,j=m*g(e)*c(a)+this.z0,i=m*g(a)+this.y0;var o=new l.Vector3(h,i,j);return o},unProject:function(e){var a=e.x-this.x0,g=e.y-this.y0,c=e.z-this.z0,h=Math.sqrt(a*a+c*c),i=k(g/h),j=c/a,l=k(j);return f=i/b,d=-l/b,a<0&&(d-=180),{lat:f,lng:d}},getNormal:function(k,m){if(m=m||1,k.lat===null||k.lat===undefined)return;if(k.lng===null||k.lng===undefined)return;if(!k)return;f=k.lat,d=k.lng,e=-d*b,a=f*b,h=c(e)*c(a)+this.x0,j=g(e)*c(a)+this.z0,i=g(a)+this.y0;var n=new l.Vector3(h,i,j).normalize();return n},radius:6378137,x0:0,y0:0,z0:0,type:'sphere'} | ||
var b=require('three'),i=Math.PI,c=Math.cos,e=Math.sin,f=Math.asin,g=Math.atan,h=Math.exp,a,j,k,l,m,n,o,p=i/180;module.exports={project:function(d,g){if(g=g||1,d.lat===null||d.lat===undefined)return;if(d.lng===null||d.lng===undefined)return;if(!d)return;a=d.lat,j=d.lng,n=-j*p,o=a*p;var f=this.radius*g;k=f*c(n)*c(o)+this.x0,m=f*e(n)*c(o)+this.z0,l=f*e(o)+this.y0;var h=new b.Vector3(k,l,m);return h},unProject:function(d){var b=d.x-this.x0,e=d.y-this.y0,c=d.z-this.z0,f=Math.sqrt(b*b+c*c),h=g(e/f),i=c/b,k=g(i);return a=h/p,j=-k/p,b<0&&(j-=180),{lat:a,lng:j}},getNormal:function(d,f){if(f=f||1,d.lat===null||d.lat===undefined)return;if(d.lng===null||d.lng===undefined)return;if(!d)return;a=d.lat,j=d.lng,n=-j*p,o=a*p,k=c(n)*c(o)+this.x0,m=e(n)*c(o)+this.z0,l=e(o)+this.y0;var g=new b.Vector3(k,l,m).normalize();return g},radius:6378137,x0:0,y0:0,z0:0,type:'sphere'} |
@@ -5,3 +5,3 @@ { | ||
"description": "3d map visualization lib", | ||
"version": "0.1.56", | ||
"version": "0.1.57", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test" |
@@ -1,1 +0,1 @@ | ||
function b(a,d){this.three3D=a,this.options=c.deepMerge(b.options,d),this.initPhysic(),this.initPreview()}var a=require('three'),c=require('bcore/utils'),e=require('./physic'),f=require('./../core/utils').getSprite;b.options={ptN:6400,weight:function(a){return a.weight||a.mass||a.m||1},sprite:{drawN:31,color:{from:'hsla(0,100%,50%,0.8)',to:'hsla(0,100%,50%,0)',easing:'Linear.None.11.7',space:'rgb'}},material:{blending:a.AdditiveBlending,transparent:!0}},b.prototype={init:function(){var e=this.options,i=e.ptN,w=this._data,u=w.nodes,c=new a.Geometry,m=100,j=Math.ceil(Math.sqrt(i)),k=new Float32Array(i*3),l=new Float32Array(i*4),o=new Float32Array(i*2),q=new Float32Array(i*1),b=0,t=e.weight.bind(e);for(var p=0;p<j;p++)for(var n=0;n<j;n++)d=u[b]||{},q[b*1]=t(d)||1e-4,k[b*3+0]=Math.random()*m,k[b*3+1]=Math.random()*m,k[b*3+2]=Math.random()*m,l[b*3+0]=0,l[b*3+1]=.5,l[b*3+2]=1,o[b*2+0]=p/j,o[b*2+1]=n/j,b++;var c=new a.BufferGeometry;c.addAttribute('position',new a.BufferAttribute(k,3)),c.addAttribute('uvs',new a.BufferAttribute(o,2)),c.addAttribute('pcolor',new a.BufferAttribute(l,3)),c.addAttribute('mass',new a.BufferAttribute(q,1));var v=f(e.sprite),r=new a.Texture(v);r.needsUpdate=!0;var x=this.material=new a.ShaderMaterial({depthWrite:!1,transparent:e.material.transparent,uniforms:{texture:{type:'t',value:this.physicRender.textureP},sprite:{type:'t',value:r}},blending:e.material.blending,vertexShader:g,fragmentShader:h}),s=this.points=new a.Points(c,x);s.frustumCulled=!1,this.three3D.add(s)},initPhysic:function(){this.physicRender=new e(this.three3D,{ptN:this.options.ptN})},render:function(a){this._data=a,this.physicRender.render(a),this.init()},updateAnim:function(){this.physicRender.updateAnim(),this.updatePreview()},initPreview:function(){var c=new a.PlaneGeometry(105,105,32),b=new a.MeshBasicMaterial({color:'#fff',side:a.DoubleSide});b.needsUpdate=!0;var d=this.meshPrev=new a.Mesh(c,b);this.three3D.add(d)},updatePreview:function(){this.meshPrev.material.map=this.physicRender.textureLinkForce}};var g='uniform sampler2D texture;attribute vec3 pcolor;attribute vec2 uvs;attribute float mass;varying vec3 color;void main() { color = pcolor; gl_PointSize = mass * 3.0; vec3 pos = texture2D(texture, uvs).xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( pos, 1.0 );}',h=' uniform sampler2D sprite; varying vec3 color; void main() { vec2 uv = vec2(gl_PointCoord.x,gl_PointCoord.y); vec4 texture2d = texture2D(sprite, uv); gl_FragColor = texture2d;}';module.exports=b | ||
function a(b,d){this.three3D=b,this.options=c.deepMerge(a.options,d),this.initPhysic(),this.initPreview()}var b=require('three'),c=require('bcore/utils'),e=require('./physic'),f=require('./../core/utils').getSprite;a.options={ptN:6400,weight:function(a){return a.weight||a.mass||a.m||1},sprite:{drawN:31,color:{from:'hsla(0,100%,50%,0.8)',to:'hsla(0,100%,50%,0)',easing:'Linear.None.11.7',space:'rgb'}},material:{blending:b.AdditiveBlending,transparent:!0}},a.prototype={init:function(){var e=this.options,i=e.ptN,w=this._data,u=w.nodes,c=new b.Geometry,m=100,j=Math.ceil(Math.sqrt(i)),k=new Float32Array(i*3),l=new Float32Array(i*4),o=new Float32Array(i*2),q=new Float32Array(i*1),a=0,t=e.weight.bind(e);for(var p=0;p<j;p++)for(var n=0;n<j;n++)d=u[a]||{},q[a*1]=t(d)||1e-4,k[a*3+0]=Math.random()*m,k[a*3+1]=Math.random()*m,k[a*3+2]=Math.random()*m,l[a*3+0]=0,l[a*3+1]=.5,l[a*3+2]=1,o[a*2+0]=p/j,o[a*2+1]=n/j,a++;var c=new b.BufferGeometry;c.addAttribute('position',new b.BufferAttribute(k,3)),c.addAttribute('uvs',new b.BufferAttribute(o,2)),c.addAttribute('pcolor',new b.BufferAttribute(l,3)),c.addAttribute('mass',new b.BufferAttribute(q,1));var v=f(e.sprite),r=new b.Texture(v);r.needsUpdate=!0;var x=this.material=new b.ShaderMaterial({depthWrite:!1,transparent:e.material.transparent,uniforms:{texture:{type:'t',value:this.physicRender.textureP},sprite:{type:'t',value:r}},blending:e.material.blending,vertexShader:g,fragmentShader:h}),s=this.points=new b.Points(c,x);s.frustumCulled=!1,this.three3D.add(s)},initPhysic:function(){this.physicRender=new e(this.three3D,{ptN:this.options.ptN})},render:function(a){this._data=a,this.physicRender.render(a),this.init()},updateAnim:function(){this.physicRender.updateAnim(),this.updatePreview()},initPreview:function(){var c=new b.PlaneGeometry(105,105,32),a=new b.MeshBasicMaterial({color:'#fff',side:b.DoubleSide});a.needsUpdate=!0;var d=this.meshPrev=new b.Mesh(c,a);this.three3D.add(d)},updatePreview:function(){this.meshPrev.material.map=this.physicRender.textureLinkForce}};var g='uniform sampler2D texture;attribute vec3 pcolor;attribute vec2 uvs;attribute float mass;varying vec3 color;void main() { color = pcolor; gl_PointSize = mass * 3.0; vec3 pos = texture2D(texture, uvs).xyz; gl_Position = projectionMatrix * modelViewMatrix * vec4( pos, 1.0 );}',h=' uniform sampler2D sprite; varying vec3 color; void main() { vec2 uv = vec2(gl_PointCoord.x,gl_PointCoord.y); vec4 texture2d = texture2D(sprite, uv); gl_FragColor = texture2d;}';module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(d,a){this.three3D=d,this.isOrder=!0,this.isable=!1,this.check(),a=this.options=c.deepMerge(b.options,a)}var a=require('three'),c=require('bcore/utils'),e=require('./force');b.options={ptNMax:14400,force:{newton:{minLength:10,G:.4,k:1e-5},resistance:{k:1e-4,min:.2}},mass:function(a){return a.weight||a.m||a.mass||1},v:function(a){return a.v||{x:0,y:0,z:0}},p:function(a){return a.p||a.position||{x:Math.random(),y:Math.random(),z:Math.random()}}},b.prototype={draw:function(){if(!this.isable)return;this._force=new e(this.options.force),this.initScene();var b=this.textureP=this.createRenderTarget(a.RGBAFormat),c=this.textureV=this.createRenderTarget(a.RGBAFormat),g=this.textureTmp=this.createRenderTarget(a.RGBAFormat),d=this.texturePCopy=b.clone(),f=this.textureVCopy=c.clone();this._links&&this.drawLinks(),this.resetTexture(),b.needsUpdate=c.needsUpdate=f.needsUpdate=d.needsUpdate=!0,this.shaderPV=this.createShader({frag:this.createFragV()}),this.shaderVP=this.createShader({frag:this.createFragS()})},render:function(a){a&&this.data(a),this.draw()},data:function(a){this.nodes(a.nodes),this.links(a.links)},nodes:function(j){if(!j)return;this._nodes=j;var b=this.options,c=j.length;if(c>b.ptNMax)return console.log('数据量太大 超过最大限制'+b.ptNMax+'个');var d=this.precision=Math.ceil(Math.sqrt(c)),n=b.mass.bind(b),o=b.v.bind(b),p=b.p.bind(b),g=new Float32Array(c*4),f=new Float32Array(c*4),e=new Float32Array(c*4),q=new Float32Array(c*4),m,a,i,k,l,r={x:1e14,y:1e14,z:1e14},s={x:0,y:0,z:0};for(var h=0;h<d*d;h++)l=j[h]||{},a=4*h,m=n(l)||0,e[a+0]=m,e[a+1]=0,e[a+2]=0,e[a+3]=0,i=o(l)||s,g[a+0]=i.x,g[a+1]=i.y,g[a+2]=i.z,g[a+3]=1,k=p(l)||r,f[a+0]=k.x,f[a+1]=k.y,f[a+2]=k.z,f[a+3]=1;this.vDataTexture=this.getDataTexture(g,d),this.pDataTexture=this.getDataTexture(f,d),this.mDataTexture=this.getDataTexture(e,d),this.cleanDataTexture=this.getDataTexture(q,d)},getDataTexture:function(f,d,b,e){e=e||a.RGBAFormat,b=b||d;var c=new a.DataTexture(f,d,b,a.RGBAFormat,a.FloatType);return c.needsUpdate=!0,c},check:function(){var b=this.renderer=this.three3D.renderer,a=b.getContext();if(!a.getExtension('OES_texture_float'))return console.log('No OES_texture_float support for float textures!');if(a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS)==0)return console.log('No support for vertex shader textures!');this.isable=!0},updateAnim:function(){var a=this.textureP,b=this.textureV,c=this.textureVCopy,d=this.texturePCopy;this.updateLinkForce(),this.isOrder?(this.updatePV(a,b,c),this.updateVP(a,c,d)):(this.updatePV(d,c,b),this.updateVP(d,b,a)),this.renderer.render(this.scene,this.camera,this.textureTmp),this.isOrder=!this.isOrder},updatePV:function(b,c,d){this.mesh.material=this.shaderPV;var a=this.shaderPV.uniforms;a.textureP.value=b,a.textureP.needsUpdate=!0,a.textureLinkForce.value=this.textureLinkForce,a.textureLinkForce.needsUpdate=!0,a.textureV.value=c,a.textureV.needsUpdate=!0,this.renderer.render(this.scene,this.camera,d)},updateVP:function(b,c,d){this.mesh.material=this.shaderVP;var a=this.shaderPV.uniforms;a.textureP.value=b,a.textureP.needsUpdate=!0,a.textureV.value=c,a.textureV.needsUpdate=!0,this.renderer.render(this.scene,this.camera,d)},initScene:function(){var e=this.camera=new a.Camera,b=this.precision;e.position.z=1,this.scene=new a.Scene;var c=this.copyShader=new a.ShaderMaterial({uniforms:{resolution:{type:'v2',value:new a.Vector2(b,b)},texture:{type:'t',value:null}},vertexShader:d,fragmentShader:f});c.needsUpdate=!0;var g=this.mesh=new a.Mesh(new a.PlaneBufferGeometry(2,2),c);this.scene.add(g)},copy:function(b,c){var a=this.mesh.material=this.copyShader;a.uniforms.texture.value=b,a.uniforms.texture.needsUpdate=!0,this.renderer.render(this.scene,this.camera,c,!0)},createShader:function(e){var b=this.precision,c={dt:{type:'f',value:1},resolution:{type:'v2',value:new a.Vector2(b,b)},textureP:{type:'t',value:null},textureLinkForce:{type:'t',value:null},textureV:{type:'t',value:null},textureM:{type:'t',value:this.mDataTexture}};return new a.ShaderMaterial({uniforms:c,vertexShader:d,fragmentShader:e.frag})},createRenderTarget:function(c){var b=this.precision;return new a.WebGLRenderTarget(b,b,{wrapS:a.RepeatWrapping,wrapT:a.RepeatWrapping,minFilter:a.NearestFilter,magFilter:a.NearestFilter,format:c,type:a.FloatType,stencilBuffer:!1})},createFragV:function(){var a=this._force,b=a.genNewton(),c=a.genResistance();return' uniform vec2 resolution; uniform sampler2D textureP; uniform sampler2D textureLinkForce; uniform sampler2D textureV; uniform sampler2D textureM; uniform float dt; const float w ='+this.precision+'.0; const float h = '+this.precision+'.0;'+b+c+'void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 p = texture2D(textureP, uv).xyz; vec3 v = texture2D(textureV, uv).xyz; float m = texture2D(textureM, uv).x; vec3 f = vec3(0.,0.,0.); for(float i=0.; i < w; i++){ for(float j=0.; j < h; j++){ vec2 uv1 = vec2( i + 0.5, j + 0.5 ) / resolution.xy; vec3 p1 = texture2D(textureP, uv1).xyz; vec3 dir = p1 - p; float m1 = texture2D(textureM, uv1).x; f = f + getNewtonForce(dir, m, m1); } }'+' v = v + (f / m + getResistance(v) ) * dt; gl_FragColor = vec4(v, 1.0); }'},createFragS:function(){return' uniform vec2 resolution; uniform sampler2D textureP; uniform sampler2D textureV; uniform float dt; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 s = texture2D(textureP, uv).xyz; vec3 v = texture2D(textureV, uv).xyz; s = s + dt * v; gl_FragColor = vec4(s, 1.0); }'},updateForce:function(){this._force.updateOptions(this.options.force),this.shaderPV.fragmentShader=this.createFragV(),this.shaderPV.needsUpdate=!0},updateOptions:function(a){this.options=c.deepMerge(b.options,a)},resetTexture:function(){this.copy(this.pDataTexture,this.texturePCopy),this.copy(this.pDataTexture,this.textureP),this.copy(this.vDataTexture,this.textureV),this.copy(this.vDataTexture,this.textureVCopy),this.copy(this.vDataTexture,this.textureLinkForce),this.copy(this.vDataTexture,this.textureTmp)}},b.prototype=c.extend(b.prototype,require('./physic.links'));var d=' void main() {gl_Position = vec4( position, 1.0 );}',f=' uniform vec2 resolution; uniform sampler2D texture; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 color = texture2D(texture, uv).xyz; gl_FragColor = vec4(color, 1.0);}';module.exports=b | ||
function a(d,b){this.three3D=d,this.isOrder=!0,this.isable=!1,this.check(),b=this.options=c.deepMerge(a.options,b)}var b=require('three'),c=require('bcore/utils'),d=require('./force');a.options={ptNMax:14400,force:{newton:{minLength:10,G:.4,k:1e-5},resistance:{k:1e-4,min:.2}},mass:function(a){return a.weight||a.m||a.mass||1},v:function(a){return a.v||{x:0,y:0,z:0}},p:function(a){return a.p||a.position||{x:Math.random(),y:Math.random(),z:Math.random()}}},a.prototype={draw:function(){if(!this.isable)return;this._force=new d(this.options.force),this.initScene();var a=this.textureP=this.createRenderTarget(b.RGBAFormat),c=this.textureV=this.createRenderTarget(b.RGBAFormat),g=this.textureTmp=this.createRenderTarget(b.RGBAFormat),e=this.texturePCopy=a.clone(),f=this.textureVCopy=c.clone();this._links&&this.drawLinks(),this.resetTexture(),a.needsUpdate=c.needsUpdate=f.needsUpdate=e.needsUpdate=!0,this.shaderPV=this.createShader({frag:this.createFragV()}),this.shaderVP=this.createShader({frag:this.createFragS()})},render:function(a){a&&this.data(a),this.draw()},data:function(a){this.nodes(a.nodes),this.links(a.links)},nodes:function(j){if(!j)return;this._nodes=j;var b=this.options,c=j.length;if(c>b.ptNMax)return console.log('数据量太大 超过最大限制'+b.ptNMax+'个');var d=this.precision=Math.ceil(Math.sqrt(c)),n=b.mass.bind(b),o=b.v.bind(b),p=b.p.bind(b),g=new Float32Array(c*4),f=new Float32Array(c*4),e=new Float32Array(c*4),q=new Float32Array(c*4),m,a,i,k,l,r={x:1e14,y:1e14,z:1e14},s={x:0,y:0,z:0};for(var h=0;h<d*d;h++)l=j[h]||{},a=4*h,m=n(l)||0,e[a+0]=m,e[a+1]=0,e[a+2]=0,e[a+3]=0,i=o(l)||s,g[a+0]=i.x,g[a+1]=i.y,g[a+2]=i.z,g[a+3]=1,k=p(l)||r,f[a+0]=k.x,f[a+1]=k.y,f[a+2]=k.z,f[a+3]=1;this.vDataTexture=this.getDataTexture(g,d),this.pDataTexture=this.getDataTexture(f,d),this.mDataTexture=this.getDataTexture(e,d),this.cleanDataTexture=this.getDataTexture(q,d)},getDataTexture:function(f,d,a,e){e=e||b.RGBAFormat,a=a||d;var c=new b.DataTexture(f,d,a,b.RGBAFormat,b.FloatType);return c.needsUpdate=!0,c},check:function(){var b=this.renderer=this.three3D.renderer,a=b.getContext();if(!a.getExtension('OES_texture_float'))return console.log('No OES_texture_float support for float textures!');if(a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS)==0)return console.log('No support for vertex shader textures!');this.isable=!0},updateAnim:function(){var a=this.textureP,b=this.textureV,c=this.textureVCopy,d=this.texturePCopy;this.updateLinkForce(),this.isOrder?(this.updatePV(a,b,c),this.updateVP(a,c,d)):(this.updatePV(d,c,b),this.updateVP(d,b,a)),this.renderer.render(this.scene,this.camera,this.textureTmp),this.isOrder=!this.isOrder},updatePV:function(b,c,d){this.mesh.material=this.shaderPV;var a=this.shaderPV.uniforms;a.textureP.value=b,a.textureP.needsUpdate=!0,a.textureLinkForce.value=this.textureLinkForce,a.textureLinkForce.needsUpdate=!0,a.textureV.value=c,a.textureV.needsUpdate=!0,this.renderer.render(this.scene,this.camera,d)},updateVP:function(b,c,d){this.mesh.material=this.shaderVP;var a=this.shaderPV.uniforms;a.textureP.value=b,a.textureP.needsUpdate=!0,a.textureV.value=c,a.textureV.needsUpdate=!0,this.renderer.render(this.scene,this.camera,d)},initScene:function(){var d=this.camera=new b.Camera,a=this.precision;d.position.z=1,this.scene=new b.Scene;var c=this.copyShader=new b.ShaderMaterial({uniforms:{resolution:{type:'v2',value:new b.Vector2(a,a)},texture:{type:'t',value:null}},vertexShader:e,fragmentShader:f});c.needsUpdate=!0;var g=this.mesh=new b.Mesh(new b.PlaneBufferGeometry(2,2),c);this.scene.add(g)},copy:function(b,c){var a=this.mesh.material=this.copyShader;a.uniforms.texture.value=b,a.uniforms.texture.needsUpdate=!0,this.renderer.render(this.scene,this.camera,c,!0)},createShader:function(d){var a=this.precision,c={dt:{type:'f',value:1},resolution:{type:'v2',value:new b.Vector2(a,a)},textureP:{type:'t',value:null},textureLinkForce:{type:'t',value:null},textureV:{type:'t',value:null},textureM:{type:'t',value:this.mDataTexture}};return new b.ShaderMaterial({uniforms:c,vertexShader:e,fragmentShader:d.frag})},createRenderTarget:function(c){var a=this.precision;return new b.WebGLRenderTarget(a,a,{wrapS:b.RepeatWrapping,wrapT:b.RepeatWrapping,minFilter:b.NearestFilter,magFilter:b.NearestFilter,format:c,type:b.FloatType,stencilBuffer:!1})},createFragV:function(){var a=this._force,b=a.genNewton(),c=a.genResistance();return' uniform vec2 resolution; uniform sampler2D textureP; uniform sampler2D textureLinkForce; uniform sampler2D textureV; uniform sampler2D textureM; uniform float dt; const float w ='+this.precision+'.0; const float h = '+this.precision+'.0;'+b+c+'void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 p = texture2D(textureP, uv).xyz; vec3 v = texture2D(textureV, uv).xyz; float m = texture2D(textureM, uv).x; vec3 f = vec3(0.,0.,0.); for(float i=0.; i < w; i++){ for(float j=0.; j < h; j++){ vec2 uv1 = vec2( i + 0.5, j + 0.5 ) / resolution.xy; vec3 p1 = texture2D(textureP, uv1).xyz; vec3 dir = p1 - p; float m1 = texture2D(textureM, uv1).x; f = f + getNewtonForce(dir, m, m1); } }'+' v = v + (f / m + getResistance(v) ) * dt; gl_FragColor = vec4(v, 1.0); }'},createFragS:function(){return' uniform vec2 resolution; uniform sampler2D textureP; uniform sampler2D textureV; uniform float dt; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 s = texture2D(textureP, uv).xyz; vec3 v = texture2D(textureV, uv).xyz; s = s + dt * v; gl_FragColor = vec4(s, 1.0); }'},updateForce:function(){this._force.updateOptions(this.options.force),this.shaderPV.fragmentShader=this.createFragV(),this.shaderPV.needsUpdate=!0},updateOptions:function(b){this.options=c.deepMerge(a.options,b)},resetTexture:function(){this.copy(this.pDataTexture,this.texturePCopy),this.copy(this.pDataTexture,this.textureP),this.copy(this.vDataTexture,this.textureV),this.copy(this.vDataTexture,this.textureVCopy),this.copy(this.vDataTexture,this.textureLinkForce),this.copy(this.vDataTexture,this.textureTmp)}},a.prototype=c.extend(a.prototype,require('./physic.links'));var e=' void main() {gl_Position = vec4( position, 1.0 );}',f=' uniform vec2 resolution; uniform sampler2D texture; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 color = texture2D(texture, uv).xyz; gl_FragColor = vec4(color, 1.0);}';module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(a,d){var e=a.three3D;this._map=a,this.three3D=e,d=this.options=c.deepMerge(b.options,d),this.init(),this.update(),this.loop()}var c=require('bcore/utils'),a=require('three');require('./lib/RenderPass'),require('./lib/BloomPass'),require('./lib/ShaderPass'),require('./lib/EffectComposer'),require('./lib/shader/HorizontalTiltShiftShader'),require('./lib/shader/VerticalTiltShiftShader'),require('./lib/shader/BleachBypassShader'),b.options={focusX:.5,focusY:.5,blur:2,effectBleachOpacity:.6},b.prototype={init:function(){var c=this.three3D,g=c.scene,e=c.camera,k=this.options,f=new a.BloomPass(.6),h=this.effectBleach=new a.ShaderPass(a.BleachBypassShader);h.uniforms.opacity.value=.9;var i=this.renderPass=new a.RenderPass(g,e),j=this.hblur=new a.ShaderPass(a.HorizontalTiltShiftShader),d=this.vblur=new a.ShaderPass(a.VerticalTiltShiftShader),b=this.composer=new a.EffectComposer(c.renderer);b.addPass(i),b.addPass(f),b.addPass(j),b.addPass(d),d.renderToScreen=!0,b.render()},update:function(){var a=this.options,b=a.blur/this.three3D.width;this.hblur.uniforms.h.value=b,this.hblur.uniforms.r.value=a.focusX,this.vblur.uniforms.v.value=b,this.vblur.uniforms.r.value=a.focusY,this.effectBleach.uniforms.opacity.value=a.effectBleachOpacity},render:function(){this.composer.render()},loop:function(){this.render(),window.requestAnimationFrame(this.loop.bind(this))}},module.exports=b | ||
function a(c,d){var e=c.three3D;this._map=c,this.three3D=e,d=this.options=b.deepMerge(a.options,d),this.init(),this.update(),this.loop()}var b=require('bcore/utils'),c=require('three');require('./lib/RenderPass'),require('./lib/BloomPass'),require('./lib/ShaderPass'),require('./lib/EffectComposer'),require('./lib/shader/HorizontalTiltShiftShader'),require('./lib/shader/VerticalTiltShiftShader'),require('./lib/shader/BleachBypassShader'),a.options={focusX:.5,focusY:.5,blur:2,effectBleachOpacity:.6},a.prototype={init:function(){var b=this.three3D,g=b.scene,e=b.camera,k=this.options,f=new c.BloomPass(.6),h=this.effectBleach=new c.ShaderPass(c.BleachBypassShader);h.uniforms.opacity.value=.9;var i=this.renderPass=new c.RenderPass(g,e),j=this.hblur=new c.ShaderPass(c.HorizontalTiltShiftShader),d=this.vblur=new c.ShaderPass(c.VerticalTiltShiftShader),a=this.composer=new c.EffectComposer(b.renderer);a.addPass(i),a.addPass(f),a.addPass(j),a.addPass(d),d.renderToScreen=!0,a.render()},update:function(){var a=this.options,b=a.blur/this.three3D.width;this.hblur.uniforms.h.value=b,this.hblur.uniforms.r.value=a.focusX,this.vblur.uniforms.v.value=b,this.vblur.uniforms.r.value=a.focusY,this.effectBleach.uniforms.opacity.value=a.effectBleachOpacity},render:function(){this.composer.render()},loop:function(){this.render(),window.requestAnimationFrame(this.loop.bind(this))}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function a(b,d){var e=b.three3D;this._map=b,this.three3D=e,d=this.options=c.deepMerge(a.options,d),this.init(),this.update(),this.loop()}var c=require('bcore/utils'),b=require('three');require('./lib/RenderPass'),require('./lib/BloomPass'),require('./lib/ShaderPass'),require('./lib/EffectComposer'),require('./lib/BokehPass'),a.options={focus:1,maxblur:2,aperture:.025},a.prototype={init:function(){var a=this.three3D,e=a.scene,f=a.camera,c=this.options,h=this.renderPass=new b.RenderPass(e,f),g=this.bokeh=new b.BokehPass(e,f,{focus:c.focus,aperture:c.aperture,maxblur:c.maxblur,width:a.width,height:a.height}),d=this.composer=new b.EffectComposer(a.renderer);d.addPass(h),d.addPass(g),g.renderToScreen=!0,d.render()},update:function(){var a=this.options,b=this.bokeh.uniforms;b.focus.value=a.focus,b.aperture.value=a.aperture,b.maxblur.value=a.maxblur},render:function(){this.composer.render()},loop:function(){this.render(),window.requestAnimationFrame(this.loop.bind(this))}},module.exports=a | ||
function a(c,d){var e=c.three3D;this._map=c,this.three3D=e,d=this.options=b.deepMerge(a.options,d),this.init(),this.update(),this.loop()}var b=require('bcore/utils'),c=require('three');require('./lib/RenderPass'),require('./lib/BloomPass'),require('./lib/ShaderPass'),require('./lib/EffectComposer'),require('./lib/BokehPass'),a.options={focus:1,maxblur:2,aperture:.025},a.prototype={init:function(){var a=this.three3D,e=a.scene,f=a.camera,b=this.options,h=this.renderPass=new c.RenderPass(e,f),g=this.bokeh=new c.BokehPass(e,f,{focus:b.focus,aperture:b.aperture,maxblur:b.maxblur,width:a.width,height:a.height}),d=this.composer=new c.EffectComposer(a.renderer);d.addPass(h),d.addPass(g),g.renderToScreen=!0,d.render()},update:function(){var a=this.options,b=this.bokeh.uniforms;b.focus.value=a.focus,b.aperture.value=a.aperture,b.maxblur.value=a.maxblur},render:function(){this.composer.render()},loop:function(){this.render(),window.requestAnimationFrame(this.loop.bind(this))}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function b(a,d){d=this.options=c.deepMerge(b.options,d),a&&this.addTo(a),this.loop()}var c=require('./../core/utils'),a=require('three');b.options={width:2e7,height:2e7},b.prototype={init:function(){var b=this.options,d=new a.PlaneGeometry(b.width,b.height,10),c=this.material=new a.MeshBasicMaterial({side:a.DoubleSide,color:'#fff'});c.needsUpdate=!0;var e=this.mesh=new a.Mesh(d,c);this.three3D.add(e)},addTo:function(a){this._map=a,this.three3D=a.three3D,this.init()},preview:function(a){if(!a)return;this.texture=this.mesh.material.map=a,this.update()},update:function(){var a=this.texture;a&&(this.material.needsUpdate=!0)},loop:function(){this.update(),requestAnimationFrame(this.loop.bind(this))}},module.exports=b | ||
function a(c,d){d=this.options=b.deepMerge(a.options,d),c&&this.addTo(c),this.loop()}var b=require('./../core/utils'),c=require('three');a.options={width:2e7,height:2e7},a.prototype={init:function(){var a=this.options,d=new c.PlaneGeometry(a.width,a.height,10),b=this.material=new c.MeshBasicMaterial({side:c.DoubleSide,color:'#fff'});b.needsUpdate=!0;var e=this.mesh=new c.Mesh(d,b);this.three3D.add(e)},addTo:function(a){this._map=a,this.three3D=a.three3D,this.init()},preview:function(a){if(!a)return;this.texture=this.mesh.material.map=a,this.update()},update:function(){var a=this.texture;a&&(this.material.needsUpdate=!0)},loop:function(){this.update(),requestAnimationFrame(this.loop.bind(this))}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function a(c){this.options=b.deepMerge(a.options,c),this.init()}var d=require('three'),b=require('./../core/utils'),c=require('bcore/event'),e=b.requestAnimationFrame,f=b.cancelAnimationFrame;a.options={width:1e3,height:1e3,clearWithImage:!1,mode:'source-over'},a=c.extend(a,{init:function(a){this.initCanvas()},loadImage:function(c,b){return typeof a==='object'?this.image=a:this.loadImage(a,this.initCanvas.bind(this));var a=this.image=new Image;a.src=c,a.onload=function(){b&&b(a)}.bind(this)},initCanvas:function(){var a=this.options,c=a.width,d=a.height,b=this.canvas=document.createElement('canvas');b.width=c,b.height=d;var e=this.ctx=b.getContext('2d');e.globalCompositeOperation=a.mode,this.clear()},clear:function(){return this.image&&this.options.clearWithImage?this.ctx.drawImage(this.image,0,0,this.canvas.width,this.canvas.height):this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)},getCanvas:function(){return this.canvas},dot:function(c,d,e,b,a){a=a||b,this.ctx.drawImage(c,d-b,e-a,2*b,2*a)}}),module.exports=a | ||
function a(b){this.options=c.deepMerge(a.options,b),this.init()}var b=require('three'),c=require('./../core/utils'),d=require('bcore/event'),e=c.requestAnimationFrame,f=c.cancelAnimationFrame;a.options={width:1e3,height:1e3,clearWithImage:!1,mode:'source-over'},a=d.extend(a,{init:function(a){this.initCanvas()},loadImage:function(c,b){return typeof a==='object'?this.image=a:this.loadImage(a,this.initCanvas.bind(this));var a=this.image=new Image;a.src=c,a.onload=function(){b&&b(a)}.bind(this)},initCanvas:function(){var a=this.options,c=a.width,d=a.height,b=this.canvas=document.createElement('canvas');b.width=c,b.height=d;var e=this.ctx=b.getContext('2d');e.globalCompositeOperation=a.mode,this.clear()},clear:function(){return this.image&&this.options.clearWithImage?this.ctx.drawImage(this.image,0,0,this.canvas.width,this.canvas.height):this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)},getCanvas:function(){return this.canvas},dot:function(c,d,e,b,a){a=a||b,this.ctx.drawImage(c,d-b,e-a,2*b,2*a)}}),module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(a){a=this.options=c.deepMerge(b.options,a),this.initShader()}var a=require('three'),c=require('./../core/utils');b.options={shapeType:'circle',r:8e4,offset:1e5,color:'#0ff',indensity:.1,background:'#000',maxOpacity:1,blending:a.AdditiveBlending},b.prototype={initShader:function(){var b=this.options,e='varying vec2 vUv;void main(){vUv = uv;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;}',f=b.background,g=b.color,c=new a.Color(g),h=new a.Vector4(c.r,c.g,c.b,1),d=new a.Color(f),i=new a.Vector4(d.r,d.g,d.b,1),j={color:{type:'v4',value:h},background:{type:'v4',value:i},rx:{type:'f',value:b.rx||b.r},ry:{type:'f',value:b.ry||b.r},dx:{type:'f',value:b.offset+(b.rx||b.r)*2},dy:{type:'f',value:b.offset+(b.ry||b.r)*2},indensity:{type:'f',value:b.indensity}};this.material=new a.ShaderMaterial({uniforms:j,vertexShader:e,fragmentShader:this.getFragmentShader(),blending:b.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:a.SmoothShading})},getFragmentShader:function(){var a=this.options.shapeType,b;a==='circle'?b='ratio = (disX * disX + disY * disY) / (rx * rx + ry * ry);':a==='rect'?b='ratio = max(disX / rx , disY / ry);':a==='diamond'&&(b='ratio = (disX + disY ) / (rx + ry );');var c='uniform vec4 color;uniform vec4 background;uniform float dx;uniform float dy;uniform float rx;uniform float ry;uniform float indensity;varying vec2 vUv;void main() {float relativeX = mod(vUv.x, dx);float relativeY = mod(vUv.y, dy);float disX = abs(relativeX - dx * 0.5);float disY = abs(relativeY - dy * 0.5);float ratio;'+b+'ratio = pow(ratio, indensity);'+'gl_FragColor = ratio * background + (1.0 - ratio) * color;'+'}';return c},updateUniforms:function(){var f=this.material,c=f.uniforms,b=this.options,g=b.background,h=b.color,d=new a.Color(h),i=new a.Vector4(d.r,d.g,d.b,1),e=new a.Color(g),j=new a.Vector4(e.r,e.g,e.b,1);c.color.value=i,c.background.value=j,c.rx.value=b.rx||b.r,c.ry.value=b.ry||b.r,c.indensity.value=b.indensity,c.dx.value=b.offset+(b.rx||b.r)*2,c.dy.value=b.offset+(b.ry||b.r)*2},updateShader:function(){this.material.fragmentShader=this.getFragmentShader(),this.material.needsUpdate=!0},update:function(){this.updateShader(),this.updateUniforms()},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.updateUniforms()},getMaterial:function(){return this.material}},module.exports=b | ||
'use strict';function a(b){b=this.options=c.deepMerge(a.options,b),this.initShader()}var b=require('three'),c=require('./../core/utils');a.options={shapeType:'circle',r:8e4,offset:1e5,color:'#0ff',indensity:.1,background:'#000',maxOpacity:1,blending:b.AdditiveBlending},a.prototype={initShader:function(){var a=this.options,e='varying vec2 vUv;void main(){vUv = uv;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;}',f=a.background,g=a.color,c=new b.Color(g),h=new b.Vector4(c.r,c.g,c.b,1),d=new b.Color(f),i=new b.Vector4(d.r,d.g,d.b,1),j={color:{type:'v4',value:h},background:{type:'v4',value:i},rx:{type:'f',value:a.rx||a.r},ry:{type:'f',value:a.ry||a.r},dx:{type:'f',value:a.offset+(a.rx||a.r)*2},dy:{type:'f',value:a.offset+(a.ry||a.r)*2},indensity:{type:'f',value:a.indensity}};this.material=new b.ShaderMaterial({uniforms:j,vertexShader:e,fragmentShader:this.getFragmentShader(),blending:a.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:b.SmoothShading})},getFragmentShader:function(){var a=this.options.shapeType,b;a==='circle'?b='ratio = (disX * disX + disY * disY) / (rx * rx + ry * ry);':a==='rect'?b='ratio = max(disX / rx , disY / ry);':a==='diamond'&&(b='ratio = (disX + disY ) / (rx + ry );');var c='uniform vec4 color;uniform vec4 background;uniform float dx;uniform float dy;uniform float rx;uniform float ry;uniform float indensity;varying vec2 vUv;void main() {float relativeX = mod(vUv.x, dx);float relativeY = mod(vUv.y, dy);float disX = abs(relativeX - dx * 0.5);float disY = abs(relativeY - dy * 0.5);float ratio;'+b+'ratio = pow(ratio, indensity);'+'gl_FragColor = ratio * background + (1.0 - ratio) * color;'+'}';return c},updateUniforms:function(){var f=this.material,c=f.uniforms,a=this.options,g=a.background,h=a.color,d=new b.Color(h),i=new b.Vector4(d.r,d.g,d.b,1),e=new b.Color(g),j=new b.Vector4(e.r,e.g,e.b,1);c.color.value=i,c.background.value=j,c.rx.value=a.rx||a.r,c.ry.value=a.ry||a.r,c.indensity.value=a.indensity,c.dx.value=a.offset+(a.rx||a.r)*2,c.dy.value=a.offset+(a.ry||a.r)*2},updateShader:function(){this.material.fragmentShader=this.getFragmentShader(),this.material.needsUpdate=!0},update:function(){this.updateShader(),this.updateUniforms()},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.updateUniforms()},getMaterial:function(){return this.material}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(d,a){var e=this.texture=d.texture;a=this.options=c.deepMerge(b.options,a),this.initShader()}var a=require('three'),c=require('./../core/utils'),d=c.getSprite,e=require('jquery');b.options={maxOpacity:1,blending:a.AdditiveBlending,heightMax:5e6,wireframe:!1,indensity:1,dotSize:5,sprite:{type:'radian',isContinue:!1,drawN:1.15,color:{from:'rgba(255,255,255, 1)',to:'rgba(255,255,255, 1)',easing:'Linear.None.1.7',space:'rgb'}}},b.prototype={initShader:function(){var b=this.options,e='attribute vec2 uvs;attribute vec3 normals1;varying vec2 uvv;uniform sampler2D texture;uniform float heightMax;uniform float dotSize;void main(){uvv = uvs;vec3 pos = position;vec3 vNormal = normalize(normalMatrix * normals1);vec4 c = texture2D(texture, uvs);float luma = 0.299 * c.x + 0.587 * c.y + 0.114 * c.z;float indensity = pow(luma, 0.1);vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 ) + heightMax * vec4(vNormal * indensity, 0.0);gl_Position = projectionMatrix * mvPosition;gl_PointSize = dotSize;}',f=b.background,g=b.color,c=new a.Color(g),h=new a.Vector4(c.r,c.g,c.b,1),d=new a.Color(f),i=new a.Vector4(d.r,d.g,d.b,1),j={color:{type:'v4',value:h},background:{type:'v4',value:i},indensity:{type:'f',value:b.indensity},texture:{type:'t',value:this.texture},heightMax:{type:'f',value:b.heightMax},dotSize:{type:'f',value:b.dotSize}};this.material=new a.ShaderMaterial({uniforms:j,vertexShader:e,fragmentShader:this.getFragmentShader(),blending:b.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:a.SmoothShading,wireframe:b.wireframe})},getFragmentShader:function(){var a='varying vec2 uvv;uniform vec4 color;uniform float indensity;uniform sampler2D texture;void main() {gl_FragColor = texture2D(texture, uvv);}';return a},updateUniforms:function(){var f=this.material,b=f.uniforms,c=this.options,g=c.background,h=c.color,d=new a.Color(h),i=new a.Vector4(d.r,d.g,d.b,1),e=new a.Color(g),j=new a.Vector4(e.r,e.g,e.b,1);b.color.value=i,b.background.value=j,b.indensity.value=c.indensity,b.heightMax.value=c.heightMax,b.dotSize.value=c.dotSize},updateShader:function(){this.material.fragmentShader=this.getFragmentShader(),this.material.needsUpdate=!0},updateImage:function(b){var a=this.material.uniforms.texture.value;b&&(a.image=b),a&&a.image&&(a.needsUpdate=!0)},update:function(a){this.material.wireframe=this.options.wireframe,this.material.blending=this.options.blending,this.updateImage(a),this.updateShader(),this.updateUniforms(),this.material.needsUpdate=!0},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.update()},getMaterial:function(){return this.update(),this.material}},module.exports=b | ||
'use strict';function a(d,b){var e=this.texture=d.texture;b=this.options=c.deepMerge(a.options,b),this.initShader()}var b=require('three'),c=require('./../core/utils'),d=c.getSprite,e=require('jquery');a.options={maxOpacity:1,blending:b.AdditiveBlending,heightMax:5e6,wireframe:!1,indensity:1,dotSize:5,sprite:{type:'radian',isContinue:!1,drawN:1.15,color:{from:'rgba(255,255,255, 1)',to:'rgba(255,255,255, 1)',easing:'Linear.None.1.7',space:'rgb'}}},a.prototype={initShader:function(){var a=this.options,e='attribute vec2 uvs;attribute vec3 normals1;varying vec2 uvv;uniform sampler2D texture;uniform float heightMax;uniform float dotSize;void main(){uvv = uvs;vec3 pos = position;vec3 vNormal = normalize(normalMatrix * normals1);vec4 c = texture2D(texture, uvs);float luma = 0.299 * c.x + 0.587 * c.y + 0.114 * c.z;float indensity = pow(luma, 0.1);vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 ) + heightMax * vec4(vNormal * indensity, 0.0);gl_Position = projectionMatrix * mvPosition;gl_PointSize = dotSize;}',f=a.background,g=a.color,c=new b.Color(g),h=new b.Vector4(c.r,c.g,c.b,1),d=new b.Color(f),i=new b.Vector4(d.r,d.g,d.b,1),j={color:{type:'v4',value:h},background:{type:'v4',value:i},indensity:{type:'f',value:a.indensity},texture:{type:'t',value:this.texture},heightMax:{type:'f',value:a.heightMax},dotSize:{type:'f',value:a.dotSize}};this.material=new b.ShaderMaterial({uniforms:j,vertexShader:e,fragmentShader:this.getFragmentShader(),blending:a.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:b.SmoothShading,wireframe:a.wireframe})},getFragmentShader:function(){var a='varying vec2 uvv;uniform vec4 color;uniform float indensity;uniform sampler2D texture;void main() {gl_FragColor = texture2D(texture, uvv);}';return a},updateUniforms:function(){var f=this.material,a=f.uniforms,c=this.options,g=c.background,h=c.color,d=new b.Color(h),i=new b.Vector4(d.r,d.g,d.b,1),e=new b.Color(g),j=new b.Vector4(e.r,e.g,e.b,1);a.color.value=i,a.background.value=j,a.indensity.value=c.indensity,a.heightMax.value=c.heightMax,a.dotSize.value=c.dotSize},updateShader:function(){this.material.fragmentShader=this.getFragmentShader(),this.material.needsUpdate=!0},updateImage:function(b){var a=this.material.uniforms.texture.value;b&&(a.image=b),a&&a.image&&(a.needsUpdate=!0)},update:function(a){this.material.wireframe=this.options.wireframe,this.material.blending=this.options.blending,this.updateImage(a),this.updateShader(),this.updateUniforms(),this.material.needsUpdate=!0},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.update()},getMaterial:function(){return this.update(),this.material}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
'use strict';var a=require('three'),c=require('./../core/utils'),d=require('bcore/event'),b=function(a){this.options=c.deepMerge(b.options,a)};b.options={maxHeight:5e6,minHeight:5e5,histogramN:100,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:c.getLat,lng:c.getLng,id:function(a,b){return a.id||b},blending:a.AdditiveBlending,faceColor:function(b){return new a.Color('rgb(0,150,250)')}},b=d.extend(b,{addTo:function(a){this.three3D=a.three3D,this.init()},init:function(){var c=this.options,d=c.histogramN,b=this.geometry=new a.BufferGeometry,e=this.positionsF32=new Float32Array(d*8*3);b.addAttribute('position',new a.BufferAttribute(e,3,1).setDynamic(!0)),b.computeBoundingSphere();var f=this.material=this.genMaterial(),g=this.mesh=new a.Mesh(b,f);this.three3D.add(g)},genMaterial:function(){var b=this.options;return new a.ShaderMaterial({uniforms:uniforms,vertexShader:vertexShader,fragmentShader:fragmentShader,vertexColors:a.vertexColors,shading:a.SmoothShading,side:a.DoubleSide})}}) | ||
'use strict';var a=require('three'),b=require('./../core/utils'),c=require('bcore/event'),d=function(a){this.options=b.deepMerge(d.options,a)};d.options={maxHeight:5e6,minHeight:5e5,histogramN:100,ratio:1.01,size:1e5,color:65280,opacity:.1,value:function(a){return a.value},lat:b.getLat,lng:b.getLng,id:function(a,b){return a.id||b},blending:a.AdditiveBlending,faceColor:function(b){return new a.Color('rgb(0,150,250)')}},d=c.extend(d,{addTo:function(a){this.three3D=a.three3D,this.init()},init:function(){var c=this.options,d=c.histogramN,b=this.geometry=new a.BufferGeometry,e=this.positionsF32=new Float32Array(d*8*3);b.addAttribute('position',new a.BufferAttribute(e,3,1).setDynamic(!0)),b.computeBoundingSphere();var f=this.material=this.genMaterial(),g=this.mesh=new a.Mesh(b,f);this.three3D.add(g)},genMaterial:function(){var b=this.options;return new a.ShaderMaterial({uniforms:uniforms,vertexShader:vertexShader,fragmentShader:fragmentShader,vertexColors:a.vertexColors,shading:a.SmoothShading,side:a.DoubleSide})}}) |
@@ -1,1 +0,1 @@ | ||
'use strict';var a=require('three'),c=require('./../core/utils'),b=function(a){this.options=c.deepMerge(b.options,a)},d=0,e=0;b.options={lineN:1e3,ptN:100,maxOpacity:.2,weight:3,material:{blending:a.AdditiveBlending},style:{opacity:function(a){return a*a},hue:.5,color:function(b,c){return b=1-b,new a.Color().setHSL(c,1-b*.3,.3+Math.pow(b,8)*.6)}}};var f=0;b.prototype={addTo:function(a){this.three3D=a.three3D,this.init()},init:function(){var e=this.options,i=e.lineN,x=e.ptN,w=e.style.color.bind(e.style),v=e.style.hue,k=this.lines=[],n=this.colorGroup=[],f=this.geometry=new a.BufferGeometry,d=this.ptRealN=(x-1)*2,u=[],l,p,z,g=this.colorsF32=new Float32Array(d*i*4),m=this.indexesF32=new Float32Array(d*i*1),q=this.positionsF32=new Float32Array(d*i*3),r=[],s=[],t,b=0;for(var c=0;c<i;c++)for(var h=0;h<d;h++){s.push(1-h/d),k[c]=p=k[c]||[],n[c]=t=n[c]||[],l=new a.Vector3,u.push(l),p.push(l),z=w(v,h/d);var j=new a.Vector4(1,1,1,1);g[b*4+0]=1,g[b*4+1]=1,g[b*4+2]=1,g[b*4+3]=1,m[b]=b,b++,r.push(j),t.push(j)}f.addAttribute('cs',new a.BufferAttribute(g,4,1).setDynamic(!0)),f.addAttribute('indexes',new a.BufferAttribute(m,1)),f.addAttribute('position',new a.BufferAttribute(q,3,1).setDynamic(!0)),f.computeBoundingSphere();var y=this.material=this.genMaterial(),o=this.line=new a.LineSegments(f,y);o.frustumCulled=!1,this.three3D.add(o)},getSegment:function(a){console.log('getSegment')},setPt:function(i,c,d,e,f){var g=this.options.ptN,a=i*this.ptRealN,h=this.geometry.getAttribute('position'),b=h.array;if(c===0){b[a*3+0]=d,b[a*3+1]=e,b[a*3+2]=f;return}b[(a+2*c-1)*3+0]=d,b[(a+2*c-1)*3+1]=e,b[(a+2*c-1)*3+2]=f,c<g-1&&(b[(a+2*c)*3+0]=d,b[(a+2*c)*3+1]=e,b[(a+2*c)*3+2]=f)},getPt:function(a,b,c){},update:function(){var a=this.geometry;a.getAttribute('cs').needsUpdate=!0,a.getAttribute('position').needsUpdate=!0},updateOptions:function(a){a=this.options=c.deepMerge(this.options||b.options,a);var d=this.material;d.linewidth=a.weight},getUniforms:function(){return this.uniforms},setColor:function(a,b,c){},setColorArray:function(k,l,b){var i=this.geometry.getAttribute('cs'),c=i.array,g=this.ptRealN,h=k*this.ptRealN,d,f,e,j;for(var a=0;a<g;a++)if(j=a/g,d=h+a,f=l[a],c[d*4+0]=f.r,c[d*4+1]=f.g,c[d*4+2]=f.b,b!==undefined&&b!==null){var e;typeof b==='function'?e=b(j):e=b,c[d*4+3]=e}return},genMaterial:function(){var b=this.options,c='attribute vec4 cs;attribute float indexes;varying vec4 c;void main(){c = cs;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;}',d='varying vec4 c;uniform float maxOpacity;void main() {gl_FragColor = c * vec4(1., 1., 1., 1.);}',e=this.uniforms={maxOpacity:{type:'f',value:b.maxOpacity}};return new a.ShaderMaterial({uniforms:e,vertexShader:c,fragmentShader:d,vertexColors:a.VertexColors,blending:b.material.blending,depthTest:!0,alphaTest:1,transparent:!0,shading:a.SmoothShading,side:a.DoubleSide,linewidth:b.weight})},remove:function(){this.three3D.remove(this.line),this.line&&this.line.dispose&&this.line.dispose(),this.geometry&&this.geometry.dispose(),this.material&&this.material.dispose(),this.line=null,this.geometry=null,this.material=null}},module.exports=b | ||
'use strict';var a=require('three'),b=require('./../core/utils'),c=function(a){this.options=b.deepMerge(c.options,a)},d=0,e=0;c.options={lineN:1e3,ptN:100,maxOpacity:.2,weight:3,material:{blending:a.AdditiveBlending},style:{opacity:function(a){return a*a},hue:.5,color:function(b,c){return b=1-b,new a.Color().setHSL(c,1-b*.3,.3+Math.pow(b,8)*.6)}}};var f=0;c.prototype={addTo:function(a){this.three3D=a.three3D,this.init()},init:function(){var e=this.options,i=e.lineN,x=e.ptN,w=e.style.color.bind(e.style),v=e.style.hue,k=this.lines=[],n=this.colorGroup=[],f=this.geometry=new a.BufferGeometry,d=this.ptRealN=(x-1)*2,u=[],l,p,z,g=this.colorsF32=new Float32Array(d*i*4),m=this.indexesF32=new Float32Array(d*i*1),q=this.positionsF32=new Float32Array(d*i*3),r=[],s=[],t,b=0;for(var c=0;c<i;c++)for(var h=0;h<d;h++){s.push(1-h/d),k[c]=p=k[c]||[],n[c]=t=n[c]||[],l=new a.Vector3,u.push(l),p.push(l),z=w(v,h/d);var j=new a.Vector4(1,1,1,1);g[b*4+0]=1,g[b*4+1]=1,g[b*4+2]=1,g[b*4+3]=1,m[b]=b,b++,r.push(j),t.push(j)}f.addAttribute('cs',new a.BufferAttribute(g,4,1).setDynamic(!0)),f.addAttribute('indexes',new a.BufferAttribute(m,1)),f.addAttribute('position',new a.BufferAttribute(q,3,1).setDynamic(!0)),f.computeBoundingSphere();var y=this.material=this.genMaterial(),o=this.line=new a.LineSegments(f,y);o.frustumCulled=!1,this.three3D.add(o)},getSegment:function(a){console.log('getSegment')},setPt:function(i,c,d,e,f){var g=this.options.ptN,a=i*this.ptRealN,h=this.geometry.getAttribute('position'),b=h.array;if(c===0){b[a*3+0]=d,b[a*3+1]=e,b[a*3+2]=f;return}b[(a+2*c-1)*3+0]=d,b[(a+2*c-1)*3+1]=e,b[(a+2*c-1)*3+2]=f,c<g-1&&(b[(a+2*c)*3+0]=d,b[(a+2*c)*3+1]=e,b[(a+2*c)*3+2]=f)},getPt:function(a,b,c){},update:function(){var a=this.geometry;a.getAttribute('cs').needsUpdate=!0,a.getAttribute('position').needsUpdate=!0},updateOptions:function(a){a=this.options=b.deepMerge(this.options||c.options,a);var d=this.material;d.linewidth=a.weight},getUniforms:function(){return this.uniforms},setColor:function(a,b,c){},setColorArray:function(k,l,b){var i=this.geometry.getAttribute('cs'),c=i.array,g=this.ptRealN,h=k*this.ptRealN,d,f,e,j;for(var a=0;a<g;a++)if(j=a/g,d=h+a,f=l[a],c[d*4+0]=f.r,c[d*4+1]=f.g,c[d*4+2]=f.b,b!==undefined&&b!==null){var e;typeof b==='function'?e=b(j):e=b,c[d*4+3]=e}return},genMaterial:function(){var b=this.options,c='attribute vec4 cs;attribute float indexes;varying vec4 c;void main(){c = cs;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;}',d='varying vec4 c;uniform float maxOpacity;void main() {gl_FragColor = c * vec4(1., 1., 1., 1.);}',e=this.uniforms={maxOpacity:{type:'f',value:b.maxOpacity}};return new a.ShaderMaterial({uniforms:e,vertexShader:c,fragmentShader:d,vertexColors:a.VertexColors,blending:b.material.blending,depthTest:!0,alphaTest:1,transparent:!0,shading:a.SmoothShading,side:a.DoubleSide,linewidth:b.weight})},remove:function(){this.three3D.remove(this.line),this.line&&this.line.dispose&&this.line.dispose(),this.geometry&&this.geometry.dispose(),this.material&&this.material.dispose(),this.line=null,this.geometry=null,this.material=null}},module.exports=c |
@@ -1,1 +0,1 @@ | ||
'use strict';function b(d){d=this.options=c.deepMerge(b.options,d);var e='attribute float sizes;attribute vec4 colors;attribute float scales;varying vec4 cs;void main(){cs = colors;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;gl_PointSize = abs(sizes * scales);}',f='varying vec4 cs;uniform float time;uniform sampler2D texture;void main() {vec2 uv = vec2(gl_PointCoord.x,gl_PointCoord.y);vec4 texture2d = texture2D(texture, uv);gl_FragColor = cs * texture2d * 1.0;}',g=this.uniforms={texture:{type:'t',value:this.genTexture()}};this.material=new a.ShaderMaterial({uniforms:g,vertexShader:e,fragmentShader:f,blending:d.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:a.SmoothShading})}var a=require('three'),c=require('./../core/utils');b.options={scatterN:1e3,maxOpacity:1,sprite:null,blending:a.AdditiveBlending},b.prototype={getMaterial:function(){return this.material},genTexture:function(c){var b=new a.Texture(this.options.sprite);return b.needsUpdate=!0,b},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.uniforms.texture.value.image=a.sprite,this.uniforms.texture.value.needsUpdate=!0,this.uniforms.texture.needsUpdate=!0}},module.exports=b | ||
'use strict';function a(d){d=this.options=c.deepMerge(a.options,d);var e='attribute float sizes;attribute vec4 colors;attribute float scales;varying vec4 cs;void main(){cs = colors;vec3 pos = position;vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );gl_Position = projectionMatrix * mvPosition;gl_PointSize = abs(sizes * scales);}',f='varying vec4 cs;uniform float time;uniform sampler2D texture;void main() {vec2 uv = vec2(gl_PointCoord.x,gl_PointCoord.y);vec4 texture2d = texture2D(texture, uv);gl_FragColor = cs * texture2d * 1.0;}',g=this.uniforms={texture:{type:'t',value:this.genTexture()}};this.material=new b.ShaderMaterial({uniforms:g,vertexShader:e,fragmentShader:f,blending:d.blending,depthTest:!0,depthWrite:!1,alphaTest:1,transparent:!0,shading:b.SmoothShading})}var b=require('three'),c=require('./../core/utils');a.options={scatterN:1e3,maxOpacity:1,sprite:null,blending:b.AdditiveBlending},a.prototype={getMaterial:function(){return this.material},genTexture:function(c){var a=new b.Texture(this.options.sprite);return a.needsUpdate=!0,a},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.uniforms.texture.value.image=a.sprite,this.uniforms.texture.value.needsUpdate=!0,this.uniforms.texture.needsUpdate=!0}},module.exports=a |
@@ -1,1 +0,1 @@ | ||
function f(d){if(!d)return console.log('无入参');var h=d.type;if(!h)return;var c=d.size||20,r=d.background,s=d.id,l=d.radius,j=d.fill,m=d.strokeWidth,o=d.stroke,t=d.complement,k=document.createElementNS('http://www.w3.org/2000/svg','defs'),f=document.createElementNS('http://www.w3.org/2000/svg','pattern');f.setAttribute('id',s),f.setAttribute('width',c),f.setAttribute('height',c),f.setAttribute('patternUnits','userSpaceOnUse');var a=document.createElementNS('http://www.w3.org/2000/svg','circle');if(h==='circle'){if(a.setAttribute('cx',c/2),a.setAttribute('cy',c/2),a.setAttribute('r',l),a.setAttribute('fill',j),a.setAttribute('stroke-width',m),a.setAttribute('stroke',o),t){var n=[[0,0],[0,c],[c,0],[c,c]],i,p,q=[];for(i=0;i<n.length;i++){p=n[i];var e=document.createElementNS('http://www.w3.org/2000/svg','circle');e.setAttribute('cx',p[0]),e.setAttribute('cy',p[1]),e.setAttribute('r',l),e.setAttribute('fill',j),e.setAttribute('stroke',o),e.setAttribute('stroke-width',m),q.push(e)}return q}}else h==='rect'||h==='path';if(a.setAttribute('d','M 0,10 l 10,-10 M -2.5,2.5 l 5,-5 M 7.5,12.5 l 5,-5'),a.setAttribute('stroke-width',2),a.setAttribute('shape-rendering','auto'),a.setAttribute('stroke','darkorange'),a.setAttribute('stroke-linecap','square'),r){var g=document.createElementNS('http://www.w3.org/2000/svg','rect');g.setAttribute('width',c),g.setAttribute('height',c),g.setAttribute('fill',r),f.appendChild(g)}b.appendChild(k),k.appendChild(f),f.appendChild(a)}function a(){return(Math.random().toString(36)+'00000000000000000').replace(/[^a-z]+/g,'').slice(0,5)}var e=require('jquery'),c=[].slice,d=document.getElementsByTagName('body')[0],b=document.createElementNS('http://www.w3.org/2000/svg','svg');d.appendChild(b),module.exports=function(){return{circles:function(){var b,f,g,e,d,c,h,i;return c=20,d=2,f=!1,g='#343434',h='#343434',i=0,e=a(),b=function(){var b,l,a,k,e,j;if(f){for(e=[[0,0],[0,c],[c,0],[c,c]],j=[],a=0,k=e.length;a<k;a++)b=e[a],j.push(l.append('circle').attr({cx:b[0],cy:b[1],r:d,fill:g,stroke:h,'stroke-width':i}));return j}},b.heavier=function(a){return arguments.length?d=a?d*2*a:d*2:d*=2,b},b.lighter=function(a){return arguments.length?d=a?d/(2*a):d/2:d/=2,b},b.thinner=function(a){return arguments.length?c=a?c*2*a:c*2:c*=2,b},b.thicker=function(a){return arguments.length?c=a?c/(2*a):c/2:c/=2,b},b.background=function(a){return b},b.size=function(a){return c=a,b},b.complement=function(){return f=!0,b},b.radius=function(a){return d=a,b},b.fill=function(a){return g=a,b},b.stroke=function(a){return h=a,b},b.strokeWidth=function(a){return i=a,b},b.id=function(a){return arguments.length?(e=a,b):e},b.url=function(){return'url(#'+e+')'},b},lines:function(){var g,f,d,h,k,i,b,j,e;return b=20,e=2,j='#343434',f=a(),g='',h=['diagonal'],i='auto',k=function(a){switch(a){case'0/8':return function(a){return'M '+a/2+', 0 l 0, '+a}(b);case'vertical':return function(a){return'M '+a/2+', 0 l 0, '+a}(b);case'1/8':return function(a){return'M '+a/4+',0 l '+a/2+','+a+' M '+-a/4+',0 l '+a/2+','+a+'\nM '+a*3/4+',0 l '+a/2+','+a}(b);case'2/8':return function(a){return'M 0,'+a+' l '+a+','+-a+' M '+-a/4+','+a/4+' l '+a/2+','+-a/2+'\nM '+.75*a+','+1.25*a+' l '+a/2+','+-a/2}(b);case'diagonal':return function(a){return'M 0,'+a+' l '+a+','+-a+' M '+-a/4+','+a/4+' l '+a/2+','+-a/2+'\nM '+.75*a+','+1.25*a+' l '+a/2+','+-a/2}(b);case'3/8':return function(a){return'M 0,'+.75*a+' l '+a+','+-a/2+' M 0,'+a/4+' l '+a+','+-a/2+'\nM 0,'+a*5/4+' l '+a+','+-a/2}(b);case'4/8':return function(a){return'M 0,'+a/2+' l '+a+',0'}(b);case'horizontal':return function(a){return'M 0,'+a/2+' l '+a+',0'}(b);case'5/8':return function(a){return'M 0,'+-a/4+' l '+a+','+a/2+'M 0,'+a/4+' l '+a+','+a/2+'\nM 0,'+a*3/4+' l '+a+','+a/2}(b);case'6/8':return function(a){return'M 0,0 l '+a+','+a+' M '+-a/4+','+.75*a+' l '+a/2+','+a/2+'\nM '+a*3/4+','+-a/4+' l '+a/2+','+a/2}(b);case'7/8':return function(a){return'M '+-a/4+',0 l '+a/2+','+a+' M '+a/4+',0 l '+a/2+','+a+'\nM '+a*3/4+',0 l '+a/2+','+a}(b);default:return function(a){return'M '+a/2+', 0 l 0, '+a}(b)}},d=function(){var c,a,l,m,d;for(c=this.append('defs').append('pattern').attr({id:f,patternUnits:'userSpaceOnUse',width:b,height:b}),g&&c.append('rect').attr({width:b,height:b,fill:g}),d=[],a=0,l=h.length;a<l;a++)m=h[a],d.push(c.append('path').attr({d:k(m),'stroke-width':e,'shape-rendering':i,stroke:j,'stroke-linecap':'square'}));return d},d.background=function(a){return g=a,d},d.shapeRendering=function(a){return i=a,d},d.heavier=function(a){return arguments.length?e=a?e*2*a:e*2:e*=2,d},d.lighter=function(a){return arguments.length?e=a?e/(2*a):e/2:e/=2,d},d.thinner=function(a){return arguments.length?b=a?b*2*a:b*2:b*=2,d},d.thicker=function(a){return arguments.length?b=a?b/(2*a):b/2:b/=2,d},d.orientation=function(){var a;return a=1<=arguments.length?c.call(arguments,0):[],h=a,d},d.size=function(a){return b=a,d},d.stroke=function(a){return j=a,d},d.strokeWidth=function(a){return e=a,d},d.id=function(a){return arguments.length?(f=a,d):f},d.url=function(){return'url(#'+f+')'},d},paths:function(){var h,k,l,f,e,b,i,c,j,d,m,g;return c=20,f=1,g=1,d=2,j='#343434',h='',k='',i='auto',l='transparent',e=void 0,m=function(a){switch(a){case'squares':return function(a){return'M '+a/4+' '+a/4+' l '+a/2+' 0 l 0 '+a/2+' l '+-a/2+' 0 Z'}(c);case'nylon':return function(a){return'M 0 '+a/4+' l '+a/4+' 0 l 0 '+-a/4+' M '+a*3/4+' '+a+' l 0 '+-a/4+'\nl '+a/4+' 0 M '+a/4+' '+a/2+' l 0 '+a/4+' l '+a/4+' 0 M '+a/2+' '+a/4+'\nl '+a/4+' 0 l 0 '+a/4}(c);case'waves':return function(a){return'M 0 '+a/2+' c '+a/8+' '+-a/4+' , '+a*3/8+' '+-a/4+' , '+a/2+' 0\nc '+a/8+' '+a/4+' , '+a*3/8+' '+a/4+' , '+a/2+' 0 M '+-a/2+' '+a/2+'\nc '+a/8+' '+a/4+' , '+a*3/8+' '+a/4+' , '+a/2+' 0 M '+a+' '+a/2+'\nc '+a/8+' '+-a/4+' , '+a*3/8+' '+-a/4+' , '+a/2+' 0'}(c);case'woven':return function(a){return'M '+a/4+','+a/4+'l'+a/2+','+a/2+'M'+a*3/4+','+a/4+'l'+a/2+','+-a/2+'\nM'+a/4+','+a*3/4+'l'+-a/2+','+a/2+'M'+a*3/4+','+a*5/4+'l'+a/2+','+-a/2+'\nM'+-a/4+','+a/4+'l'+a/2+','+-a/2}(c);case'crosses':return function(a){return'M '+a/4+','+a/4+'l'+a/2+','+a/2+'M'+a/4+','+a*3/4+'l'+a/2+','+-a/2}(c);case'caps':return function(a){return'M '+a/4+','+a*3/4+'l'+a/4+','+-a/2+'l'+a/4+','+a/2}(c);case'hexagons':return function(a){return g=3,f=Math.sqrt(3),'M '+a+',0 l '+a+',0 l '+a/2+','+a*Math.sqrt(3)/2+'\nl '+-a/2+','+a*Math.sqrt(3)/2+' l '+-a+',0\nl '+-a/2+','+-a*Math.sqrt(3)/2+' Z M 0,'+a*Math.sqrt(3)/2+'\nl '+a/2+',0 M '+3*a+','+a*Math.sqrt(3)/2+' l '+-a/2+',0'}(c);default:return a(c)}},b=function(){var b,n;return n=m(k),e=a(),b=this.append('defs').append('pattern').attr({id:e,patternUnits:'userSpaceOnUse',width:c*g,height:c*f}),h&&b.append('rect').attr({width:c*g,height:c*f,fill:h}),b.append('path').attr({d:n,fill:l,'stroke-width':d,'shape-rendering':i,stroke:j,'stroke-linecap':'square'})},b.background=function(a){return h=a,b},b.shapeRendering=function(a){return i=a,b},b.heavier=function(a){return arguments.length?d=a?d*2*a:d*2:d*=2,b},b.lighter=function(a){return arguments.length?d=a?d/(2*a):d/2:d/=2,b},b.thinner=function(a){return arguments.length?c=a?c*2*a:c*2:c*=2,b},b.thicker=function(a){return arguments.length?c=a?c/(2*a):c/2:c/=2,b},b.d=function(a){return k=a,b},b.size=function(a){return c=a,b},b.stroke=function(a){return j=a,b},b.strokeWidth=function(a){return d=a,b},b.id=function(a){return arguments.length?(e=a,b):e},b.url=function(){return'url(#'+e+')'},b}}} | ||
function a(c){if(!c)return console.log('无入参');var h=c.type;if(!h)return;var b=c.size||20,r=c.background,s=c.id,l=c.radius,j=c.fill,m=c.strokeWidth,o=c.stroke,t=c.complement,k=document.createElementNS('http://www.w3.org/2000/svg','defs'),e=document.createElementNS('http://www.w3.org/2000/svg','pattern');e.setAttribute('id',s),e.setAttribute('width',b),e.setAttribute('height',b),e.setAttribute('patternUnits','userSpaceOnUse');var a=document.createElementNS('http://www.w3.org/2000/svg','circle');if(h==='circle'){if(a.setAttribute('cx',b/2),a.setAttribute('cy',b/2),a.setAttribute('r',l),a.setAttribute('fill',j),a.setAttribute('stroke-width',m),a.setAttribute('stroke',o),t){var n=[[0,0],[0,b],[b,0],[b,b]],i,p,q=[];for(i=0;i<n.length;i++){p=n[i];var d=document.createElementNS('http://www.w3.org/2000/svg','circle');d.setAttribute('cx',p[0]),d.setAttribute('cy',p[1]),d.setAttribute('r',l),d.setAttribute('fill',j),d.setAttribute('stroke',o),d.setAttribute('stroke-width',m),q.push(d)}return q}}else h==='rect'||h==='path';if(a.setAttribute('d','M 0,10 l 10,-10 M -2.5,2.5 l 5,-5 M 7.5,12.5 l 5,-5'),a.setAttribute('stroke-width',2),a.setAttribute('shape-rendering','auto'),a.setAttribute('stroke','darkorange'),a.setAttribute('stroke-linecap','square'),r){var g=document.createElementNS('http://www.w3.org/2000/svg','rect');g.setAttribute('width',b),g.setAttribute('height',b),g.setAttribute('fill',r),e.appendChild(g)}f.appendChild(k),k.appendChild(e),e.appendChild(a)}function b(){return(Math.random().toString(36)+'00000000000000000').replace(/[^a-z]+/g,'').slice(0,5)}var c=require('jquery'),d=[].slice,e=document.getElementsByTagName('body')[0],f=document.createElementNS('http://www.w3.org/2000/svg','svg');e.appendChild(f),module.exports=function(){return{circles:function(){var a,f,g,e,d,c,h,i;return c=20,d=2,f=!1,g='#343434',h='#343434',i=0,e=b(),a=function(){var b,l,a,k,e,j;if(f){for(e=[[0,0],[0,c],[c,0],[c,c]],j=[],a=0,k=e.length;a<k;a++)b=e[a],j.push(l.append('circle').attr({cx:b[0],cy:b[1],r:d,fill:g,stroke:h,'stroke-width':i}));return j}},a.heavier=function(b){return arguments.length?d=b?d*2*b:d*2:d*=2,a},a.lighter=function(b){return arguments.length?d=b?d/(2*b):d/2:d/=2,a},a.thinner=function(b){return arguments.length?c=b?c*2*b:c*2:c*=2,a},a.thicker=function(b){return arguments.length?c=b?c/(2*b):c/2:c/=2,a},a.background=function(b){return a},a.size=function(b){return c=b,a},a.complement=function(){return f=!0,a},a.radius=function(b){return d=b,a},a.fill=function(b){return g=b,a},a.stroke=function(b){return h=b,a},a.strokeWidth=function(b){return i=b,a},a.id=function(b){return arguments.length?(e=b,a):e},a.url=function(){return'url(#'+e+')'},a},lines:function(){var g,f,c,h,k,i,a,j,e;return a=20,e=2,j='#343434',f=b(),g='',h=['diagonal'],i='auto',k=function(b){switch(b){case'0/8':return function(a){return'M '+a/2+', 0 l 0, '+a}(a);case'vertical':return function(a){return'M '+a/2+', 0 l 0, '+a}(a);case'1/8':return function(a){return'M '+a/4+',0 l '+a/2+','+a+' M '+-a/4+',0 l '+a/2+','+a+'\nM '+a*3/4+',0 l '+a/2+','+a}(a);case'2/8':return function(a){return'M 0,'+a+' l '+a+','+-a+' M '+-a/4+','+a/4+' l '+a/2+','+-a/2+'\nM '+.75*a+','+1.25*a+' l '+a/2+','+-a/2}(a);case'diagonal':return function(a){return'M 0,'+a+' l '+a+','+-a+' M '+-a/4+','+a/4+' l '+a/2+','+-a/2+'\nM '+.75*a+','+1.25*a+' l '+a/2+','+-a/2}(a);case'3/8':return function(a){return'M 0,'+.75*a+' l '+a+','+-a/2+' M 0,'+a/4+' l '+a+','+-a/2+'\nM 0,'+a*5/4+' l '+a+','+-a/2}(a);case'4/8':return function(a){return'M 0,'+a/2+' l '+a+',0'}(a);case'horizontal':return function(a){return'M 0,'+a/2+' l '+a+',0'}(a);case'5/8':return function(a){return'M 0,'+-a/4+' l '+a+','+a/2+'M 0,'+a/4+' l '+a+','+a/2+'\nM 0,'+a*3/4+' l '+a+','+a/2}(a);case'6/8':return function(a){return'M 0,0 l '+a+','+a+' M '+-a/4+','+.75*a+' l '+a/2+','+a/2+'\nM '+a*3/4+','+-a/4+' l '+a/2+','+a/2}(a);case'7/8':return function(a){return'M '+-a/4+',0 l '+a/2+','+a+' M '+a/4+',0 l '+a/2+','+a+'\nM '+a*3/4+',0 l '+a/2+','+a}(a);default:return function(a){return'M '+a/2+', 0 l 0, '+a}(a)}},c=function(){var c,b,l,m,d;for(c=this.append('defs').append('pattern').attr({id:f,patternUnits:'userSpaceOnUse',width:a,height:a}),g&&c.append('rect').attr({width:a,height:a,fill:g}),d=[],b=0,l=h.length;b<l;b++)m=h[b],d.push(c.append('path').attr({d:k(m),'stroke-width':e,'shape-rendering':i,stroke:j,'stroke-linecap':'square'}));return d},c.background=function(a){return g=a,c},c.shapeRendering=function(a){return i=a,c},c.heavier=function(a){return arguments.length?e=a?e*2*a:e*2:e*=2,c},c.lighter=function(a){return arguments.length?e=a?e/(2*a):e/2:e/=2,c},c.thinner=function(b){return arguments.length?a=b?a*2*b:a*2:a*=2,c},c.thicker=function(b){return arguments.length?a=b?a/(2*b):a/2:a/=2,c},c.orientation=function(){var a;return a=1<=arguments.length?d.call(arguments,0):[],h=a,c},c.size=function(b){return a=b,c},c.stroke=function(a){return j=a,c},c.strokeWidth=function(a){return e=a,c},c.id=function(a){return arguments.length?(f=a,c):f},c.url=function(){return'url(#'+f+')'},c},paths:function(){var h,k,l,f,e,a,i,c,j,d,m,g;return c=20,f=1,g=1,d=2,j='#343434',h='',k='',i='auto',l='transparent',e=void 0,m=function(a){switch(a){case'squares':return function(a){return'M '+a/4+' '+a/4+' l '+a/2+' 0 l 0 '+a/2+' l '+-a/2+' 0 Z'}(c);case'nylon':return function(a){return'M 0 '+a/4+' l '+a/4+' 0 l 0 '+-a/4+' M '+a*3/4+' '+a+' l 0 '+-a/4+'\nl '+a/4+' 0 M '+a/4+' '+a/2+' l 0 '+a/4+' l '+a/4+' 0 M '+a/2+' '+a/4+'\nl '+a/4+' 0 l 0 '+a/4}(c);case'waves':return function(a){return'M 0 '+a/2+' c '+a/8+' '+-a/4+' , '+a*3/8+' '+-a/4+' , '+a/2+' 0\nc '+a/8+' '+a/4+' , '+a*3/8+' '+a/4+' , '+a/2+' 0 M '+-a/2+' '+a/2+'\nc '+a/8+' '+a/4+' , '+a*3/8+' '+a/4+' , '+a/2+' 0 M '+a+' '+a/2+'\nc '+a/8+' '+-a/4+' , '+a*3/8+' '+-a/4+' , '+a/2+' 0'}(c);case'woven':return function(a){return'M '+a/4+','+a/4+'l'+a/2+','+a/2+'M'+a*3/4+','+a/4+'l'+a/2+','+-a/2+'\nM'+a/4+','+a*3/4+'l'+-a/2+','+a/2+'M'+a*3/4+','+a*5/4+'l'+a/2+','+-a/2+'\nM'+-a/4+','+a/4+'l'+a/2+','+-a/2}(c);case'crosses':return function(a){return'M '+a/4+','+a/4+'l'+a/2+','+a/2+'M'+a/4+','+a*3/4+'l'+a/2+','+-a/2}(c);case'caps':return function(a){return'M '+a/4+','+a*3/4+'l'+a/4+','+-a/2+'l'+a/4+','+a/2}(c);case'hexagons':return function(a){return g=3,f=Math.sqrt(3),'M '+a+',0 l '+a+',0 l '+a/2+','+a*Math.sqrt(3)/2+'\nl '+-a/2+','+a*Math.sqrt(3)/2+' l '+-a+',0\nl '+-a/2+','+-a*Math.sqrt(3)/2+' Z M 0,'+a*Math.sqrt(3)/2+'\nl '+a/2+',0 M '+3*a+','+a*Math.sqrt(3)/2+' l '+-a/2+',0'}(c);default:return a(c)}},a=function(){var a,n;return n=m(k),e=b(),a=this.append('defs').append('pattern').attr({id:e,patternUnits:'userSpaceOnUse',width:c*g,height:c*f}),h&&a.append('rect').attr({width:c*g,height:c*f,fill:h}),a.append('path').attr({d:n,fill:l,'stroke-width':d,'shape-rendering':i,stroke:j,'stroke-linecap':'square'})},a.background=function(b){return h=b,a},a.shapeRendering=function(b){return i=b,a},a.heavier=function(b){return arguments.length?d=b?d*2*b:d*2:d*=2,a},a.lighter=function(b){return arguments.length?d=b?d/(2*b):d/2:d/=2,a},a.thinner=function(b){return arguments.length?c=b?c*2*b:c*2:c*=2,a},a.thicker=function(b){return arguments.length?c=b?c/(2*b):c/2:c/=2,a},a.d=function(b){return k=b,a},a.size=function(b){return c=b,a},a.stroke=function(b){return j=b,a},a.strokeWidth=function(b){return d=b,a},a.id=function(b){return arguments.length?(e=b,a):e},a.url=function(){return'url(#'+e+')'},a}}} |
@@ -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({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 a=require('three'),b=require('./../core/utils'),c=require('bcore/event'),d=b.requestAnimationFrame,e=b.cancelAnimationFrame;a.ImageUtils.crossOrigin='',a.Loader.crossOrigin='';var f=function(a,c){this.options=b.deepMerge(f.options,c),this.container=b.getContainer(a),this.width=a.offsetWidth,this.height=a.offsetHeight,this.initScene(),this.initCamera(),this.initRender(),this.initEvents(),this.loop()};f.options={clearAlpha:0,alpha:1,clearColor:0,background:'transparent',pointerEvents:'auto',camera:{angle:60,far:119378137,near:1}},f=c.extend(f,{}),f.prototype.initScene=function(){this.scene=new a.Scene},f.prototype.initCamera=function(){var d=this.width,e=this.height,c=this.options.camera,b=this.camera=new a.PerspectiveCamera(c.angle,d/e,c.far,c.near);b.up.x=0,b.up.y=1,b.up.z=0,b.lookAt(new a.Vector3(0,0,0)),this.scene.add(b)},f.prototype.initRender=function(){var c=this.options,d=this.renderer=new a.WebGLRenderer({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,b=e.style;b.position='absolute',b.top=0,b.left=0,b.height='100%',b.width='100%',b.opacity=c.alpha,b.background=c.background,b.pointerEvents=c.pointerEvents,this.container.style.pointerEvents=c.pointerEvents,this.container.appendChild(e)},f.prototype.initTarget=function(){var b=this.target=new a.WebGLRenderTarget(this.width,this.height);b.minFilter=a.LinearFilter,b.generateMipmaps=!1,this.renderer.setRenderTarget(b)},f.prototype.update=function(){var a=this.renderer;a.clear(),a.render(this.scene,this.camera)},f.prototype.loop=function(){this.update(),d(this.loop.bind(this))},f.prototype.add=function(a){this.scene.add(a)},f.prototype.remove=function(a){this.scene.remove(a)},f.prototype.children=function(){return this.scene.children},f.prototype.setClearColor=function(a){this.renderer.setClearColor(a)},f.prototype.setCameraPosition=function(a){this.camera.position.x=a.x,this.camera.position.y=a.y,this.camera.position.z=a.z},f.prototype.setCameraView=function(a){this.camera.lookAt(a)},f.prototype.getCamera=function(){return this.camera},f.prototype.setSize=function(a,b){this.renderer.setSize(a,b)},f.prototype.getContainer=function(){return this.container},f.prototype.initEvents=function(){window.addEventListener('resize',this.onWindowResize.bind(this))},f.prototype.updateOptions=function(a){a&&(this.options=b.deepMerge(this.options,a)),this.updateCSS()},f.prototype.updateCSS=function(){this.canvas.style.pointerEvents=this.container.style.pointerEvents=this.pointerEvents=this.options.pointerEvents},f.prototype.updateCamera=function(d){d&&typeof d==='object'&&(this.options=b.deepMerge(this.options,{camera:d}));var a=this.camera,c=this.options.camera;a.far=c.far,a.near=c.near,a.angle=c.angle,a.updateProjectionMatrix(),a.updateMatrixWorld()},f.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=f |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
2