mirror of https://gitee.com/antv-l7/antv-l7
fix(rewind):vector tile not rewind
This commit is contained in:
parent
4e6ec5a2c4
commit
59a66e93a6
|
@ -17,7 +17,7 @@
|
|||
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
|
||||
<script src="https://webapi.amap.com/maps?v=1.4.15&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>
|
||||
|
@ -28,7 +28,7 @@ const scene = new L7.Scene({
|
|||
mapStyle: 'light', // 样式URL
|
||||
center: [104.838088,34.075889 ],
|
||||
pitch: 0,
|
||||
hash:true,
|
||||
hash:false,
|
||||
zoom: 3,
|
||||
|
||||
});
|
||||
|
|
|
@ -262,9 +262,6 @@ export default class Layer extends Base {
|
|||
Util.assign(animateOptions, cfg);
|
||||
this.set('animateOptions', animateOptions);
|
||||
return this;
|
||||
}
|
||||
texture() {
|
||||
|
||||
}
|
||||
fitBounds() {
|
||||
const extent = this.layerSource.data.extent;
|
||||
|
|
|
@ -27,7 +27,7 @@ export default class Scene extends Base {
|
|||
|
||||
_initEngine(mapContainer) {
|
||||
this._engine = new Engine(mapContainer, this);
|
||||
this.registerMapEvent();
|
||||
// this.registerMapEvent();
|
||||
this._engine.run();
|
||||
compileBuiltinModules();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Base from '../core/base';
|
||||
import WorkerPool from '../worker/worker_pool';
|
||||
import { throttle } from '@antv/util';
|
||||
import throttle from '../util/throttle';
|
||||
import { toLngLat, Bounds } from '@antv/geo-coord';
|
||||
import SourceCache from '../source/source_cache';
|
||||
import WorkerController from '../worker/worker_controller';
|
||||
|
@ -66,13 +66,13 @@ export default class Style extends Base {
|
|||
|
||||
}
|
||||
addMapEvent() {
|
||||
this.mapEventHander = () => {
|
||||
this.mapEventHander = throttle(() => {
|
||||
requestAnimationFrame(() => {
|
||||
for (const key in this._sourceCaches) {
|
||||
this._sourceCaches[key].update(this.layers, this.sourceStyles[key]);
|
||||
}
|
||||
});
|
||||
};
|
||||
}, 200);
|
||||
this.scene.map.on('zoomchange', this.mapEventHander);
|
||||
this.scene.map.on('dragend', this.mapEventHander);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'three/src/polyfills.js';
|
||||
import { BufferAttribute } from 'three/src/core/BufferAttribute.js';
|
||||
export * from 'three/src/constants.js';
|
||||
export { Scene } from 'three/src/scenes/Scene.js';
|
||||
export { WebGLRenderer } from 'three/src/renderers/WebGLRenderer.js';
|
||||
|
@ -30,7 +31,7 @@ export { DataTexture } from 'three/src/textures/DataTexture.js';
|
|||
export { Color } from 'three/src/math/Color.js';
|
||||
export {
|
||||
Float64BufferAttribute,
|
||||
Float32BufferAttribute,
|
||||
// Float32BufferAttribute,
|
||||
Uint32BufferAttribute,
|
||||
Int32BufferAttribute,
|
||||
Uint16BufferAttribute,
|
||||
|
@ -43,3 +44,11 @@ export {
|
|||
|
||||
export { InstancedBufferAttribute } from 'three/src/core/InstancedBufferAttribute'
|
||||
// export * from '../../build/three.js';
|
||||
function Float32BufferAttribute( array, itemSize, normalized ) {
|
||||
BufferAttribute.call( this, array, itemSize, normalized );
|
||||
|
||||
}
|
||||
|
||||
Float32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );
|
||||
Float32BufferAttribute.prototype.constructor = Float32BufferAttribute;
|
||||
export { Float32BufferAttribute }
|
|
@ -166,7 +166,7 @@ export default class BufferBase extends Base {
|
|||
sizes: new Float32Array(polygon.sizes)
|
||||
|
||||
};
|
||||
|
||||
polygon = {};
|
||||
return attributes;
|
||||
}
|
||||
_toPointShapeAttributes(polygon) {
|
||||
|
@ -331,7 +331,7 @@ export default class BufferBase extends Base {
|
|||
colors,
|
||||
pickingIds
|
||||
};
|
||||
|
||||
polygonline = {};
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
@ -363,6 +363,7 @@ export default class BufferBase extends Base {
|
|||
pickingIds
|
||||
|
||||
};
|
||||
point = {};
|
||||
return attributes;
|
||||
}
|
||||
_generateTexture() {
|
||||
|
|
|
@ -60,7 +60,7 @@ export default function extrudePolygon(points, extrude) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
points = [];
|
||||
return {
|
||||
positions,
|
||||
faceUv,
|
||||
|
@ -100,6 +100,7 @@ export function extrudePolygonLine(points, extrude) {
|
|||
}
|
||||
}
|
||||
}
|
||||
points = [];
|
||||
return {
|
||||
positions,
|
||||
positionsIndex: cells
|
||||
|
|
|
@ -31,6 +31,7 @@ export default class VectorTileMesh {
|
|||
this.layer.shape = this.layer._getShape(layerData);
|
||||
}
|
||||
this.mesh = getRender(this.layer.get('type'), this.layer.shape)(null, this.layer, data.attributes);
|
||||
this.mesh.frustumCulled = false;
|
||||
if (this.mesh.type !== 'composer') { // 热力图的情况
|
||||
this.mesh.onBeforeRender = renderer => {
|
||||
this._renderMask(renderer);
|
||||
|
@ -86,7 +87,7 @@ export default class VectorTileMesh {
|
|||
const br = [ tilebound.getBottomRight().x, tilebound.getBottomRight().y, 0 ];
|
||||
const tl = [ tilebound.getTopLeft().x, tilebound.getTopLeft().y, 0 ];
|
||||
const tr = [ tilebound.getTopRight().x, tilebound.getTopRight().y, 0 ];
|
||||
const positions = [ ...bl, ...tr, ...br, ...bl, ...tl, ...tr ];
|
||||
const positions = new Float32Array([ ...bl, ...tr, ...br, ...bl, ...tl, ...tr ]);
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
geometry.addAttribute('position', new THREE.Float32BufferAttribute(positions, 3));
|
||||
const maskMaterial = new MaskMaterial();
|
||||
|
|
|
@ -3,7 +3,10 @@ import { getCoords } from '@turf/invariant';
|
|||
import { djb2hash } from '../../util/bkdr-hash';
|
||||
import rewind from '@mapbox/geojson-rewind';
|
||||
export default function geoJSON(data, cfg) {
|
||||
rewind(data, true);
|
||||
// 矢量瓦片图层不做 rewind
|
||||
if (!cfg.hasOwnProperty('sourceLayer')) {
|
||||
rewind(data, true);
|
||||
}
|
||||
const resultData = [];
|
||||
const featureKeys = {};
|
||||
data.features = data.features.filter(item => {
|
||||
|
|
|
@ -88,7 +88,7 @@ export default class SouceCache extends Base {
|
|||
_calculateTileIDs() {
|
||||
this._tileMap = {};
|
||||
this.updateTileList = [];
|
||||
const zoom = Math.floor(this.scene.getZoom()); // zoom - 1
|
||||
const zoom = Math.floor(this.scene.getZoom()) - 1; // zoom - 1
|
||||
const minSourceZoom = this.get('minZoom');
|
||||
const maxSourceZoom = this.get('maxZoom');
|
||||
this.tileZoom = zoom > maxSourceZoom ? maxSourceZoom : zoom;
|
||||
|
|
|
@ -30,6 +30,7 @@ export default class WorkerTile {
|
|||
type: 'FeatureCollection',
|
||||
features
|
||||
};
|
||||
delete data.layers[sourcelayer];
|
||||
for (let i = 0; i < sourceStyle[sourcelayer].length; i++) {
|
||||
const style = sourceStyle[sourcelayer][i];
|
||||
style.sourceOption.parser.type = 'geojson';
|
||||
|
|
|
@ -35,4 +35,5 @@ export default class WorkerPool {
|
|||
}
|
||||
}
|
||||
|
||||
WorkerPool.workerCount = Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1);
|
||||
WorkerPool.workerCount = 1;
|
||||
// Math.max(Math.floor(window.navigator.hardwareConcurrency / 2), 1);
|
||||
|
|
Loading…
Reference in New Issue