This commit is contained in:
2912401452 2021-09-15 11:47:10 +08:00
commit e6debc224e
23 changed files with 304 additions and 53 deletions

View File

@ -14,7 +14,7 @@
"message": "chore: publish"
}
},
"version": "2.5.14",
"version": "2.5.16",
"npmClient": "yarn",
"useWorkspaces": true,
"publishConfig": {

View File

@ -153,7 +153,7 @@
"version": "lerna version --force-publish --conventional-commits --exact --no-changelog",
"version:prerelease": "lerna version --force-publish --conventional-prerelease",
"prerelease": "yarn build && yarn bundle",
"release-beta": "yarn run prerelease && lerna publish --dist-tag beta from-package --registry https://registry.npmjs.com/ --force-publish && lerna run sync",
"release-beta": "yarn run prerelease && lerna publish --dist-tag beta from-package --registry https://registry.npmjs.org/ --force-publish && lerna run sync",
"release": "lerna publish from-package --registry https://registry.npmjs.com/ --force-publish && lerna run sync",
"release-cdn": "antv-bin upload -n @antv/l7",
"storybook": "start-storybook -p 6006",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-component",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -25,8 +25,8 @@
"author": "lzxue",
"license": "ISC",
"dependencies": {
"@antv/l7-core": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-core": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"eventemitter3": "^4.0.0",
"inversify": "^5.0.1",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-core",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -24,7 +24,7 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"@mapbox/tiny-sdf": "^1.1.1",
"ajv": "^6.10.2",

View File

@ -144,7 +144,8 @@ export default class PickingService implements IPickingService {
}
this.alreadyInPicking = true;
await this.pickingLayers(target);
this.layerService.renderLayers();
// TODO: 触发图层更新渲染,同时传递更新类型
this.layerService.renderLayers('picking');
this.alreadyInPicking = false;
}
@ -361,11 +362,13 @@ export default class PickingService implements IPickingService {
layer: ILayer,
pickedColors: Uint8Array | undefined,
) {
// @ts-ignore
const [r, g, b] = pickedColors;
layer.hooks.beforeHighlight.call([r, g, b]);
}
private selectFeature(layer: ILayer, pickedColors: Uint8Array | undefined) {
// @ts-ignore
const [r, g, b] = pickedColors;
layer.hooks.beforeSelect.call([r, g, b]);
}

View File

@ -313,7 +313,7 @@ export interface ILayerService {
remove(layer: ILayer): void;
removeAllLayers(): void;
updateRenderOrder(): void;
renderLayers(): void;
renderLayers(type?: string): void;
getOESTextureFloat(): boolean;
destroy(): void;
}

View File

@ -21,6 +21,8 @@ export default class LayerService implements ILayerService {
private animateInstanceCount: number = 0;
private lastRenderTime: number = new Date().getTime();
@inject(TYPES.IRendererService)
private readonly renderService: IRendererService;
@ -69,7 +71,13 @@ export default class LayerService implements ILayerService {
this.destroy();
}
public renderLayers() {
public renderLayers(type?: string) {
// TODO: 每次渲染的时候都需要进行渲染判断,判断是否进行渲染
// 没有传递 type 参数时默认触发的是地图事件,优先级最高,直接渲染
if (!this.renderTest(type)) {
return;
}
if (this.alreadyInRendering) {
return;
}
@ -119,6 +127,23 @@ export default class LayerService implements ILayerService {
return this.renderService.extensionObject.OES_texture_float;
}
// 渲染检测
private renderTest(type: string | undefined): boolean {
// 继续渲染事件
const renderTime = new Date().getTime();
if (type) {
switch (type) {
case 'picking':
// picking 类型的渲染事件 若是触发的时间与上次触发的间隔在 64 ms 之内,则放弃此次渲染
return !(renderTime - this.lastRenderTime < 64);
default:
return true;
}
}
this.lastRenderTime = renderTime;
return true;
}
private clear() {
this.renderService.clear({
color: [0, 0, 0, 0],

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7",
"version": "2.5.14",
"version": "2.5.16",
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
"main": "lib/index.js",
"module": "es/index.js",
@ -25,12 +25,12 @@
"author": "antv",
"license": "MIT",
"dependencies": {
"@antv/l7-component": "^2.5.14",
"@antv/l7-core": "^2.5.14",
"@antv/l7-layers": "^2.5.14",
"@antv/l7-maps": "^2.5.14",
"@antv/l7-scene": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-component": "2.5.16",
"@antv/l7-core": "2.5.16",
"@antv/l7-layers": "2.5.16",
"@antv/l7-maps": "2.5.16",
"@antv/l7-scene": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7"
},
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",

View File

@ -1,2 +1,2 @@
const version = '2.5.14';
const version = '2.5.15';
export { version };

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-layers",
"version": "2.5.14",
"version": "2.5.16",
"description": "L7's collection of built-in layers",
"main": "lib/index.js",
"module": "es/index.js",
@ -24,9 +24,9 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.5.14",
"@antv/l7-source": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-core": "2.5.16",
"@antv/l7-source": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"@mapbox/martini": "^0.2.0",
"@turf/meta": "^6.0.2",

View File

@ -3,7 +3,7 @@ import { aProjectFlat, lngLatToMeters } from '@antv/l7-utils';
import earcut from 'earcut';
import { vec3 } from 'gl-matrix';
import ExtrudePolyline from '../utils/extrude_polyline';
import { calculteCentroid } from '../utils/geo';
import { calculateCentroid } from '../utils/geo';
import extrudePolygon, {
extrude_PolygonNormal,
fillPolygon,
@ -24,8 +24,9 @@ const GeometryCache: IGeometryCache = {};
* 2D
* @param feature feature
*/
export function PointFillTriangulation(feature: IEncodeFeature) {
const coordinates = calculteCentroid(feature.coordinates);
const coordinates = calculateCentroid(feature.coordinates);
return {
vertices: [...coordinates, ...coordinates, ...coordinates, ...coordinates],
indices: [0, 1, 2, 2, 3, 0],
@ -57,7 +58,7 @@ export function PointExtrudeTriangulation(feature: IEncodeFeature) {
* @param feature feature
*/
export function PointImageTriangulation(feature: IEncodeFeature) {
const coordinates = calculteCentroid(feature.coordinates);
const coordinates = calculateCentroid(feature.coordinates);
return {
vertices: [...coordinates],
indices: [0],

View File

@ -2,7 +2,7 @@ import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';
import { isNumber } from 'lodash';
import BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';
import { PointExtrudeTriangulation } from '../../core/triangulation';
import { calculteCentroid } from '../../utils/geo';
import { calculateCentroid } from '../../utils/geo';
import pointExtrudeFrag from '../shaders/extrude_frag.glsl';
import pointExtrudeVert from '../shaders/extrude_vert.glsl';
interface IPointLayerStyleOptions {
@ -151,7 +151,7 @@ export default class ExtrudeModel extends BaseModel {
},
size: 3,
update: (feature: IEncodeFeature, featureIdx: number) => {
const coordinates = calculteCentroid(feature.coordinates);
const coordinates = calculateCentroid(feature.coordinates);
return [coordinates[0], coordinates[1], 0];
},
},

View File

@ -17,7 +17,7 @@ import BaseModel, {
styleSingle,
} from '../../core/BaseModel';
import CollisionIndex from '../../utils/collision-index';
import { calculteCentroid } from '../../utils/geo';
import { calculateCentroid } from '../../utils/geo';
import {
anchorType,
getGlyphQuads,
@ -429,18 +429,18 @@ export default class TextModel extends BaseModel {
feature.glyphQuads = glyphQuads;
// feature.centroid = calculteCentroid(coordinates);
feature.centroid = calculteCentroid(feature.coordinates);
feature.centroid = calculateCentroid(feature.coordinates);
// 此时地图高德2.0 originCentroid == centroid
feature.originCentroid =
feature.version === 'GAODE2.x'
? calculteCentroid(feature.originCoordinates)
? calculateCentroid(feature.originCoordinates)
: (feature.originCentroid = feature.centroid);
this.glyphInfoMap[id as number] = {
shaping,
glyphQuads,
centroid: calculteCentroid(feature.coordinates),
centroid: calculateCentroid(feature.coordinates),
};
return feature;
});

View File

@ -1,6 +1,6 @@
type Position = number[];
import { isNumber } from 'lodash';
export function calculteCentroid(
export function calculateCentroid(
coord: Position | Position[] | Position[][],
): Position {
// let pos = coord as Position;

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-map",
"version": "2.5.14",
"version": "2.5.16",
"description": "l7 map",
"keywords": [],
"author": "thinkinggis <lzx199065@gmail.com>",
@ -37,7 +37,7 @@
},
"homepage": "https://github.com/antvis/L7#readme",
"dependencies": {
"@antv/l7-utils": "^2.5.14",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"@mapbox/point-geometry": "^0.1.0",
"@mapbox/unitbezier": "^0.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-maps",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -27,9 +27,9 @@
"license": "ISC",
"dependencies": {
"@amap/amap-jsapi-loader": "^0.0.3",
"@antv/l7-core": "^2.5.14",
"@antv/l7-map": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-core": "2.5.16",
"@antv/l7-map": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"@types/amap-js-api": "^1.4.6",
"@types/mapbox-gl": "^1.11.2",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-renderer",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -26,7 +26,7 @@
"gl": "^4.4.0"
},
"dependencies": {
"@antv/l7-core": "^2.5.14",
"@antv/l7-core": "2.5.16",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"l7regl": "^0.0.14",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-scene",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -23,12 +23,12 @@
"author": "xiaoiver",
"license": "ISC",
"dependencies": {
"@antv/l7-component": "^2.5.14",
"@antv/l7-core": "^2.5.14",
"@antv/l7-layers": "^2.5.14",
"@antv/l7-maps": "^2.5.14",
"@antv/l7-renderer": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-component": "2.5.16",
"@antv/l7-core": "2.5.16",
"@antv/l7-layers": "2.5.16",
"@antv/l7-maps": "2.5.16",
"@antv/l7-renderer": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"mapbox-gl": "^1.2.1",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-source",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -26,8 +26,8 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.5.14",
"@antv/l7-utils": "^2.5.14",
"@antv/l7-core": "2.5.16",
"@antv/l7-utils": "2.5.16",
"@babel/runtime": "^7.7.7",
"@mapbox/geojson-rewind": "^0.4.0",
"@turf/helpers": "^6.1.4",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-three",
"version": "2.5.14",
"version": "2.5.16",
"description": "three for L7 ",
"keywords": [
"3D",
@ -44,7 +44,7 @@
},
"homepage": "https://github.com/antvis/L7#readme",
"dependencies": {
"@antv/l7": "^2.5.14",
"@antv/l7": "2.5.16",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"reflect-metadata": "^0.1.13",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-utils",
"version": "2.5.14",
"version": "2.5.16",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -0,0 +1,215 @@
// @ts-ignore
import { Scene } from '@antv/l7';
import { PointLayer } from '@antv/l7-layers';
import { GaodeMap } from '@antv/l7-maps';
import * as React from 'react';
export default class PointTest extends React.Component {
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [110.19382669582967, 30.258134],
pitch: 0,
zoom: 2,
}),
});
// @ts-ignore
var Stats = function() {
function h(a) {
c.appendChild(a.dom);
return a;
}
function k(a) {
for (var d = 0; d < c.children.length; d++)
// @ts-ignore
c.children[d].style.display = d === a ? 'block' : 'none';
l = a;
}
var l = 0,
c = document.createElement('div');
c.style.cssText =
'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';
c.addEventListener(
'click',
function(a) {
a.preventDefault();
k(++l % c.children.length);
},
!1,
);
var g = (performance || Date).now(),
e = g,
a = 0,
// @ts-ignore
r = h(new Stats.Panel('FPS', '#0ff', '#002')),
// @ts-ignore
f = h(new Stats.Panel('MS', '#0f0', '#020'));
// @ts-ignore
if (self.performance && self.performance.memory)
// @ts-ignore
var t = h(new Stats.Panel('MB', '#f08', '#201'));
k(0);
return {
REVISION: 16,
dom: c,
addPanel: h,
showPanel: k,
begin: function() {
g = (performance || Date).now();
},
end: function() {
a++;
var c = (performance || Date).now();
f.update(c - g, 200);
// @ts-ignore
if (
c > e + 1e3 &&
(r.update((1e3 * a) / (c - e), 100), (e = c), (a = 0), t)
) {
// @ts-ignore
var d = performance.memory;
t.update(d.usedJSHeapSize / 1048576, d.jsHeapSizeLimit / 1048576);
}
return c;
},
update: function() {
g = this.end();
},
domElement: c,
setMode: k,
};
};
// @ts-ignore
Stats.Panel = function(h, k, l) {
var c = Infinity,
g = 0,
e = Math.round,
a = e(window.devicePixelRatio || 1),
r = 80 * a,
f = 48 * a,
t = 3 * a,
u = 2 * a,
d = 3 * a,
m = 15 * a,
n = 74 * a,
p = 30 * a,
q = document.createElement('canvas');
q.width = r;
q.height = f;
q.style.cssText = 'width:80px;height:48px';
var b = q.getContext('2d');
b.font = 'bold ' + 9 * a + 'px Helvetica,Arial,sans-serif';
b.textBaseline = 'top';
b.fillStyle = l;
b.fillRect(0, 0, r, f);
b.fillStyle = k;
b.fillText(h, t, u);
b.fillRect(d, m, n, p);
b.fillStyle = l;
b.globalAlpha = 0.9;
b.fillRect(d, m, n, p);
// @ts-ignore
return {
dom: q,
update: function(f, v) {
c = Math.min(c, f);
g = Math.max(g, f);
b.fillStyle = l;
b.globalAlpha = 1;
b.fillRect(0, 0, r, m);
b.fillStyle = k;
b.fillText(e(f) + ' ' + h + ' (' + e(c) + '-' + e(g) + ')', t, u);
// @ts-ignore
b.drawImage(q, d + a, m, n - a, p, d, m, n - a, p);
b.fillRect(d + n - a, m, a, p);
b.fillStyle = l;
b.globalAlpha = 0.9;
b.fillRect(d + n - a, m, a, e((1 - f / v) * p));
},
};
};
'object' === typeof module && (module.exports = Stats);
// @ts-ignore
var stats = new Stats();
document.body.appendChild(stats.dom);
// let address = 'https://gw.alipayobjects.com/os/bmw-prod/e76d89f4-aa69-4974-90b7-b236904a43b1.json' // 100
// let address = 'https://gw.alipayobjects.com/os/bmw-prod/edc8219a-b095-4451-98e9-3e387e290087.json' // 10000
// let address = 'https://gw.alipayobjects.com/os/bmw-prod/2c37f08b-3fe6-4c68-a699-dc15cfc217f1.json' // 50000
let address =
'https://gw.alipayobjects.com/os/bmw-prod/8adff753-64e6-4ffa-9e7b-1f3dc6f4fd76.json'; // 100000
fetch(address)
.then((res) => res.json())
.then((data) => {
const layer = new PointLayer()
.source(data, {
parser: {
type: 'json',
x: 'lng',
y: 'lat',
},
})
.size(10)
.color('#f00')
.shape('circle')
.style({
opacity: 1.0,
})
.select(true)
.active(true);
scene.on('loaded', () => {
scene.addLayer(layer);
// @ts-ignore
// layer.layerService.startAnimate2(stats)
// ILayerService
// ---
// startAnimate2(state: any): void;
// ---
// LayerService
// ---
// private stats: any;
// ---
// @ts-ignore
// public startAnimate2(stats) {
// // @ts-ignore
// this.stats = stats
// if (this.animateInstanceCount++ === 0) {
// this.clock.start();
// this.runRender();
// }
// }
// public runRender() {
// // @ts-ignore
// this.stats.update()
// this.renderLayers();
// this.layerRenderID = requestAnimationFrame(this.runRender.bind(this));
// }
});
});
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
></div>
);
}
}

View File

@ -0,0 +1,7 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import PointTest from './components/Map';
// @ts-ignore
storiesOf('地图性能检测', module)
.add('点', () => <PointTest />)