fix(line):line

This commit is contained in:
李正学 2018-11-19 12:06:42 +08:00
parent 673a6205c4
commit 6fb4a2e973
14 changed files with 143 additions and 149 deletions

View File

@ -1,4 +1,4 @@
import Material from '../../../geom/material/material'
import Material from '../../../geom/material/material';
import picking_frag from './picking_frag.glsl';
import picking_vert from './picking_vert.glsl';

View File

@ -6,7 +6,6 @@ import Base from './base';
import * as THREE from './three';
import ColorUtil from '../attr/color-util';
import * as source from '../source/index';
import * as turfMeta from '@turf/meta';
import PickingMaterial from '../core/engine/picking/pickingMaterial';
import Attr from '../attr/index';
import Util from '../util';
@ -277,7 +276,7 @@ export default class Layer extends Base {
const attrOptions = this.get('attrOptions');
for (const type in attrOptions) {
if (attrOptions.hasOwnProperty(type)) {
this._updateAttr(type)
this._updateAttr(type);
}
}
}
@ -462,11 +461,10 @@ export default class Layer extends Base {
}
_addPickingEvents() {
// TODO: Find a way to properly remove this listener on destroy
this.scene.on('pick', (e) => {
this.scene.on('pick', e => {
// Re-emit click event from the layer
const { featureId, point2d, point3d, intersects } = e;
if(intersects.length === 0)
return;
if (intersects.length === 0) { return; }
const source = this.layerSource.get('data');
const feature = source.features[featureId];
const lnglat = this.scene.containerToLngLat(point2d);
@ -474,7 +472,7 @@ export default class Layer extends Base {
feature,
pixel: point2d,
lnglat: { lng: lnglat.lng, lat: lnglat.lat }
}
};
this.emit('click', target);
// this.emit('move', target);
});
@ -503,7 +501,7 @@ export default class Layer extends Base {
break;
}
}
colorAttr.needsUpdate =true
colorAttr.needsUpdate = true;
return;
}
@ -540,7 +538,7 @@ export default class Layer extends Base {
colorAttr.array[index * 4 + 3] = color[3];
pickAttr.array[index] = id;
}
})
});
colorAttr.needsUpdate = true;
pickAttr.needsUpdate = true;
this._needUpdateFilter = false;
@ -581,7 +579,7 @@ export default class Layer extends Base {
colorAttr.array[i * 4 + 3] = color[3];
}
}
})
});
colorAttr.needsUpdate = true;
}
/**

View File

@ -296,7 +296,7 @@ export default class BufferBase extends Base {
pickingIds,
shapePositions,
a_size,
faceUv: new Float32Array(polygon.faceUv),
faceUv: new Float32Array(polygon.faceUv)
};

View File

@ -55,7 +55,6 @@ export default class PointBuffer extends BufferBase {
let indexCount = 0;
this.bufferStruct.style = properties;
coordinates.forEach((geo, index) => {
const m1 = new THREE.Matrix4();
let { size, shape } = properties[index];
let shapeType = 'extrude';
@ -66,7 +65,7 @@ export default class PointBuffer extends BufferBase {
Util.isArray(size) || (size = [ size, size, size ]);
}
if (regularShape[shape] == null) {
uvs.push(0,0,1,0,1,1,1,1,0,1,0,0)
uvs.push(0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0);
shape = 'square';
}
const vert = regularShape[shape](shapeType);

View File

@ -53,16 +53,15 @@ export default class PointLayer extends Layer {
u_zoom: this.scene.getZoom()
});
mtl.setDefinesvalue('SHAPE', true);
if(shape=='radar') {
if (shape === 'radar') {
mtl.fragmentShader = radar;
}
if(shape=='warn') {
if (shape === 'warn') {
mtl.fragmentShader = warn;
}
} else { // sdf 绘制点
mtl = new PointMaterial({
u_opacity: opacity,
@ -83,11 +82,9 @@ export default class PointLayer extends Layer {
if (this.shapeType === 'image') {
geometry.addAttribute('uv', new THREE.Float32BufferAttribute(attributes.uvs, 2));
geometry.addAttribute('a_size', new THREE.Float32BufferAttribute(attributes.sizes, 1));
} else if(this.shapeType=== undefined)
{
} else if (this.shapeType === undefined) {
geometry.addAttribute('a_size', new THREE.Float32BufferAttribute(attributes.sizes, 1));
}
else { // 多边形面
} else { // 多边形面
geometry.addAttribute('normal', new THREE.Float32BufferAttribute(attributes.normals, 3));
geometry.addAttribute('a_shape', new THREE.Float32BufferAttribute(attributes.shapePositions, 3));
geometry.addAttribute('a_size', new THREE.Float32BufferAttribute(attributes.a_size, 3));

View File

@ -10,23 +10,22 @@ export default class CSVSource extends Source {
const y = this.get('y');
const x1 = this.get('x1');
const y1 = this.get('y1');
const coords = this.get('coordinates')
const coords = this.get('coordinates');
this.propertiesData = [];// 临时使用
this.geoData = [];
let csvdata = data;
Util.isArray(csvdata) || (csvdata = csvParse(data));
this.propertiesData = csvdata;
csvdata.forEach((col, featureIndex) => {
if(col['coordinates']){
coordinates = col['coordinates'];
let coordinates = [];
if (col.coordinates) {
coordinates = col.coordinates;
}
let coordinates = [ col[x], col[y] ];
if (x1 && y1) {
coordinates = [[ col[x], col[y] ], [ col[x1], col[y1] ]];
}
if(coords&& col['coords'])
coordinates =col['coords'];
if (coords && col.coords) { coordinates = col.coords; }
col._id = featureIndex + 1;
this._coordProject(coordinates);
this.geoData.push(this._coordProject(coordinates));

View File

@ -25,6 +25,7 @@ export default class GeojsonSource extends Source {
const data = this.get('data');
const selectFeatureIds = [];
let featureStyleId = 0;
/* eslint-disable */
turfMeta.flattenEach(data, (currentFeature, featureIndex, multiFeatureIndex) => {
/* eslint-disable */
if (featureIndex === (featureId)) {