test:(base)

This commit is contained in:
李正学 2018-10-31 11:29:54 +08:00
parent 9c517998aa
commit 37c331d31f
14 changed files with 199 additions and 64 deletions

View File

@ -36,6 +36,7 @@ scene.on('load', () => {
.source(data)
.shape('2d:circle')
.size('value', [ 8, 500 ]) // default 1
.active(true)
.filter('value', field_8 => {
return field_8 * 1 > 500;
})

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>point_circle</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
center: [ 116.155185, 39.96644],
pitch: 25,
zoom: 9.6
});
window.scene = scene;
scene.on('load', () => {
$.get('./data/spot.geojson', data => {
scene.PointLayer({
zIndex: 2
})
.source(data)
.shape('3d:hexagon')
.size('level',(level)=>{
return [10000,10000,Math.pow(10,level)];
}) // default 1
.active(true)
.color('level', [ '#ffffd4', '#fed98e', '#fe9929', '#d95f0e', '#993404' ])
.render();
});
});
</script>
</body>
</html>

View File

@ -21,10 +21,6 @@
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const gui = new dat.GUI({ autoPlace: false });
const customContainer = document.getElementById('gui');
customContainer.appendChild(gui.domElement);
const province = { 全国: '00', 新疆维吾尔自治区: '65', 西藏自治区: '54', 内蒙古自治区: '15', 青海省: '63', 四川省: '51', 黑龙江省: '23', 甘肃省: '62', 云南省: '53', 广西壮族自治区: '45', 湖南省: '43', 陕西省: '61', 广东省: '44', 吉林省: '22', 河北省: '13', 湖北省: '42', 贵州省: '52', 山东省: '37', 江西省: '36', 河南省: '41', 辽宁省: '21', 山西省: '14', 安徽省: '34', 福建省: '35', 浙江省: '33', 江苏省: '32', 重庆市: '50', 宁夏回族自治区: '64', 海南省: '46', 台湾省: '71', 北京市: '11', 天津市: '12', 上海市: '31', 香港特别行政区: '81', 澳门特别行政区: '82' };
const scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
@ -41,7 +37,7 @@ scene.on('load', () => {
.source(city)
.color('pm2_5_24h', [ '#002466', '#0D408C', '#105CB3', '#1A76C7', '#2894E0', '#3CB4F0', '#65CEF7', '#98E3FA', '#CFF6FF', '#E8FCFF' ])
.shape('fill')
// .active({ fill: 'red' })
.active({ fill: '#fff' })
.style({
opacity: 1
})

View File

@ -31,7 +31,7 @@ const scene = new L7.Scene({
zoom: 4
});
scene.on('load', () => {
scene.on('loaded', () => {
const xhr = new XMLHttpRequest();
xhr.open('GET', ' https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat', true);

83
demos/07_city.html Normal file
View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>city</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
center: [120.174865, 30.245345],
pitch: 45,
zoom: 12.63
});
window.scene = scene;
scene.on('loaded', () => {
$.get('./data/water.geojson', data => {
scene.PolygonLayer({
zIndex: 0
})
.source(data)
.shape('fill')
.color('rgb(71,148,218)')
.render();
});
$.get('./data/land.geojson', data => {
scene.PolygonLayer({
zIndex: 0
})
.source(data)
.shape('fill')
.color('rgb(176,211,122)')
.render();
});
$.get('./data/river.geojson', data => {
scene.LineLayer({
zIndex: 2
})
.source(data)
.color('rgb(126,204,243)')
.render();
});
$.get('./data/road.geojson', data => {
scene.LineLayer({
zIndex: 2
})
.source(data)
.color('rgb(245,227,199)')
.render();
});
$.get('./data/build.geojson', data => {
scene.PolygonLayer({
zIndex: 2
})
.source(data)
.shape('extrude')
.size('floor',[10,3000])
.color('rgb(250,250,250)')
.render();
});
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@ -33,7 +33,7 @@
"connect": "^3.6.6",
"d3-queue": "~3.0.7",
"debug": "~3.1.0",
"electron": "^1.8.4",
"electron": "^1.8.7",
"eslint": "~3.19.0",
"eslint-config-airbnb": "~15.0.1",
"eslint-config-egg": "~4.2.0",

View File

@ -10,7 +10,6 @@ void main() {
gl_FragColor = vec4(v_color.xyz , v_color.w * u_opacity);
}else {
vec4 color = texture2D(u_texture,v_texCoord) * v_color;
color = vec4(color.rgb * vlightWeight, color.w);
gl_FragColor = color;
}
#else

View File

@ -6,9 +6,6 @@ attribute vec4 a_color;
attribute vec4 a_idColor;
attribute vec2 faceUv;
varying vec2 v_texCoord;
varying float vlightWeight;
varying vec4 v_color;
void main() {
mat4 matModelViewProjection = projectionMatrix * modelViewMatrix;
@ -16,16 +13,15 @@ void main() {
vec3 worldNormal = vec3(vec4(normal,1.0) * modelMatrix);
// //cal light weight
vec3 viewDir = normalize(cameraPosition - worldPos);
vec3 lightDir = normalize(vec3(0.5,0,-1));
vec3 lightDir = normalize(vec3(1, -1.5, 2));
// vec3 lightDir = normalize(vec3(0.05,-0.001,-1));
vec3 halfDir = normalize(viewDir+lightDir);
// //lambert
float lambert = 0.5 * dot(worldNormal, lightDir) + 0.8;
float lambert = 0.5 * dot(worldNormal, lightDir);
//specular
float specular = pow( max(0.0, dot(worldNormal, halfDir)), 32.0);
//sum to light weight
float lightWeight = ambientRatio + diffuseRatio * lambert + specularRatio * specular;
vlightWeight = lightWeight;
v_texCoord = faceUv;
v_color =vec4(a_color.rgb * lightWeight, a_color.w);

View File

@ -7,59 +7,54 @@ varying vec2 v_texCoord;
varying vec4 v_color;
uniform float u_min;
uniform float u_max;
uniform vec4 u_extent;
#define PI 3.141592653589793
void main() {
float value = texture2D(u_texture,v_texCoord)[0];
value = clamp(value,u_min,u_max);
float value1 = (value - u_min) / (u_max -u_min);
vec2 ramp_pos = vec2(
fract(16.0 * (1.0 - value1)),
floor(16.0 * (1.0 - value1)) / 16.0);
vec4 color = texture2D(u_colorTexture,ramp_pos);
// vec2 u_latrange = vec2(3.83718,53.5636);
// float u_zoom = 7.0;
// float u_maxzoom= 10.0;
// vec2 epsilon = 1.0 / u_dimension;
// vec2 u_light = vec2(0.5000, 5.8469);
// vec4 u_accent = vec4(0.,0.,0.,1.);
// vec4 u_highlight = vec4(1.0);
// vec4 u_shadow = vec4(0.,0.,0.,1.);
// float a = texture2D(u_texture,v_texCoord - epsilon)[0];
// float b = texture2D(u_texture,v_texCoord+vec2(0,-epsilon.y))[0];
// float c = texture2D(u_texture,v_texCoord+ vec2(epsilon.x - epsilon.y))[0];
// float d = texture2D(u_texture,v_texCoord+ vec2(-epsilon.x,0))[0];
// float e = texture2D(u_texture,v_texCoord)[0];
// float f = texture2D(u_texture,v_texCoord+ vec2(epsilon.x,0))[0];
// float g = texture2D(u_texture,v_texCoord+ vec2(-epsilon.x,epsilon.y))[0];
// float h = texture2D(u_texture,v_texCoord+ vec2(0,epsilon.y))[0];
// float i = texture2D(u_texture,v_texCoord+ epsilon)[0];
// float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;
vec2 u_latrange = vec2(3.83718,53.5636);
float u_zoom = 7.0;
float u_maxzoom= 10.0;
vec2 epsilon = 1.0 / u_dimension;
vec2 u_light = vec2(0.5000, 5.8469);
vec4 u_accent = vec4(0.,0.,0.,1.);
vec4 u_highlight = vec4(1.0);
vec4 u_shadow = vec4(0.,0.,0.,1.);
float a = texture2D(u_texture,v_texCoord - epsilon)[0];
float b = texture2D(u_texture,v_texCoord+vec2(0,-epsilon.y))[0];
float c = texture2D(u_texture,v_texCoord+ vec2(epsilon.x - epsilon.y))[0];
float d = texture2D(u_texture,v_texCoord+ vec2(-epsilon.x,0))[0];
float e = texture2D(u_texture,v_texCoord)[0];
float f = texture2D(u_texture,v_texCoord+ vec2(epsilon.x,0))[0];
float g = texture2D(u_texture,v_texCoord+ vec2(-epsilon.x,epsilon.y))[0];
float h = texture2D(u_texture,v_texCoord+ vec2(0,epsilon.y))[0];
float i = texture2D(u_texture,v_texCoord+ epsilon)[0];
float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;
// vec2 deriv = vec2(
// (c + f + f + i) - (a + d + d + g),
// (g + h + h + i) - (a + b + b + c)
// ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);
// float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_texCoord.y) + u_latrange[1]));
// float slope = atan(1.25 * length(deriv) / scaleFactor);
// float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);
vec2 deriv = vec2(
(c + f + f + i) - (a + d + d + g),
(g + h + h + i) - (a + b + b + c)
) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);
float scaleFactor = cos(radians((u_latrange[0] - u_latrange[1]) * (1.0 - v_texCoord.y) + u_latrange[1]));
float slope = atan(1.25 * length(deriv) / scaleFactor);
float aspect = deriv.x != 0.0 ? atan(deriv.y, -deriv.x) : PI / 2.0 * (deriv.y > 0.0 ? 1.0 : -1.0);
// float intensity = u_light.x;
// float azimuth = u_light.y + PI;
float intensity = u_light.x;
float azimuth = u_light.y + PI;
// float base = 1.875 - intensity * 1.75;
// float maxValue = 0.5 * PI;
// float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;
float base = 1.875 - intensity * 1.75;
float maxValue = 0.5 * PI;
float scaledSlope = intensity != 0.5 ? ((pow(base, slope) - 1.0) / (pow(base, maxValue) - 1.0)) * maxValue : slope;
// float accent = cos(scaledSlope);
// // We multiply both the accent and shade color by a clamped intensity value
// // so that intensities >= 0.5 do not additionally affect the color values
// // while intensity values < 0.5 make the overall color more transparent.
// vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0);
// float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);
// vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);
// gl_FragColor = v_color * (1.0 - shade_color.a) + shade_color;
gl_FragColor = color;
float accent = cos(scaledSlope);
// We multiply both the accent and shade color by a clamped intensity value
// so that intensities >= 0.5 do not additionally affect the color values
// while intensity values < 0.5 make the overall color more transparent.
vec4 accent_color = (1.0 - accent) * v_color * clamp(intensity * 2.0, 0.0, 1.0);
float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0);
vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0);
//gl_FragColor = v_color * (1.0 - shade_color.a) + shade_color;
gl_FragColor = v_color;
}

View File

@ -12,7 +12,13 @@ void main() {
float value = texture2D(u_texture,uv)[0];
v_texCoord = uv;
value = clamp(value,u_min,u_max);
float value1 = (value - u_min) / (u_max -u_min);
vec2 ramp_pos = vec2(
fract(16.0 * (1.0 - value1)),
floor(16.0 * (1.0 - value1)) / 16.0);
v_color = texture2D(u_colorTexture,ramp_pos);
vec2 range = u_extent.zw - u_extent.xy;
gl_Position = matModelViewProjection * vec4(position.xy, value*100.0, 1.0);
gl_Position = matModelViewProjection * vec4(position.xy, 0., 1.0);
}

View File

@ -85,12 +85,12 @@ export function arc(geo, index) {
* @param {int} index 原始数据index
* @return {object} 顶点坐标,索引坐标
*/
export function defaultLine(geo) {
export function defaultLine(geo,index) {
const indexArray = [];
const positions = [];
geo.slice(0, geo.length - 1).forEach((coor, index) => {
geo.slice(0, geo.length - 1).forEach((coor, i) => {
positions.push(coor, geo[index + 1]);
positions.push(coor, geo[i + 1]);
indexArray.push(index, index);
});

View File

@ -0,0 +1,9 @@
const expect = require('chai').expect;
// const Base= require('../../../src/core/base');
describe('core base Test',function(){
// const base1 = new Base();
// it('test getDefaultcfg',function(){
// expect(base1.getDefaultCfg()).to.be.an('object');
// })
it('test ')
})