diff --git a/dev-demos/features/canvasLayer/custom.md b/dev-demos/features/canvasLayer/custom.md
new file mode 100644
index 0000000000..ae19c4dfaa
--- /dev/null
+++ b/dev-demos/features/canvasLayer/custom.md
@@ -0,0 +1,155 @@
+### CanvasLayer - demo1
+```tsx
+import { CanvasLayer, Scene } from '@antv/l7';
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+ let x = 0;
+function draw(option) {
+const { size, ctx, mapService } = option;
+const [ width, height ] = size;
+
+const radius = 30,
+ rectWidth = radius * 2;
+const rectHeight = rectWidth;
+
+ctx.clearRect(0, 0, width, height);
+
+const points = [
+ {
+ lng: 108.544921875,
+ lat: 30.977609093348686,
+ level: 85,
+ color: 'rgba( 220,20,60, 0.6)'
+ },
+ {
+ lng: 110.654296875,
+ lat: 31.090574094954192,
+ level: 75,
+ color: 'rgba( 255,140,0, 0.6)'
+ },
+ {
+ lng: 112.5,
+ lat: 29.80251790576445,
+ level: 65,
+ color: 'rgba(255,165,0, 0.6)'
+ },
+ {
+ lng: 114.78515624999999,
+ lat: 30.64867367928756,
+ level: 40,
+ color: 'rgba(30,144,255, 0.6)'
+ },
+ {
+ lng: 116.49902343749999,
+ lat: 29.84064389983441,
+ level: 50,
+ color: 'rgba(30,144,255, 0.6)'
+ },
+ {
+ lng: 118.21289062499999,
+ lat: 31.16580958786196,
+ level: 20,
+ color: 'rgba( 127,255,0, 0.6)'
+ },
+ {
+ lng: 119.091796875,
+ lat: 32.509761735919426,
+ level: 50,
+ color: 'rgba(30,144,255, 0.6)'
+ },
+ {
+ lng: 121.0693359374999,
+ lat: 31.80289258670676,
+ level: 45,
+ color: 'rgba(30,144,255, 0.6)'
+ }
+];
+ctx.fillStyle = 'rgb(35,75,225)';
+ctx.font = 'normal small-caps bold 14px arial';
+ctx.textAlign = 'center';
+ctx.textBaseline = 'middle';
+
+points.map(point => {
+ const pixelCenter = mapService.lngLatToContainer([ point.lng, point.lat ]);
+ pixelCenter.x *= window.devicePixelRatio;
+ pixelCenter.y *= window.devicePixelRatio;
+ const rectStartX = pixelCenter.x - radius;
+ const rectStartY = pixelCenter.y - radius;
+
+ ctx.save();
+
+ ctx.fillText(point.level + '%', pixelCenter.x, pixelCenter.y);
+
+ ctx.beginPath();
+ ctx.arc(pixelCenter.x, pixelCenter.y, radius, 0, Math.PI * 2);
+ ctx.fillStyle = 'rgba(135,206,250,0.2)';
+ ctx.closePath();
+ ctx.fill();
+ ctx.clip();
+
+ ctx.beginPath();
+ ctx.fillStyle = point.color;
+ ctx.moveTo(rectStartX, pixelCenter.y);
+
+ const waterheight = rectStartY + ((100 - point.level) / 100) * rectHeight;
+ for (let i = 0; i <= rectWidth; i += 10) {
+ ctx.lineTo(
+ rectStartX + i,
+ waterheight + Math.sin(Math.PI * 2 * (i / rectWidth) + x) * 3 + 1
+ );
+ }
+
+ ctx.lineTo(pixelCenter.x + radius, pixelCenter.y + radius);
+ ctx.lineTo(rectStartX, pixelCenter.y + radius);
+ ctx.lineTo(rectStartX, pixelCenter.y);
+ ctx.closePath();
+
+ ctx.fill();
+
+ ctx.restore();
+});
+}
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ style: 'fresh',
+ center: [ 115, 31 ],
+ zoom: 5.0
+ })
+ });
+ scene.on('loaded', () => {
+ const layer = new CanvasLayer({})
+ .style({
+ zIndex: 10,
+ update: 'always',
+ drawingOnCanvas: draw
+ })
+ .animate({
+ enable: true
+ });
+ scene.addLayer(layer);
+
+ setInterval(() => {
+ x += 0.1;
+ layer.style({
+ drawingOnCanvas: draw
+ });
+ scene.render();
+ }, 30);
+ });
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/canvasLayer/custom2.md b/dev-demos/features/canvasLayer/custom2.md
new file mode 100644
index 0000000000..d33a1d7661
--- /dev/null
+++ b/dev-demos/features/canvasLayer/custom2.md
@@ -0,0 +1,75 @@
+### CanvasLayer - demo2
+```tsx
+import { CanvasLayer, Scene } from '@antv/l7';
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ style: 'fresh',
+ center: [ 90, 31 ],
+ zoom: 2
+ })
+ });
+ scene.on('loaded', () => {
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json'
+ )
+ .then(res => res.json())
+ .then(data => {
+ const layer = new CanvasLayer({})
+ .style({
+ zIndex: 10,
+ update: 'dragend',
+ drawingOnCanvas: option => {
+ const { size, ctx, mapService } = option;
+ const [ width, height ] = size;
+
+ ctx.clearRect(0, 0, width, height);
+ ctx.fillStyle = 'rgba(0, 200, 0, 0.2)';
+ data.features.map(feature => {
+ const pixelCenter = mapService.lngLatToContainer(
+ feature.geometry.coordinates
+ );
+ pixelCenter.x *= window.devicePixelRatio;
+ pixelCenter.y *= window.devicePixelRatio;
+ if (
+ pixelCenter.x < 0 ||
+ pixelCenter.y < 0 ||
+ pixelCenter.x > width ||
+ pixelCenter.y > height
+ ) { return ''; }
+ ctx.beginPath();
+ ctx.arc(
+ pixelCenter.x,
+ pixelCenter.y,
+ feature.properties.capacity / 200,
+ 0,
+ Math.PI * 2
+ );
+ ctx.fill();
+ ctx.closePath();
+ });
+ }
+ });
+
+ scene.addLayer(layer);
+ });
+ });
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/citybuilding/amap1.md b/dev-demos/features/citybuilding/amap1.md
new file mode 100644
index 0000000000..e42ccb00fc
--- /dev/null
+++ b/dev-demos/features/citybuilding/amap1.md
@@ -0,0 +1,2 @@
+### building - amap1
+
\ No newline at end of file
diff --git a/dev-demos/features/citybuilding/amap1.tsx b/dev-demos/features/citybuilding/amap1.tsx
new file mode 100644
index 0000000000..2eba793e94
--- /dev/null
+++ b/dev-demos/features/citybuilding/amap1.tsx
@@ -0,0 +1,124 @@
+// @ts-ignore
+import { Scene, CityBuildingLayer, LineLayer, PolygonLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ style: 'dark',
+ center: [120.145, 30.238915],
+ pitch: 60,
+ zoom: 13.2,
+ }),
+ });
+ fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/ggFwDClGjjvpSMBIrcEx.json',
+ ).then(async (res) => {
+ const pointLayer = new CityBuildingLayer();
+ pointLayer
+ .source(await res.json())
+ .size('floor', [0, 500])
+ .color('rgba(242,246,250,1.0)')
+ .animate({
+ enable: true,
+ })
+ .active({
+ color: '#0ff',
+ mix: 0.5,
+ })
+ .style({
+ opacity: 0.7,
+ baseColor: 'rgb(16, 16, 16)',
+ windowColor: 'rgb(30, 60, 89)',
+ brightColor: 'rgb(255, 176, 38)',
+ sweep: {
+ enable: true,
+ sweepRadius: 2,
+ sweepColor: '#1990FF',
+ sweepSpeed: 0.5,
+ sweepCenter: [120.145319, 30.238915],
+ },
+ });
+ scene.addLayer(pointLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/67130c6c-7f49-4680-915c-54e69730861d.json',
+ )
+ .then((data) => data.json())
+ .then(({ lakeBorderData, lakeData, landData }) => {
+ const lakeLayer = new PolygonLayer()
+ .source(lakeData)
+ .shape('fill')
+ .color('#1E90FF')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'out', // in - out
+ },
+ });
+ const landLayer = new PolygonLayer()
+ .source(landData)
+ .shape('fill')
+ .color('#3CB371')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ const lakeBorderLayer = new PolygonLayer()
+ .source(lakeBorderData)
+ .shape('fill')
+ .color('#ccc')
+ .style({
+ opacity: 0.5,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ scene.addLayer(lakeLayer);
+ scene.addLayer(lakeBorderLayer);
+ scene.addLayer(landLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const layer = new LineLayer({
+ zIndex: 0,
+ depth: true,
+ })
+ .source(data)
+ .size(1)
+ .shape('line')
+ .color('#1990FF')
+ .animate({
+ interval: 1, // 间隔
+ duration: 2, // 持续时间,延时
+ trailLength: 2, // 流线长度
+ });
+ scene.addLayer(layer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/citybuilding/amap2.md b/dev-demos/features/citybuilding/amap2.md
new file mode 100644
index 0000000000..7357b7f283
--- /dev/null
+++ b/dev-demos/features/citybuilding/amap2.md
@@ -0,0 +1,2 @@
+### building - amap2
+
\ No newline at end of file
diff --git a/dev-demos/features/citybuilding/amap2.tsx b/dev-demos/features/citybuilding/amap2.tsx
new file mode 100644
index 0000000000..2fcbface47
--- /dev/null
+++ b/dev-demos/features/citybuilding/amap2.tsx
@@ -0,0 +1,124 @@
+// @ts-ignore
+import { Scene, CityBuildingLayer, LineLayer, PolygonLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMapV2 } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMapV2({
+ style: 'dark',
+ center: [120.145, 30.238915],
+ pitch: 60,
+ zoom: 13.2,
+ }),
+ });
+ fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/ggFwDClGjjvpSMBIrcEx.json',
+ ).then(async (res) => {
+ const pointLayer = new CityBuildingLayer();
+ pointLayer
+ .source(await res.json())
+ .size('floor', [0, 500])
+ .color('rgba(242,246,250,1.0)')
+ .animate({
+ enable: true,
+ })
+ .active({
+ color: '#0ff',
+ mix: 0.5,
+ })
+ .style({
+ opacity: 0.7,
+ baseColor: 'rgb(16, 16, 16)',
+ windowColor: 'rgb(30, 60, 89)',
+ brightColor: 'rgb(255, 176, 38)',
+ sweep: {
+ enable: true,
+ sweepRadius: 2,
+ sweepColor: '#1990FF',
+ sweepSpeed: 0.5,
+ sweepCenter: [120.145319, 30.238915],
+ },
+ });
+ scene.addLayer(pointLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/67130c6c-7f49-4680-915c-54e69730861d.json',
+ )
+ .then((data) => data.json())
+ .then(({ lakeBorderData, lakeData, landData }) => {
+ const lakeLayer = new PolygonLayer()
+ .source(lakeData)
+ .shape('fill')
+ .color('#1E90FF')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'out', // in - out
+ },
+ });
+ const landLayer = new PolygonLayer()
+ .source(landData)
+ .shape('fill')
+ .color('#3CB371')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ const lakeBorderLayer = new PolygonLayer()
+ .source(lakeBorderData)
+ .shape('fill')
+ .color('#ccc')
+ .style({
+ opacity: 0.5,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ scene.addLayer(lakeLayer);
+ scene.addLayer(lakeBorderLayer);
+ scene.addLayer(landLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const layer = new LineLayer({
+ zIndex: 0,
+ depth: true,
+ })
+ .source(data)
+ .size(1)
+ .shape('line')
+ .color('#1990FF')
+ .animate({
+ interval: 1, // 间隔
+ duration: 2, // 持续时间,延时
+ trailLength: 2, // 流线长度
+ });
+ scene.addLayer(layer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/citybuilding/mapbox.md b/dev-demos/features/citybuilding/mapbox.md
new file mode 100644
index 0000000000..113fe7c691
--- /dev/null
+++ b/dev-demos/features/citybuilding/mapbox.md
@@ -0,0 +1,2 @@
+### building - mapbox
+
\ No newline at end of file
diff --git a/dev-demos/features/citybuilding/mapbox.tsx b/dev-demos/features/citybuilding/mapbox.tsx
new file mode 100644
index 0000000000..f66135a511
--- /dev/null
+++ b/dev-demos/features/citybuilding/mapbox.tsx
@@ -0,0 +1,124 @@
+// @ts-ignore
+import { Scene, CityBuildingLayer, LineLayer, PolygonLayer } from '@antv/l7';
+// @ts-ignore
+import { Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new Mapbox({
+ style: 'dark',
+ center: [120.145, 30.238915],
+ pitch: 60,
+ zoom: 13.2,
+ }),
+ });
+ fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/ggFwDClGjjvpSMBIrcEx.json',
+ ).then(async (res) => {
+ const pointLayer = new CityBuildingLayer();
+ pointLayer
+ .source(await res.json())
+ .size('floor', [0, 500])
+ .color('rgba(242,246,250,1.0)')
+ .animate({
+ enable: true,
+ })
+ .active({
+ color: '#0ff',
+ mix: 0.5,
+ })
+ .style({
+ opacity: 0.7,
+ baseColor: 'rgb(16, 16, 16)',
+ windowColor: 'rgb(30, 60, 89)',
+ brightColor: 'rgb(255, 176, 38)',
+ sweep: {
+ enable: true,
+ sweepRadius: 2,
+ sweepColor: '#1990FF',
+ sweepSpeed: 0.5,
+ sweepCenter: [120.145319, 30.238915],
+ },
+ });
+ scene.addLayer(pointLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/67130c6c-7f49-4680-915c-54e69730861d.json',
+ )
+ .then((data) => data.json())
+ .then(({ lakeBorderData, lakeData, landData }) => {
+ const lakeLayer = new PolygonLayer()
+ .source(lakeData)
+ .shape('fill')
+ .color('#1E90FF')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'out', // in - out
+ },
+ });
+ const landLayer = new PolygonLayer()
+ .source(landData)
+ .shape('fill')
+ .color('#3CB371')
+ .style({
+ opacity: 0.4,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ const lakeBorderLayer = new PolygonLayer()
+ .source(lakeBorderData)
+ .shape('fill')
+ .color('#ccc')
+ .style({
+ opacity: 0.5,
+ opacityLinear: {
+ enable: true,
+ dir: 'in', // in - out
+ },
+ });
+
+ scene.addLayer(lakeLayer);
+ scene.addLayer(lakeBorderLayer);
+ scene.addLayer(landLayer);
+ });
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const layer = new LineLayer({
+ zIndex: 0,
+ depth: true,
+ })
+ .source(data)
+ .size(1)
+ .shape('line')
+ .color('#1990FF')
+ .animate({
+ interval: 1, // 间隔
+ duration: 2, // 持续时间,延时
+ trailLength: 2, // 流线长度
+ });
+ scene.addLayer(layer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/geometry/billboard.md b/dev-demos/features/geometry/billboard.md
new file mode 100644
index 0000000000..4f57860dd9
--- /dev/null
+++ b/dev-demos/features/geometry/billboard.md
@@ -0,0 +1,2 @@
+### billboard
+
\ No newline at end of file
diff --git a/stories/layerbuild/components/Billboard.tsx b/dev-demos/features/geometry/demos/billboard.tsx
similarity index 77%
rename from stories/layerbuild/components/Billboard.tsx
rename to dev-demos/features/geometry/demos/billboard.tsx
index a39f885ccb..5bafcb4d28 100644
--- a/stories/layerbuild/components/Billboard.tsx
+++ b/dev-demos/features/geometry/demos/billboard.tsx
@@ -1,12 +1,11 @@
-// @ts-nocheck
// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { GeometryLayer } from '@antv/l7-layers';
+import { Scene, GeometryLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -60,20 +59,14 @@ export default class Demo extends React.Component {
img.src =
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*zMw0T6gEIZYAAAAAAAAAAAAAARQnAQ';
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/geometry/sprite.tsx b/dev-demos/features/geometry/demos/sprite.tsx
similarity index 100%
rename from dev-demos/features/geometry/sprite.tsx
rename to dev-demos/features/geometry/demos/sprite.tsx
diff --git a/dev-demos/features/geometry/sprite.md b/dev-demos/features/geometry/sprite.md
index 7167bda454..879e3a556e 100644
--- a/dev-demos/features/geometry/sprite.md
+++ b/dev-demos/features/geometry/sprite.md
@@ -1,2 +1,2 @@
### sprite
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dev-demos/features/heatmap/heatmap.tsx b/dev-demos/features/heatmap/demos/heatmap.tsx
similarity index 100%
rename from dev-demos/features/heatmap/heatmap.tsx
rename to dev-demos/features/heatmap/demos/heatmap.tsx
diff --git a/stories/layerbuild/components/Heatmap3d.tsx b/dev-demos/features/heatmap/demos/heatmap3d.tsx
similarity index 70%
rename from stories/layerbuild/components/Heatmap3d.tsx
rename to dev-demos/features/heatmap/demos/heatmap3d.tsx
index 5e315cf5bf..ce71020c8c 100644
--- a/stories/layerbuild/components/Heatmap3d.tsx
+++ b/dev-demos/features/heatmap/demos/heatmap3d.tsx
@@ -1,12 +1,11 @@
-// @ts-nocheck
// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { HeatmapLayer } from '@antv/l7-layers';
+import { Scene, HeatmapLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -45,20 +44,14 @@ export default class Demo extends React.Component {
scene.addLayer(layer);
});
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/heatmap/heatmap.md b/dev-demos/features/heatmap/heatmap.md
index ed169c7b73..642df4ceb8 100644
--- a/dev-demos/features/heatmap/heatmap.md
+++ b/dev-demos/features/heatmap/heatmap.md
@@ -1,2 +1,2 @@
### Heatmap
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dev-demos/features/heatmap/heatmap3d.md b/dev-demos/features/heatmap/heatmap3d.md
new file mode 100644
index 0000000000..954578e597
--- /dev/null
+++ b/dev-demos/features/heatmap/heatmap3d.md
@@ -0,0 +1,2 @@
+### Heatmap - 3D
+
\ No newline at end of file
diff --git a/dev-demos/features/imageLayer/image.md b/dev-demos/features/imageLayer/image.md
new file mode 100644
index 0000000000..4c2b589044
--- /dev/null
+++ b/dev-demos/features/imageLayer/image.md
@@ -0,0 +1,2 @@
+### Image Layer
+
\ No newline at end of file
diff --git a/dev-demos/features/point/image.tsx b/dev-demos/features/imageLayer/image.tsx
similarity index 100%
rename from dev-demos/features/point/image.tsx
rename to dev-demos/features/imageLayer/image.tsx
diff --git a/dev-demos/features/imageLayer/raster.md b/dev-demos/features/imageLayer/raster.md
new file mode 100644
index 0000000000..5806fc4cde
--- /dev/null
+++ b/dev-demos/features/imageLayer/raster.md
@@ -0,0 +1,2 @@
+### Image Layer - raster
+
\ No newline at end of file
diff --git a/dev-demos/features/imageLayer/raster.tsx b/dev-demos/features/imageLayer/raster.tsx
new file mode 100644
index 0000000000..045b5b3e28
--- /dev/null
+++ b/dev-demos/features/imageLayer/raster.tsx
@@ -0,0 +1,88 @@
+// @ts-ignore
+import { RasterLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import * as GeoTIFF from 'geotiff';
+
+async function getTiffData() {
+ const response = await fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
+ );
+ const arrayBuffer = await response.arrayBuffer();
+ const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
+ const image = await tiff.getImage();
+ const width = image.getWidth();
+ const height = image.getHeight();
+ const values = await image.readRasters();
+ return {
+ data: values[0],
+ width,
+ height,
+ min: 0,
+ max: 8000,
+ };
+}
+
+async function addLayer() {
+ const tiffdata = await getTiffData();
+
+ const layer = new RasterLayer({});
+ layer
+ .source(tiffdata.data, {
+ parser: {
+ type: 'raster',
+ width: tiffdata.width,
+ height: tiffdata.height,
+ min: 0,
+ max: 80,
+ extent: [73.482190241, 3.82501784112, 135.106618732, 57.6300459963],
+ },
+ })
+ .style({
+ heightRatio: 100,
+ opacity: 0.8,
+ domain: [0, 2000],
+ rampColors: {
+ colors: [
+ '#FF4818',
+ '#F7B74A',
+ '#FFF598',
+ '#91EABC',
+ '#2EA9A1',
+ '#206C7C',
+ ].reverse(),
+ positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
+ },
+ });
+ return layer;
+}
+
+export default () => {
+ useEffect(() => {
+ (async () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [121.268, 30.3628],
+ zoom: 3,
+ }),
+ });
+
+ const layer = await addLayer();
+
+ scene.on('loaded', () => {
+ scene.addLayer(layer);
+ });
+ })();
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/point/greatcircleline.tsx b/dev-demos/features/line/demos/greatcircleline.tsx
similarity index 99%
rename from dev-demos/features/point/greatcircleline.tsx
rename to dev-demos/features/line/demos/greatcircleline.tsx
index 867d029aac..cd17d3aaef 100644
--- a/dev-demos/features/point/greatcircleline.tsx
+++ b/dev-demos/features/line/demos/greatcircleline.tsx
@@ -1,4 +1,3 @@
-// @ts-ignore
import {
LineLayer,
Scene,
@@ -6,6 +5,7 @@ import {
lineAtOffset,
lineAtOffsetAsyc,
PointLayer,
+ // @ts-ignore
} from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
diff --git a/dev-demos/features/line/line.tsx b/dev-demos/features/line/demos/line.tsx
similarity index 99%
rename from dev-demos/features/line/line.tsx
rename to dev-demos/features/line/demos/line.tsx
index d335acfdd6..fd5f6322b2 100644
--- a/dev-demos/features/line/line.tsx
+++ b/dev-demos/features/line/demos/line.tsx
@@ -6,6 +6,7 @@ import {
lineAtOffset,
lineAtOffsetAsyc,
PointLayer,
+ // @ts-ignore
} from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
@@ -18,7 +19,6 @@ export default () => {
map: new GaodeMap({
center: [105, 32],
zoom: 4,
- // pitch: 60
}),
});
diff --git a/stories/Layers/components/lineAnimate.tsx b/dev-demos/features/line/demos/lineAnimate.tsx
similarity index 65%
rename from stories/Layers/components/lineAnimate.tsx
rename to dev-demos/features/line/demos/lineAnimate.tsx
index 178fb8fbb3..fede344c49 100644
--- a/stories/Layers/components/lineAnimate.tsx
+++ b/dev-demos/features/line/demos/lineAnimate.tsx
@@ -1,22 +1,26 @@
-import { LineLayer, Scene } from '@antv/l7';
-import { Mapbox } from '@antv/l7-maps';
-import * as React from 'react';
-
-export default class LineDemo extends React.Component {
+// @ts-ignore
+import {
+ LineLayer,
+ Scene,
+ Source,
+ lineAtOffset,
+ lineAtOffsetAsyc,
+ PointLayer,
// @ts-ignore
- private scene: Scene;
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ // @ts-ignore
+ useEffect(async () => {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/49a796db-944b-4c35-aa97-1015f0a407f1.json',
);
const scene = new Scene({
id: 'map',
- map: new Mapbox({
+ map: new GaodeMap({
center: [110.19382669582967, 40.258134],
pitch: 0,
zoom: 3,
@@ -53,21 +57,14 @@ export default class LineDemo extends React.Component {
.render();
lineLayer.fitBounds();
scene.addLayer(lineLayer);
- this.scene = scene;
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/Map/components/amap2demo_arcLine3d.tsx b/dev-demos/features/line/demos/lineArc3d.tsx
similarity index 84%
rename from stories/Map/components/amap2demo_arcLine3d.tsx
rename to dev-demos/features/line/demos/lineArc3d.tsx
index 8d483b7aee..43ff8dc5fe 100644
--- a/stories/Map/components/amap2demo_arcLine3d.tsx
+++ b/dev-demos/features/line/demos/lineArc3d.tsx
@@ -1,16 +1,16 @@
-import { PointLayer, LineLayer, Scene } from '@antv/l7';
-import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
-
-export default class Amap2demo_arcLine3d extends React.Component {
+// @ts-ignore
+import {
+ LineLayer,
+ Scene,
+ PointLayer,
// @ts-ignore
- private scene: Scene;
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -21,7 +21,6 @@ export default class Amap2demo_arcLine3d extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.on('loaded', () => {
scene.addImage(
@@ -123,22 +122,14 @@ export default class Amap2demo_arcLine3d extends React.Component {
scene.addLayer(flyLine);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/line/demos/lineArcPlane.tsx b/dev-demos/features/line/demos/lineArcPlane.tsx
new file mode 100644
index 0000000000..41c494a582
--- /dev/null
+++ b/dev-demos/features/line/demos/lineArcPlane.tsx
@@ -0,0 +1,120 @@
+// @ts-ignore
+import { LineLayer, Scene, PointLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ pitch: 40,
+ center: [ 40, 40.16797 ],
+ style: 'dark',
+ zoom: 2.5
+ })
+ });
+ scene.addImage(
+ 'plane',
+ 'https://gw.alipayobjects.com/zos/bmw-prod/0ca1668e-38c2-4010-8568-b57cb33839b9.svg'
+ );
+ scene.on('loaded', () => {
+ Promise.all([
+ fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/2960e1fc-b543-480f-a65e-d14c229dd777.json'
+ ).then(d => d.json()),
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json'
+ ).then(d => d.text()),
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json'
+ ).then(d => d.text())
+ ]).then(function onLoad([ world, dot, flyline ]) {
+ const dotData = eval(dot);
+ // @ts-ignore
+ const flydata = eval(flyline).map(item => {
+ // @ts-ignore
+ const latlng1 = item.from.split(',').map(e => {
+ return e * 1;
+ });
+ // @ts-ignore
+ const latlng2 = item.to.split(',').map(e => {
+ return e * 1;
+ });
+ return { coord: [ latlng1, latlng2 ] };
+ });
+
+ const worldLine = new LineLayer()
+ .source(world)
+ .color('#41fc9d')
+ .size(0.5)
+ .style({
+ opacity: 0.4
+ });
+ const dotPoint = new PointLayer()
+ .source(dotData, {
+ parser: {
+ type: 'json',
+ x: 'lng',
+ y: 'lat'
+ }
+ })
+ .shape('circle')
+ .color('#ffed11')
+ .animate(true)
+ .size(40);
+ const flyLine = new LineLayer({ blend: 'normal' })
+ .source(flydata, {
+ parser: {
+ type: 'json',
+ coordinates: 'coord'
+ }
+ })
+ .color('#ff6b34')
+ .texture('plane')
+ .shape('arc')
+ .size(15)
+ .animate({
+ duration: 1,
+ interval: 0.2,
+ trailLength: 0.5
+ })
+ .style({
+ textureBlend: 'replace',
+ lineTexture: true, // 开启线的贴图功能
+ iconStep: 10, // 设置贴图纹理的间距
+ });
+
+ const flyLine2 = new LineLayer()
+ .source(flydata, {
+ parser: {
+ type: 'json',
+ coordinates: 'coord'
+ }
+ })
+ .color('#ff6b34')
+ .shape('arc')
+ .size(1)
+ .style({
+ lineType: 'dash',
+ dashArray: [ 5, 5 ],
+ opacity: 0.5
+ });
+ scene.addLayer(worldLine);
+ scene.addLayer(dotPoint);
+ scene.addLayer(flyLine2);
+ scene.addLayer(flyLine);
+ });
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/line/demos/lineArrow.tsx b/dev-demos/features/line/demos/lineArrow.tsx
new file mode 100644
index 0000000000..d29ad9a73f
--- /dev/null
+++ b/dev-demos/features/line/demos/lineArrow.tsx
@@ -0,0 +1,150 @@
+// @ts-ignore
+import { LineLayer, Scene, PointLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [ 120.15, 30.3 ],
+ zoom: 10,
+ style: 'light'
+ })
+ });
+
+ const pointLayer = new PointLayer()
+ .source([{ lng: 120.155, lat: 30.31 }], {
+ parser: {
+ type: 'json',
+ x: 'lng',
+ y: 'lat'
+ }
+ })
+ .shape('circle')
+ .size(6000)
+ .color('#f00')
+ .animate(true)
+ .style({
+ unit: 'meter'
+ });
+ const lineLayer = new LineLayer({})
+ .source({
+ type: 'FeatureCollection',
+ features: [
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'LineString',
+ coordinates: [
+ [
+ 120.1863098144,
+ 30.321915039121
+ ],
+ [
+ 120.3401184082,
+ 30.43446594614
+ ]
+ ]
+ }
+ },
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'LineString',
+ coordinates: [
+ [
+ 120.19660949707033,
+ 30.298796461361665
+ ],
+ [
+ 120.31883239746092,
+ 30.28041626667403
+ ]
+ ]
+ }
+ },
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'LineString',
+ coordinates: [
+ [
+ 120.12245178222656,
+ 30.29523927312319
+ ],
+ [
+ 120.01808166503906,
+ 30.261439550638762
+ ]
+ ]
+ }
+ },
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'LineString',
+ coordinates: [
+ [
+ 120.15609741210938,
+ 30.285159872426014
+ ],
+ [
+ 120.14923095703124,
+ 30.20626765511821
+ ]
+ ]
+ }
+ },
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'LineString',
+ coordinates: [
+ [
+ 120.10940551757812,
+ 30.320136880604423
+ ],
+ [
+ 120.01327514648438,
+ 30.362803774813028
+ ]
+ ]
+ }
+ }
+ ]
+ }
+ )
+ .size(2)
+ .shape('line')
+ .style({
+ arrow: {
+ enable: true,
+ arrowWidth: 4,
+ arrowHeight: 4,
+ tailWidth: 0.4
+ }
+ })
+ .color('#f00');
+ scene.on('loaded', () => {
+ scene.addLayer(pointLayer);
+ scene.addLayer(lineLayer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/line/demos/lineTexture.tsx b/dev-demos/features/line/demos/lineTexture.tsx
new file mode 100644
index 0000000000..5acd6bea20
--- /dev/null
+++ b/dev-demos/features/line/demos/lineTexture.tsx
@@ -0,0 +1,70 @@
+// @ts-ignore
+import {
+ LineLayer,
+ Scene,
+ // @ts-ignore
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [120.15, 30.246],
+ pitch: 0,
+ zoom: 13.5,
+ style: 'dark',
+ pitchEnable: false,
+ rotation: -90,
+ }),
+ });
+
+ scene.addImage(
+ 'arrow',
+ 'https://gw.alipayobjects.com/zos/bmw-prod/ce83fc30-701f-415b-9750-4b146f4b3dd6.svg',
+ );
+
+ scene.on('loaded', () => {
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/40ef2173-df66-4154-a8c0-785e93a5f18e.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const colors = ['#66c2a4', '#2ca25f', '#006d2c'];
+ const layer = new LineLayer({})
+ .source(data)
+ .size(2.5)
+ .shape('line')
+ .texture('arrow')
+ .color('', () => {
+ return colors[Math.floor(Math.random() * colors.length)];
+ })
+ .animate({
+ interval: 1, // 间隔
+ duration: 1, // 持续时间,延时
+ trailLength: 2, // 流线长度
+ })
+ .style({
+ opacity: 0.6,
+ lineTexture: true, // 开启线的贴图功能
+ iconStep: 20, // 设置贴图纹理的间距
+ borderWidth: 0.4, // 默认文 0,最大有效值为 0.5
+ borderColor: '#fff', // 默认为 #ccc
+ });
+ scene.addLayer(layer);
+ });
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/layerbuild/components/LineArc.tsx b/dev-demos/features/line/demos/lineWorker.tsx
similarity index 58%
rename from stories/layerbuild/components/LineArc.tsx
rename to dev-demos/features/line/demos/lineWorker.tsx
index 8f16eaa2cc..4c5f81a65d 100644
--- a/stories/layerbuild/components/LineArc.tsx
+++ b/dev-demos/features/line/demos/lineWorker.tsx
@@ -1,12 +1,15 @@
-// @ts-nocheck
// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { LineLayer } from '@antv/l7-layers';
+import {
+ LineLayer,
+ Scene,
+ // @ts-ignore
+} from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -15,7 +18,7 @@ export default class Demo extends React.Component {
zoom: 2,
}),
});
- const layer = new LineLayer()
+ const layer = new LineLayer({ workerEnabled: true })
.source({
type: 'FeatureCollection',
features: [
@@ -32,26 +35,20 @@ export default class Demo extends React.Component {
},
],
})
- .shape('arc')
+ .shape('line')
.color('#f00')
.size(5);
scene.on('loaded', () => {
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/point/arcline.tsx b/dev-demos/features/line/demos/linearc.tsx
similarity index 99%
rename from dev-demos/features/point/arcline.tsx
rename to dev-demos/features/line/demos/linearc.tsx
index e88e48cd41..a9b4d487f3 100644
--- a/dev-demos/features/point/arcline.tsx
+++ b/dev-demos/features/line/demos/linearc.tsx
@@ -6,6 +6,7 @@ import {
lineAtOffset,
lineAtOffsetAsyc,
PointLayer,
+ // @ts-ignore
} from '@antv/l7';
// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
diff --git a/dev-demos/features/line/linearline.tsx b/dev-demos/features/line/demos/linearline.tsx
similarity index 100%
rename from dev-demos/features/line/linearline.tsx
rename to dev-demos/features/line/demos/linearline.tsx
diff --git a/dev-demos/features/line/lineblur.tsx b/dev-demos/features/line/demos/lineblur.tsx
similarity index 97%
rename from dev-demos/features/line/lineblur.tsx
rename to dev-demos/features/line/demos/lineblur.tsx
index 16d309d1c1..205242339a 100644
--- a/dev-demos/features/line/lineblur.tsx
+++ b/dev-demos/features/line/demos/lineblur.tsx
@@ -1,4 +1,6 @@
+// @ts-ignore
import { LineLayer, Scene } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
import React, { useEffect } from 'react';
diff --git a/stories/Map/components/amap2demo_lineDash.tsx b/dev-demos/features/line/demos/linedash.tsx
similarity index 58%
rename from stories/Map/components/amap2demo_lineDash.tsx
rename to dev-demos/features/line/demos/linedash.tsx
index bb8e681620..7bcaaf1396 100644
--- a/stories/Map/components/amap2demo_lineDash.tsx
+++ b/dev-demos/features/line/demos/linedash.tsx
@@ -1,28 +1,19 @@
+// @ts-ignore
import { LineLayer, Scene } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Amap2demo_lineDash extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [116.3956, 39.9392],
- pitch: 0,
zoom: 10,
- rotation: 0,
style: 'amap://styles/wine',
- // viewMode: '2D',
}),
});
- this.scene = scene;
scene.on('loaded', () => {
fetch(
@@ -43,22 +34,14 @@ export default class Amap2demo_lineDash extends React.Component {
scene.addLayer(layer);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/layerbuild/components/LineHalf.tsx b/dev-demos/features/line/demos/linehalf.tsx
similarity index 64%
rename from stories/layerbuild/components/LineHalf.tsx
rename to dev-demos/features/line/demos/linehalf.tsx
index 011523b288..52c66ed7c8 100644
--- a/stories/layerbuild/components/LineHalf.tsx
+++ b/dev-demos/features/line/demos/linehalf.tsx
@@ -1,12 +1,11 @@
-// @ts-nocheck
// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { LineLayer } from '@antv/l7-layers';
+import { LineLayer, Scene } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -36,6 +35,7 @@ export default class Demo extends React.Component {
.color('#f00')
.size(10)
.style({
+ opacity: 0.5,
arrow: {
enable: true,
},
@@ -43,20 +43,14 @@ export default class Demo extends React.Component {
scene.on('loaded', () => {
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/line/demos/lineheight.tsx b/dev-demos/features/line/demos/lineheight.tsx
new file mode 100644
index 0000000000..7f02bc7d96
--- /dev/null
+++ b/dev-demos/features/line/demos/lineheight.tsx
@@ -0,0 +1,61 @@
+import { LineLayer, Scene } from '@antv/l7';
+import { GaodeMap, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new Mapbox({
+ pitch: 40,
+ style: 'light',
+ center: [102.600579, 23.114887],
+ zoom: 14.66,
+ }),
+ });
+
+ scene.on('loaded', () => {
+ fetch('https://gw.alipayobjects.com/os/rmsportal/ZVfOvhVCzwBkISNsuKCc.json')
+ .then((res) => res.json())
+ .then((data) => {
+ const layer = new LineLayer({})
+ .source(data)
+ .size('ELEV', (h) => {
+ return [h % 50 === 0 ? 1.0 : 0.5, (h - 1400) * 20]; // amap
+ })
+ .shape('line')
+ .scale('ELEV', {
+ type: 'quantize',
+ })
+ .style({
+ heightfixed: true,
+ })
+ .color(
+ 'ELEV',
+ [
+ '#E4682F',
+ '#FF8752',
+ '#FFA783',
+ '#FFBEA8',
+ '#FFDCD6',
+ '#EEF3FF',
+ '#C8D7F5',
+ '#A5C1FC',
+ '#7FA7F9',
+ '#5F8AE5',
+ ].reverse(),
+ );
+ scene.addLayer(layer);
+ });
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/Map/components/linewall.tsx b/dev-demos/features/line/demos/linewall.tsx
similarity index 74%
rename from stories/Map/components/linewall.tsx
rename to dev-demos/features/line/demos/linewall.tsx
index 1676158827..595c410a54 100644
--- a/stories/Map/components/linewall.tsx
+++ b/dev-demos/features/line/demos/linewall.tsx
@@ -1,25 +1,17 @@
-import { LineLayer, Scene, flow } from '@antv/l7';
+import { LineLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
-export default class Amap2demo_lineLinear extends React.Component {
- // @ts-ignore
- private scene: Scene;
+import React, { useEffect } from 'react';
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [115, 30.258134],
pitch: 40,
zoom: 6,
- viewMode: '3D',
}),
});
- this.scene = scene;
const geoData = {
type: 'FeatureCollection',
features: [
@@ -77,22 +69,14 @@ export default class Amap2demo_lineLinear extends React.Component {
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/point/simpleline.tsx b/dev-demos/features/line/demos/simpleline.tsx
similarity index 75%
rename from dev-demos/features/point/simpleline.tsx
rename to dev-demos/features/line/demos/simpleline.tsx
index fdbd8cbf12..5fbc5abb30 100644
--- a/dev-demos/features/point/simpleline.tsx
+++ b/dev-demos/features/line/demos/simpleline.tsx
@@ -91,62 +91,6 @@ export default () => {
}),
});
- const testdata = {
- type: 'FeatureCollection',
- features: [
- {
- type: 'Feature',
- geometry: {
- type: 'MultiLineString',
- coordinates: [
- [
- [115.565185546875, 41.31082388091818],
- [115.3948974609375, 41.203456192051306],
- [115.1751708984375, 40.979898069620134],
- [115.0982666015625, 40.90105786688403],
- [114.697265625, 40.701463603604594],
- [114.89501953125, 40.50126945841643],
- [114.9993896484375, 40.50126945841643],
- [115.0982666015625, 40.400947631519614],
- [114.9993896484375, 40.3004760797495],
- [114.697265625, 40.20405042511331],
- [114.697265625, 40.3004760797495],
- [114.3951416015625, 40.20405042511331],
- [114.1973876953125, 40.20405042511331],
- [114.0985107421875, 40.00237193587648],
- [113.9996337890625, 39.90130858574736],
- [113.697509765625, 39.80009595634837],
- [113.2965087890625, 39.90130858574736],
- [113.0987548828125, 39.80009595634837],
- [112.9998779296875, 39.70296052957232],
- [112.69775390625, 39.202462225882385],
- [112.598876953125, 39.202462225882385],
- [112.5, 39.0533181067413],
- [112.3956298828125, 38.90385833966778],
- [112.1978759765625, 38.70265930723801],
- [112.060546875, 38.77121637244272],
- [112.060546875, 40.061256581404734],
- [112.1978759765625, 40.20405042511331],
- [112.060546875, 40.20405042511331],
- [112.060546875, 41.31082388091818],
- [115.565185546875, 41.31082388091818],
- ],
- ],
- },
- properties: {
- ECO_NAME: 'Mongolian-Manchurian grassland',
- BIOME_NAME: 'Temperate Grasslands, Savannas & Shrublands',
- REALM: 'Palearctic',
- NNH: 3,
- NNH_NAME: 'Nature Could Recover',
- COLOR: '#F6FC38',
- COLOR_BIO: '#FEFF73',
- COLOR_NNH: '#F9A91B',
- },
- },
- ],
- };
-
const multipolygon = {
type: 'Feature',
geometry: {
@@ -205,11 +149,6 @@ export default () => {
COLOR_NNH: '#F9A91B',
},
};
- const testdata2 = {
- type: 'FeatureCollection',
- features: [],
- };
- console.log(polygonToLineString((multipolygon as unknown) as MultiPolygon));
const layer = new LineLayer()
// .source({
diff --git a/dev-demos/features/line/line.md b/dev-demos/features/line/line.md
index 3a48cf6c90..a48db4048a 100644
--- a/dev-demos/features/line/line.md
+++ b/dev-demos/features/line/line.md
@@ -1,2 +1,2 @@
### Line
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineAnimate.md b/dev-demos/features/line/lineAnimate.md
new file mode 100644
index 0000000000..2decd3f304
--- /dev/null
+++ b/dev-demos/features/line/lineAnimate.md
@@ -0,0 +1,2 @@
+### Line - animate
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineArc.md b/dev-demos/features/line/lineArc.md
new file mode 100644
index 0000000000..a7b1e40585
--- /dev/null
+++ b/dev-demos/features/line/lineArc.md
@@ -0,0 +1,2 @@
+### Line - arc
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineArc3d.md b/dev-demos/features/line/lineArc3d.md
new file mode 100644
index 0000000000..c7275bddeb
--- /dev/null
+++ b/dev-demos/features/line/lineArc3d.md
@@ -0,0 +1,2 @@
+### Line - arc3d
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineArcPlane.md b/dev-demos/features/line/lineArcPlane.md
new file mode 100644
index 0000000000..be2f92bfd2
--- /dev/null
+++ b/dev-demos/features/line/lineArcPlane.md
@@ -0,0 +1,2 @@
+### Line - arc - plane
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineArrow.md b/dev-demos/features/line/lineArrow.md
new file mode 100644
index 0000000000..1a4f0c4c6d
--- /dev/null
+++ b/dev-demos/features/line/lineArrow.md
@@ -0,0 +1,2 @@
+### Line - arrow
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineGreatcircle.md b/dev-demos/features/line/lineGreatcircle.md
new file mode 100644
index 0000000000..7b700830a9
--- /dev/null
+++ b/dev-demos/features/line/lineGreatcircle.md
@@ -0,0 +1,2 @@
+### Line - greatCircle
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineHalf.md b/dev-demos/features/line/lineHalf.md
new file mode 100644
index 0000000000..5e482576df
--- /dev/null
+++ b/dev-demos/features/line/lineHalf.md
@@ -0,0 +1,2 @@
+### Line - half
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineTexture.md b/dev-demos/features/line/lineTexture.md
new file mode 100644
index 0000000000..1aad27b587
--- /dev/null
+++ b/dev-demos/features/line/lineTexture.md
@@ -0,0 +1,2 @@
+### Line - texture
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineWorker.md b/dev-demos/features/line/lineWorker.md
new file mode 100644
index 0000000000..fdb577023e
--- /dev/null
+++ b/dev-demos/features/line/lineWorker.md
@@ -0,0 +1,2 @@
+### Line - worker
+
\ No newline at end of file
diff --git a/dev-demos/features/line/linearline.md b/dev-demos/features/line/linearline.md
index 71b5a3d981..d8ffed8f8d 100644
--- a/dev-demos/features/line/linearline.md
+++ b/dev-demos/features/line/linearline.md
@@ -1,2 +1,2 @@
-### Linear Line
-
\ No newline at end of file
+### Line - linear
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineblur.md b/dev-demos/features/line/lineblur.md
index 9673470645..1ad3218a8c 100644
--- a/dev-demos/features/line/lineblur.md
+++ b/dev-demos/features/line/lineblur.md
@@ -1,2 +1,2 @@
-### Line Blur
-
\ No newline at end of file
+### Line - blur
+
\ No newline at end of file
diff --git a/dev-demos/features/line/linedash.md b/dev-demos/features/line/linedash.md
new file mode 100644
index 0000000000..eeea7d0b09
--- /dev/null
+++ b/dev-demos/features/line/linedash.md
@@ -0,0 +1,2 @@
+### Line - dash
+
\ No newline at end of file
diff --git a/dev-demos/features/line/lineheight.md b/dev-demos/features/line/lineheight.md
new file mode 100644
index 0000000000..40a02eae36
--- /dev/null
+++ b/dev-demos/features/line/lineheight.md
@@ -0,0 +1,2 @@
+### Line - height
+
\ No newline at end of file
diff --git a/dev-demos/features/line/linewall.md b/dev-demos/features/line/linewall.md
new file mode 100644
index 0000000000..611663edeb
--- /dev/null
+++ b/dev-demos/features/line/linewall.md
@@ -0,0 +1,2 @@
+### Line - wall
+
\ No newline at end of file
diff --git a/dev-demos/features/line/simpleline.md b/dev-demos/features/line/simpleline.md
new file mode 100644
index 0000000000..4cc7850ee5
--- /dev/null
+++ b/dev-demos/features/line/simpleline.md
@@ -0,0 +1,2 @@
+### Line - simple
+
\ No newline at end of file
diff --git a/stories/mask/components/heatmap.tsx b/dev-demos/features/mask/demos/heatmap.tsx
similarity index 76%
rename from stories/mask/components/heatmap.tsx
rename to dev-demos/features/mask/demos/heatmap.tsx
index c03e7a4265..54476ecf41 100644
--- a/stories/mask/components/heatmap.tsx
+++ b/dev-demos/features/mask/demos/heatmap.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- HeatmapLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, HeatmapLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -27,7 +16,6 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -67,7 +55,6 @@ export default class MaskPoints extends React.Component {
)
.then((res) => res.json())
.then((data) => {
- // const heatmapLayer = new HeatmapLayer({ mask: true, maskInside: true })
const heatmapLayer = new HeatmapLayer({
mask: true,
maskInside: false,
@@ -97,22 +84,14 @@ export default class MaskPoints extends React.Component {
scene.addLayer(heatmapLayer);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/heatmapgrid.tsx b/dev-demos/features/mask/demos/heatmapgrid.tsx
similarity index 81%
rename from stories/mask/components/heatmapgrid.tsx
rename to dev-demos/features/mask/demos/heatmapgrid.tsx
index 4d295608ed..9c5fb8fd73 100644
--- a/stories/mask/components/heatmapgrid.tsx
+++ b/dev-demos/features/mask/demos/heatmapgrid.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- HeatmapLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, HeatmapLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -27,7 +16,6 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -117,22 +105,14 @@ export default class MaskPoints extends React.Component {
// scene.addMask(mask2, heatmapLayer.id);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/heatmapgrid3d.tsx b/dev-demos/features/mask/demos/heatmapgrid3d.tsx
similarity index 77%
rename from stories/mask/components/heatmapgrid3d.tsx
rename to dev-demos/features/mask/demos/heatmapgrid3d.tsx
index 290abcabc0..cc93f89d50 100644
--- a/stories/mask/components/heatmapgrid3d.tsx
+++ b/dev-demos/features/mask/demos/heatmapgrid3d.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- HeatmapLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, HeatmapLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -28,7 +17,6 @@ export default class MaskPoints extends React.Component {
zoom: 12.47985,
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -62,7 +50,6 @@ export default class MaskPoints extends React.Component {
)
.then((res) => res.json())
.then((data) => {
- // const layer = new HeatmapLayer({ mask: true })
const layer = new HeatmapLayer({
mask: true,
maskInside: false,
@@ -105,22 +92,14 @@ export default class MaskPoints extends React.Component {
scene.addLayer(layer);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/hexgon.tsx b/dev-demos/features/mask/demos/hexgon.tsx
similarity index 79%
rename from stories/mask/components/hexgon.tsx
rename to dev-demos/features/mask/demos/hexgon.tsx
index 95f25b252c..ea4d5f7e25 100644
--- a/stories/mask/components/hexgon.tsx
+++ b/dev-demos/features/mask/demos/hexgon.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- HeatmapLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, HeatmapLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -27,7 +16,6 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -66,7 +54,6 @@ export default class MaskPoints extends React.Component {
)
.then((res) => res.text())
.then((data) => {
- // const layer = new HeatmapLayer({ mask: true })
const layer = new HeatmapLayer({
mask: true,
maskInside: false,
@@ -115,22 +102,14 @@ export default class MaskPoints extends React.Component {
scene.addLayer(layer);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/image.tsx b/dev-demos/features/mask/demos/image.tsx
similarity index 68%
rename from stories/mask/components/image.tsx
rename to dev-demos/features/mask/demos/image.tsx
index 07d27d7c4d..e900bd79a0 100644
--- a/stories/mask/components/image.tsx
+++ b/dev-demos/features/mask/demos/image.tsx
@@ -1,23 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- PolygonLayer,
- PointLayer,
- ImageLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, ImageLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -28,7 +16,6 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -64,7 +51,6 @@ export default class MaskPoints extends React.Component {
};
scene.on('loaded', () => {
- // let points = new PointLayer({ zIndex: 2, mask: true, maskInside: false }) // maskInside: true
const layer = new ImageLayer({
mask: true,
maskInside: false,
@@ -73,7 +59,7 @@ export default class MaskPoints extends React.Component {
maskColor: '#f00',
});
layer.source(
- 'https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',
+ 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*4UApTKmeiy4AAAAAAAAAAAAAARQnAQ',
{
parser: {
type: 'image',
@@ -88,22 +74,14 @@ export default class MaskPoints extends React.Component {
);
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/raster.tsx b/dev-demos/features/mask/demos/raster.tsx
similarity index 55%
rename from stories/mask/components/raster.tsx
rename to dev-demos/features/mask/demos/raster.tsx
index a41954b0f6..b3fc9c9d80 100644
--- a/stories/mask/components/raster.tsx
+++ b/dev-demos/features/mask/demos/raster.tsx
@@ -1,38 +1,34 @@
-import { LineLayer, Scene, MaskLayer, RasterLayer } from '@antv/l7';
-import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
// @ts-ignore
+import { Scene, RasterLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
import * as GeoTIFF from 'geotiff';
-export default class MaskPoints extends React.Component {
+async function getTiffData() {
+ const response = await fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
+ // 'https://gw.alipayobjects.com/zos/antvdemo/assets/2019_clip/ndvi_201905.tiff',
+ );
+ const arrayBuffer = await response.arrayBuffer();
+ const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
+ const image = await tiff.getImage();
+ const width = image.getWidth();
+ const height = image.getHeight();
+ const values = await image.readRasters();
+ return {
+ data: values[0],
+ width,
+ height,
+ min: 0,
+ max: 8000,
+ };
+}
+
+export default () => {
// @ts-ignore
- private scene: Scene;
-
- private async getTiffData() {
- const response = await fetch(
- 'https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat',
- // 'https://gw.alipayobjects.com/zos/antvdemo/assets/2019_clip/ndvi_201905.tiff',
- );
- const arrayBuffer = await response.arrayBuffer();
- const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer);
- const image = await tiff.getImage();
- const width = image.getWidth();
- const height = image.getHeight();
- const values = await image.readRasters();
- return {
- data: values[0],
- width,
- height,
- min: 0,
- max: 8000,
- };
- }
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+ useEffect( async () => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -43,13 +39,12 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
);
- const tiffdata = await this.getTiffData();
+ const tiffdata = await getTiffData();
fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
@@ -57,7 +52,6 @@ export default class MaskPoints extends React.Component {
.then((res) => res.json())
.then((maskData) => {
const layer = new RasterLayer({ mask: true, maskfence: maskData });
- // const layer = new RasterLayer({ mask: true, maskInside: false });
const mindata = -0;
const maxdata = 8000;
layer
@@ -91,22 +85,14 @@ export default class MaskPoints extends React.Component {
});
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/singleMask.tsx b/dev-demos/features/mask/demos/singleMask.tsx
similarity index 74%
rename from stories/mask/components/singleMask.tsx
rename to dev-demos/features/mask/demos/singleMask.tsx
index 01d9da91de..517ff01106 100644
--- a/stories/mask/components/singleMask.tsx
+++ b/dev-demos/features/mask/demos/singleMask.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- PolygonLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, PointLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -27,7 +16,6 @@ export default class MaskPoints extends React.Component {
style: 'dark',
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -55,7 +43,6 @@ export default class MaskPoints extends React.Component {
};
scene.on('loaded', () => {
- // let points = new PointLayer({ zIndex: 2, mask: true, maskInside: false }) // maskInside: true
let point1 = new PointLayer({
zIndex: 1,
mask: true,
@@ -85,7 +72,6 @@ export default class MaskPoints extends React.Component {
})
.active(true);
- // let point2 = new PointLayer({ zIndex: 3, mask: false, maskInside: true })
let point2 = new PointLayer({
zIndex: 3,
mask: true,
@@ -131,22 +117,14 @@ export default class MaskPoints extends React.Component {
scene.render();
}, 2000);
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/mask/components/text.tsx b/dev-demos/features/mask/demos/text.tsx
similarity index 77%
rename from stories/mask/components/text.tsx
rename to dev-demos/features/mask/demos/text.tsx
index 6933fc6303..072c7af111 100644
--- a/stories/mask/components/text.tsx
+++ b/dev-demos/features/mask/demos/text.tsx
@@ -1,22 +1,11 @@
-import {
- LineLayer,
- Scene,
- MaskLayer,
- PolygonLayer,
- PointLayer,
-} from '@antv/l7';
+// @ts-ignore
+import { Scene, PointLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class MaskPoints extends React.Component {
- // @ts-ignore
- private scene: Scene;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
stencil: true,
@@ -26,7 +15,6 @@ export default class MaskPoints extends React.Component {
zoom: 4,
}),
});
- this.scene = scene;
scene.addImage(
'00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg',
@@ -65,7 +53,6 @@ export default class MaskPoints extends React.Component {
)
.then((res) => res.json())
.then((data) => {
- // const pointLayer = new PointLayer({ mask: true })
const pointLayer = new PointLayer({
mask: true,
maskInside: false,
@@ -95,22 +82,14 @@ export default class MaskPoints extends React.Component {
scene.addLayer(pointLayer);
});
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/mask/demos/wind.tsx b/dev-demos/features/mask/demos/wind.tsx
new file mode 100644
index 0000000000..4e993abedc
--- /dev/null
+++ b/dev-demos/features/mask/demos/wind.tsx
@@ -0,0 +1,95 @@
+// @ts-ignore
+import { Scene, WindLayer } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ stencil: true,
+ map: new GaodeMap({
+ center: [105.732421875, 32.24997445586331],
+ pitch: 0,
+ style: 'dark',
+ zoom: 2,
+ }),
+ });
+
+ const maskData = {
+ type: 'FeatureCollection',
+ features: [
+ {
+ type: 'Feature',
+ geometry: {
+ type: 'MultiPolygon',
+ coordinates: [
+ [
+ [
+ [125.15625000000001, 8.407168163601076],
+ [116.54296874999999, -21.289374355860424],
+ [156.26953125, -20.632784250388013],
+ [150.29296875, 2.1088986592431382],
+ ],
+ ],
+ [
+ [
+ [78.57421875, 46.92025531537451],
+ [51.67968749999999, 37.020098201368114],
+ [87.890625, 28.76765910569123],
+ ],
+ ],
+ ],
+ },
+ },
+ ],
+ };
+
+ scene.on('loaded', () => {
+ const layer = new WindLayer({
+ mask: true,
+ maskInside: false,
+ maskfence: maskData,
+ });
+ layer
+ .source(
+ 'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*wcU8S5xMEDYAAAAAAAAAAAAAARQnAQ',
+ {
+ parser: {
+ type: 'image',
+ extent: [-180, -85, 180, 85],
+ },
+ },
+ )
+ .animate(true)
+ .style({
+ uMin: -21.32,
+ uMax: 26.8,
+ vMin: -21.57,
+ vMax: 21.42,
+ numParticles: 35535,
+ fadeOpacity: 0.996,
+ sizeScale: 1.2,
+ rampColors: {
+ 0.0: '#c6dbef',
+ 0.1: '#9ecae1',
+ 0.2: '#6baed6',
+ 0.3: '#4292c6',
+ 0.4: '#2171b5',
+ 0.5: '#084594',
+ },
+ });
+ scene.addLayer(layer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/mask/heatmap.md b/dev-demos/features/mask/heatmap.md
new file mode 100644
index 0000000000..6df8dc5081
--- /dev/null
+++ b/dev-demos/features/mask/heatmap.md
@@ -0,0 +1,2 @@
+### heatmap
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/heatmapgrid.md b/dev-demos/features/mask/heatmapgrid.md
new file mode 100644
index 0000000000..cbef235e6f
--- /dev/null
+++ b/dev-demos/features/mask/heatmapgrid.md
@@ -0,0 +1,2 @@
+### heatmapgrid
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/heatmapgrid3d.md b/dev-demos/features/mask/heatmapgrid3d.md
new file mode 100644
index 0000000000..100facc3f6
--- /dev/null
+++ b/dev-demos/features/mask/heatmapgrid3d.md
@@ -0,0 +1,2 @@
+### heatmapgrid3d
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/hexgon.md b/dev-demos/features/mask/hexgon.md
new file mode 100644
index 0000000000..9fc93e16c2
--- /dev/null
+++ b/dev-demos/features/mask/hexgon.md
@@ -0,0 +1,2 @@
+### hexgon
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/image.md b/dev-demos/features/mask/image.md
new file mode 100644
index 0000000000..12e1691101
--- /dev/null
+++ b/dev-demos/features/mask/image.md
@@ -0,0 +1,2 @@
+### image
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/raster.md b/dev-demos/features/mask/raster.md
new file mode 100644
index 0000000000..b0225f5cc3
--- /dev/null
+++ b/dev-demos/features/mask/raster.md
@@ -0,0 +1,2 @@
+### raster
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/singleMask.md b/dev-demos/features/mask/singleMask.md
new file mode 100644
index 0000000000..1e3c59e880
--- /dev/null
+++ b/dev-demos/features/mask/singleMask.md
@@ -0,0 +1,2 @@
+### singleMask
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/text.md b/dev-demos/features/mask/text.md
new file mode 100644
index 0000000000..82c33124c5
--- /dev/null
+++ b/dev-demos/features/mask/text.md
@@ -0,0 +1,2 @@
+### text
+
\ No newline at end of file
diff --git a/dev-demos/features/mask/wind.md b/dev-demos/features/mask/wind.md
new file mode 100644
index 0000000000..be482f6762
--- /dev/null
+++ b/dev-demos/features/mask/wind.md
@@ -0,0 +1,2 @@
+### wind
+
\ No newline at end of file
diff --git a/dev-demos/features/point/arcline.md b/dev-demos/features/point/arcline.md
deleted file mode 100644
index 6390be01cb..0000000000
--- a/dev-demos/features/point/arcline.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Arc Line
-
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/column.tsx b/dev-demos/features/point/demos/column.tsx
new file mode 100644
index 0000000000..58a34192af
--- /dev/null
+++ b/dev-demos/features/point/demos/column.tsx
@@ -0,0 +1,60 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ pitch: 66.02383,
+ style: 'dark',
+ center: [121.400257, 31.25287],
+ zoom: 14.55,
+ rotation: 134.9507,
+ }),
+ });
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const pointLayer = new PointLayer({})
+ .source(data, {
+ parser: {
+ type: 'json',
+ x: 'longitude',
+ y: 'latitude',
+ },
+ })
+ .shape('name', [
+ 'cylinder',
+ 'triangleColumn',
+ 'hexagonColumn',
+ 'squareColumn',
+ ])
+ .size('unit_price', (h) => {
+ return [6, 6, 100];
+ })
+ .color('name', ['#739DFF', '#61FCBF', '#FFDE74', '#FF896F'])
+ .style({
+ opacity: 1.0,
+ });
+
+ scene.addLayer(pointLayer);
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/cylinder.tsx b/dev-demos/features/point/demos/cylinder.tsx
new file mode 100644
index 0000000000..0224f2c72e
--- /dev/null
+++ b/dev-demos/features/point/demos/cylinder.tsx
@@ -0,0 +1,65 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [121.107846, 30.267069],
+ pitch: 35.210526315789465,
+ style: 'dark',
+ zoom: 8,
+ animateEnable: false,
+ }),
+ });
+
+ scene.on('loaded', () => {
+ fetch(
+ 'https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const pointLayer = new PointLayer({ depth: false })
+ .source(data.list, {
+ parser: {
+ type: 'json',
+ x: 'j',
+ y: 'w',
+ },
+ })
+ .shape('cylinder') // cylinder triangleColumn hexagonColumn squareColumn
+ .size('t', function(level) {
+ return [1, 1, level * 2 + 20];
+ })
+ .active(true)
+ .color('#0ff')
+ .style({
+ // opacity: 0.8,
+ opacityLinear: {
+ enable: true, // true - false
+ dir: 'up', // up - down
+ },
+ lightEnable: false,
+ // sourceColor: '#f00',
+ // targetColor: "#0f0"
+ });
+ scene.addLayer(pointLayer);
+ });
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/iconfont.tsx b/dev-demos/features/point/demos/iconfont.tsx
new file mode 100644
index 0000000000..bfd725a45f
--- /dev/null
+++ b/dev-demos/features/point/demos/iconfont.tsx
@@ -0,0 +1,74 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [ 110, 36 ],
+ style: 'light',
+ zoom: 3
+ })
+ });
+
+ const fontFamily = 'iconfont';
+ // 指定 iconfont 字体文件
+ const fontPath =
+ '//at.alicdn.com/t/font_2534097_fcae9o2mxbv.woff2?t=1622200439140';
+ // 全局添加资源
+ scene.addFontFace(fontFamily, fontPath);
+ // 全局添加 iconfont 字段的映射;
+ scene.addIconFont('icon1', '');
+
+ scene.on('loaded', () => {
+ const imageLayer = new PointLayer()
+ .source(
+ [
+ {
+ j: 118.234433,
+ w: 35.007936,
+ icon: 'icon1',
+ value: 10,
+ name: 'AA',
+ type: 'dibiaoshui',
+ },
+ ],
+ {
+ parser: {
+ type: 'json',
+ x: 'j',
+ y: 'w',
+ },
+ },
+ )
+ .color('#44ff00')
+ .shape('icon', 'text')
+ .size(30)
+ .style({
+ // textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
+ // textOffset: [ 40, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
+ padding: [0, 0], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
+ stroke: '#ffffff', // 描边颜色
+ fontFamily,
+ iconfont: true,
+ textAllowOverlap: true,
+ });
+ scene.addLayer(imageLayer);
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/icons.tsx b/dev-demos/features/point/demos/icons.tsx
new file mode 100644
index 0000000000..2bc53c3127
--- /dev/null
+++ b/dev-demos/features/point/demos/icons.tsx
@@ -0,0 +1,73 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ // @ts-ignore
+ useEffect( async () => {
+ const response = await fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json',
+ );
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [121.4, 31.258134],
+ zoom: 12,
+ pitch: 0,
+ style: 'normal',
+ }),
+ });
+ scene.addImage(
+ '00',
+ 'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*g8cUQ7pPT9YAAAAAAAAAAAAAARQnAQ',
+ );
+ scene.addImage(
+ '01',
+ 'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*LTcXTLBM7kYAAAAAAAAAAAAAARQnAQ',
+ );
+ scene.addImage(
+ '02',
+ 'https://gw.alipayobjects.com/zos/bmw-prod/904d047a-16a5-461b-a921-98fa537fc04a.svg',
+ );
+ const data = await response.json();
+ const newData = data.map((item: any) => {
+ item.type = ['00', '01', '02'][Math.floor(Math.random() * 3)];
+ return item;
+ });
+ const imageLayer = new PointLayer({
+ blend: 'normal',
+ })
+ .source(newData, {
+ parser: {
+ type: 'json',
+ x: 'longitude',
+ y: 'latitude',
+ },
+ })
+ .shape('type', (v: any) => {
+ return v;
+ })
+ .active(false)
+ .size(20);
+ scene.addLayer(imageLayer);
+ imageLayer.on('mousedown', (e) => {
+ console.log('mousedown', e);
+ });
+ imageLayer.on('click', (e) => {
+ console.log('click', e);
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/normal.tsx b/dev-demos/features/point/demos/normal.tsx
new file mode 100644
index 0000000000..7808e44a2b
--- /dev/null
+++ b/dev-demos/features/point/demos/normal.tsx
@@ -0,0 +1,51 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ style: 'dark',
+ center: [ 121.417463, 31.215175 ],
+ pitch: 0,
+ zoom: 11
+ })
+ });
+ scene.on('loaded', () => {
+ fetch('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt')
+ .then(res => res.text())
+ .then(data => {
+ const pointLayer = new PointLayer({})
+ .source(data, {
+ parser: {
+ type: 'csv',
+ y: 'lat',
+ x: 'lng'
+ }
+ })
+ .size(0.5)
+ .color('#080298')
+ .style({
+ opacity: 1
+ });
+
+ scene.addLayer(pointLayer);
+ });
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/radar.tsx b/dev-demos/features/point/demos/radar.tsx
new file mode 100644
index 0000000000..a1bb2693b3
--- /dev/null
+++ b/dev-demos/features/point/demos/radar.tsx
@@ -0,0 +1,56 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [110.19382669582967, 30.258134],
+ pitch: 0,
+ zoom: 2,
+ }),
+ });
+
+ const layer = new PointLayer()
+ .source(
+ [
+ {
+ lng: 120,
+ lat: 30,
+ t: 'text1',
+ },
+ ],
+ {
+ parser: {
+ type: 'json',
+ x: 'lng',
+ y: 'lat',
+ },
+ },
+ )
+ .size(25)
+ .color('#f00')
+ .shape('radar')
+ .animate(true)
+ .active(true);
+
+ scene.on('loaded', () => {
+ scene.addLayer(layer);
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/simple.tsx b/dev-demos/features/point/demos/simple.tsx
new file mode 100644
index 0000000000..fc307557ad
--- /dev/null
+++ b/dev-demos/features/point/demos/simple.tsx
@@ -0,0 +1,52 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [ 110, 36 ],
+ style: 'light',
+ zoom: 3
+ })
+ });
+ scene.on('loaded', () => {
+ fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
+ .then(res => res.json())
+ .then(data => {
+ const pointLayer = new PointLayer({ blend: 'additive' })
+ .source(data.list, {
+ parser: {
+ type: 'json',
+ x: 'j',
+ y: 'w'
+ }
+ })
+ .shape('simple')
+ .size(6)
+ .color('#ff0')
+ .style({
+ opacity: 0.3
+ });
+
+ scene.addLayer(pointLayer);
+ });
+
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/demos/text.tsx b/dev-demos/features/point/demos/text.tsx
new file mode 100644
index 0000000000..61f9b2e081
--- /dev/null
+++ b/dev-demos/features/point/demos/text.tsx
@@ -0,0 +1,59 @@
+// @ts-ignore
+import { PointLayer, Scene } from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect( () => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [ 110, 36 ],
+ style: 'light',
+ zoom: 3
+ })
+ });
+ scene.on('loaded', () => {
+ fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
+ .then(res => res.json())
+ .then(data => {
+ const pointLayer = new PointLayer({})
+ .source(data.list, {
+ parser: {
+ type: 'json',
+ x: 'j',
+ y: 'w'
+ }
+ })
+ .shape('m', 'text')
+ .size(12)
+ .color('w', [ '#0e0030', '#0e0030', '#0e0030' ])
+ .style({
+ // textAllowOverlap: true,
+ textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
+ textOffset: [ 0, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
+ spacing: 2, // 字符间距
+ padding: [ 1, 1 ], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
+ stroke: '#ffffff', // 描边颜色
+ strokeWidth: 0.3, // 描边宽度
+ strokeOpacity: 1.0
+ });
+
+ scene.addLayer(pointLayer);
+ });
+
+ });
+
+ }, []);
+ return (
+
+ );
+ };
+
\ No newline at end of file
diff --git a/dev-demos/features/point/greatcircleline.md b/dev-demos/features/point/greatcircleline.md
deleted file mode 100644
index 73ea935b52..0000000000
--- a/dev-demos/features/point/greatcircleline.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### GreatCircle Line
-
\ No newline at end of file
diff --git a/dev-demos/features/point/image.md b/dev-demos/features/point/image.md
deleted file mode 100644
index d7c3ff870c..0000000000
--- a/dev-demos/features/point/image.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### 图片图层
-
\ No newline at end of file
diff --git a/dev-demos/features/point/pointCircle.md b/dev-demos/features/point/pointCircle.md
index aeb36fc878..09647a01ca 100644
--- a/dev-demos/features/point/pointCircle.md
+++ b/dev-demos/features/point/pointCircle.md
@@ -1,4 +1,4 @@
-### point circle
+### point - circle
```tsx
import { PointLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
diff --git a/dev-demos/features/point/pointColumn.md b/dev-demos/features/point/pointColumn.md
new file mode 100644
index 0000000000..631e8ae93f
--- /dev/null
+++ b/dev-demos/features/point/pointColumn.md
@@ -0,0 +1,2 @@
+### point - column
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointCylinder.md b/dev-demos/features/point/pointCylinder.md
new file mode 100644
index 0000000000..6f4510921a
--- /dev/null
+++ b/dev-demos/features/point/pointCylinder.md
@@ -0,0 +1,2 @@
+### point - cylinder
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointFillImage.md b/dev-demos/features/point/pointFillImage.md
index 7da50282b3..1dace4cbd8 100644
--- a/dev-demos/features/point/pointFillImage.md
+++ b/dev-demos/features/point/pointFillImage.md
@@ -1,4 +1,4 @@
-### point fillImage
+### point - fillImage
```tsx
import { PointLayer, Scene } from '@antv/l7';
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
diff --git a/dev-demos/features/point/pointIconfont.md b/dev-demos/features/point/pointIconfont.md
new file mode 100644
index 0000000000..e6061f5958
--- /dev/null
+++ b/dev-demos/features/point/pointIconfont.md
@@ -0,0 +1,4 @@
+### Point - text - iconfont
+
+#### iconfont
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointIcons.md b/dev-demos/features/point/pointIcons.md
new file mode 100644
index 0000000000..ae5e5ee5a7
--- /dev/null
+++ b/dev-demos/features/point/pointIcons.md
@@ -0,0 +1,2 @@
+### point - icons
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointImage.md b/dev-demos/features/point/pointImage.md
index ab1729621c..71df2208f8 100644
--- a/dev-demos/features/point/pointImage.md
+++ b/dev-demos/features/point/pointImage.md
@@ -1,4 +1,4 @@
-### point image
+### point - image
```tsx
import { PointLayer, Scene } from '@antv/l7';
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
@@ -6,12 +6,10 @@ import React, { useEffect } from 'react';
export default () => {
useEffect(() => {
-
const scene = new Scene({
id: 'point_fillImage',
map: new Mapbox({
style: 'light',
-
center: [120, 30],
pitch: 60,
zoom: 14
diff --git a/dev-demos/features/point/pointNormal.md b/dev-demos/features/point/pointNormal.md
new file mode 100644
index 0000000000..2a4518ed82
--- /dev/null
+++ b/dev-demos/features/point/pointNormal.md
@@ -0,0 +1,2 @@
+### Point - normal
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointRadar.md b/dev-demos/features/point/pointRadar.md
new file mode 100644
index 0000000000..327617ffe9
--- /dev/null
+++ b/dev-demos/features/point/pointRadar.md
@@ -0,0 +1,2 @@
+### point - radar
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointSimple.md b/dev-demos/features/point/pointSimple.md
new file mode 100644
index 0000000000..4df6bb8f9d
--- /dev/null
+++ b/dev-demos/features/point/pointSimple.md
@@ -0,0 +1,2 @@
+### Point - simple
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointText.md b/dev-demos/features/point/pointText.md
new file mode 100644
index 0000000000..9548a09913
--- /dev/null
+++ b/dev-demos/features/point/pointText.md
@@ -0,0 +1,3 @@
+### Point - text
+#### normal text
+
\ No newline at end of file
diff --git a/dev-demos/features/point/pointWave.md b/dev-demos/features/point/pointWave.md
index 7c40580157..91729d1ac8 100644
--- a/dev-demos/features/point/pointWave.md
+++ b/dev-demos/features/point/pointWave.md
@@ -1,4 +1,4 @@
-### point wave
+### point - wave
```tsx
import { PointLayer, Scene } from '@antv/l7';
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
diff --git a/dev-demos/features/point/simpleline.md b/dev-demos/features/point/simpleline.md
deleted file mode 100644
index f6b78bf749..0000000000
--- a/dev-demos/features/point/simpleline.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Simple Line
-
\ No newline at end of file
diff --git a/stories/Map/components/amap2demo_polygon_extrude.tsx b/dev-demos/features/polygon/demos/extrude.tsx
similarity index 64%
rename from stories/Map/components/amap2demo_polygon_extrude.tsx
rename to dev-demos/features/polygon/demos/extrude.tsx
index aeb22fd7b9..b663890dc1 100644
--- a/stories/Map/components/amap2demo_polygon_extrude.tsx
+++ b/dev-demos/features/polygon/demos/extrude.tsx
@@ -1,35 +1,26 @@
-import { PolygonLayer, Scene, LineLayer, PointLayer } from '@antv/l7';
-import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
-import * as React from 'react';
-export default class Amap2demo_polygon_extrude extends React.Component {
- private gui: dat.GUI;
- private $stats: Node;
+import {
+ Scene,
+ PolygonLayer,
+ PointLayer,
+ LineLayer,
// @ts-ignore
- private scene: Scene;
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
- // const response = await fetch(
- // // 'https://gw.alipayobjects.com/os/basement_prod/f79485d8-d86f-4bb3-856d-537b586be06e.json',
- // // 'https://gw.alipayobjects.com/os/basement_prod/619a6f16-ecb0-4fca-9f9a-b06b67f6f02b.json',
- // 'https://gw.alipayobjects.com/os/bmw-prod/93a55259-328e-4e8b-8dc2-35e05844ed31.json'
- // );
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
- // map: new GaodeMapV2({
- // map: new Mapbox({
style: 'dark',
center: [120, 29.732983],
zoom: 6.2,
pitch: 60,
}),
});
- this.scene = scene;
const wavePoints = new PointLayer({ zIndex: 2 })
.source(
@@ -70,7 +61,6 @@ export default class Amap2demo_polygon_extrude extends React.Component {
scene.on('loaded', () => {
scene.addLayer(wavePoints);
- // @ts-ignore
let lineDown, lineUp, textLayer;
fetch('https://geo.datav.aliyun.com/areas_v3/bound/330000_full.json')
@@ -148,9 +138,6 @@ export default class Amap2demo_polygon_extrude extends React.Component {
.size(150000)
.shape('extrude')
.color('#0DCCFF')
- // .active({
- // color: 'rgb(100,230,255)',
- // })
.style({
heightfixed: true,
pickLight: true,
@@ -176,58 +163,16 @@ export default class Amap2demo_polygon_extrude extends React.Component {
sidesurface: false,
});
scene.addLayer(provincelayerTop);
-
- // provincelayer.on('mousemove', () => {
- // provincelayer.style({
- // raisingHeight: 200000 + 100000,
- // });
- // // @ts-ignore
- // lineDown.style({
- // raisingHeight: 200000 + 100000,
- // });
- // // @ts-ignore
- // lineUp.style({
- // raisingHeight: 200000 + 150000 + 100000,
- // });
- // // @ts-ignore
- // textLayer.style({
- // raisingHeight: 200000 + 150000 + 10000 + 100000,
- // });
- // });
-
- // provincelayer.on('unmousemove', () => {
- // provincelayer.style({
- // raisingHeight: 200000,
- // });
- // // @ts-ignore
- // lineDown.style({
- // raisingHeight: 200000,
- // });
- // // @ts-ignore
- // lineUp.style({
- // raisingHeight: 200000 + 150000,
- // });
- // // @ts-ignore
- // textLayer.style({
- // raisingHeight: 200000 + 150000 + 10000,
- // });
- // });
});
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/polygon/demos/fill.tsx b/dev-demos/features/polygon/demos/fill.tsx
new file mode 100644
index 0000000000..91fa31a102
--- /dev/null
+++ b/dev-demos/features/polygon/demos/fill.tsx
@@ -0,0 +1,67 @@
+
+import {
+ Scene,
+ PolygonLayer,
+ // @ts-ignore
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ pitch: 40,
+ center: [113.8623046875, 30.031055426540206],
+ zoom: 7.5,
+ }),
+ });
+ const data = {
+ type: 'FeatureCollection',
+ features: [
+ {
+ type: 'Feature',
+ properties: {
+ testOpacity: 0.8,
+ },
+ geometry: {
+ type: 'Polygon',
+ coordinates: [
+ [
+ [113.8623046875, 30.031055426540206],
+ [116.3232421875, 30.031055426540206],
+ [116.3232421875, 31.090574094954192],
+ [113.8623046875, 31.090574094954192],
+ [113.8623046875, 30.031055426540206],
+ ],
+ ],
+ },
+ },
+ ],
+ };
+
+
+ const layer = new PolygonLayer({})
+ .source(data)
+ .shape('fill')
+ .color('red')
+ .active(true)
+ .style({
+ });
+
+ scene.on('loaded', () => {
+ scene.addLayer(layer);
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/layerbuild/components/PolygonOcean.tsx b/dev-demos/features/polygon/demos/ocean.tsx
similarity index 65%
rename from stories/layerbuild/components/PolygonOcean.tsx
rename to dev-demos/features/polygon/demos/ocean.tsx
index 3bd8663ea8..c62b4b4905 100644
--- a/stories/layerbuild/components/PolygonOcean.tsx
+++ b/dev-demos/features/polygon/demos/ocean.tsx
@@ -1,12 +1,15 @@
-// @ts-nocheck
-// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { PolygonLayer } from '@antv/l7-layers';
-import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+import {
+ Scene,
+ PolygonLayer,
+ // @ts-ignore
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -46,20 +49,14 @@ export default class Demo extends React.Component {
scene.on('loaded', () => {
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/stories/layerbuild/components/PolygonWater.tsx b/dev-demos/features/polygon/demos/water.tsx
similarity index 59%
rename from stories/layerbuild/components/PolygonWater.tsx
rename to dev-demos/features/polygon/demos/water.tsx
index 8c99702a48..e0a6d4cbae 100644
--- a/stories/layerbuild/components/PolygonWater.tsx
+++ b/dev-demos/features/polygon/demos/water.tsx
@@ -1,18 +1,21 @@
-// @ts-nocheck
-// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { PolygonLayer } from '@antv/l7-layers';
-import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+import {
+ Scene,
+ PolygonLayer,
+ // @ts-ignore
+} from '@antv/l7';
+// @ts-ignore
+import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [120, 30],
pitch: 0,
- zoom: 2,
+ zoom: 3,
}),
});
const layer = new PolygonLayer()
@@ -27,8 +30,9 @@ export default class Demo extends React.Component {
coordinates: [
[
[104.4140625, 35.460669951495305],
- [98.7890625, 24.206889622398023],
- [111.796875, 27.371767300523047],
+ [114.4140625, 35.460669951495305],
+ [114.4140625, 30.460669951495305],
+ [104.4140625, 30.460669951495305],
[104.4140625, 35.460669951495305],
],
],
@@ -47,20 +51,14 @@ export default class Demo extends React.Component {
scene.on('loaded', () => {
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/polygon/extrude.md b/dev-demos/features/polygon/extrude.md
new file mode 100644
index 0000000000..17144217fa
--- /dev/null
+++ b/dev-demos/features/polygon/extrude.md
@@ -0,0 +1,2 @@
+### Polygon - extrude
+
\ No newline at end of file
diff --git a/dev-demos/features/polygon/fill.md b/dev-demos/features/polygon/fill.md
new file mode 100644
index 0000000000..c43009af13
--- /dev/null
+++ b/dev-demos/features/polygon/fill.md
@@ -0,0 +1,2 @@
+### Polygon - fill
+
\ No newline at end of file
diff --git a/dev-demos/features/polygon/ocean.md b/dev-demos/features/polygon/ocean.md
new file mode 100644
index 0000000000..4fab5993a5
--- /dev/null
+++ b/dev-demos/features/polygon/ocean.md
@@ -0,0 +1,2 @@
+### Polygon - ocean
+
\ No newline at end of file
diff --git a/dev-demos/features/polygon/water.md b/dev-demos/features/polygon/water.md
new file mode 100644
index 0000000000..0718dd28af
--- /dev/null
+++ b/dev-demos/features/polygon/water.md
@@ -0,0 +1,2 @@
+### Polygon - water
+
\ No newline at end of file
diff --git a/stories/layerbuild/components/Wind.tsx b/dev-demos/features/something/demos/wind.tsx
similarity index 70%
rename from stories/layerbuild/components/Wind.tsx
rename to dev-demos/features/something/demos/wind.tsx
index 314a7f58f5..2494e04287 100644
--- a/stories/layerbuild/components/Wind.tsx
+++ b/dev-demos/features/something/demos/wind.tsx
@@ -1,12 +1,11 @@
-// @ts-nocheck
// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { WindLayer } from '@antv/l7-layers';
+import { Scene, WindLayer } from '@antv/l7';
+// @ts-ignore
import { GaodeMap } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
@@ -49,20 +48,14 @@ export default class Demo extends React.Component {
});
scene.addLayer(layer);
});
- }
-
- public render() {
- return (
-
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/something/wind.md b/dev-demos/features/something/wind.md
new file mode 100644
index 0000000000..be482f6762
--- /dev/null
+++ b/dev-demos/features/something/wind.md
@@ -0,0 +1,2 @@
+### wind
+
\ No newline at end of file
diff --git a/dev-demos/features/threejs/amap1.md b/dev-demos/features/threejs/amap1.md
new file mode 100644
index 0000000000..d532a50102
--- /dev/null
+++ b/dev-demos/features/threejs/amap1.md
@@ -0,0 +1,90 @@
+### threejs - amap1
+```tsx
+import { Scene } from '@antv/l7';
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import { ThreeLayer, ThreeRender } from '@antv/l7-three';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
+import { animate, easeInOut } from 'popmotion';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [111.4453125, 32.84267363195431],
+ pitch: 45,
+ rotation: 30,
+ zoom: 10,
+ }),
+ });
+ scene.registerRenderService(ThreeRender);
+ scene.on('loaded', () => {
+ const threeJSLayer = new ThreeLayer({
+ enableMultiPassRenderer: false,
+ // @ts-ignore
+ onAddMeshes: (threeScene: THREE.Scene, layer: ThreeLayer) => {
+ threeScene.add(new THREE.AmbientLight(0xffffff));
+ const sunlight = new THREE.DirectionalLight(0xffffff, 0.25);
+ sunlight.position.set(0, 80000000, 100000000);
+ sunlight.matrixWorldNeedsUpdate = true;
+ threeScene.add(sunlight);
+
+ let center = scene.getCenter();
+ let cubeGeometry = new THREE.BoxBufferGeometry(10000, 10000, 10000);
+ let cubeMaterial = new THREE.MeshNormalMaterial();
+ let cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
+ layer.setObjectLngLat(cube, [center.lng + 0.05, center.lat], 0);
+ threeScene.add(cube);
+
+ // 使用 Three.js glTFLoader 加载模型
+ const loader = new GLTFLoader();
+ loader.load(
+ 'https://gw.alipayobjects.com/os/bmw-prod/3ca0a546-92d8-4ba0-a89c-017c218d5bea.gltf',
+ (gltf) => {
+ // 根据 GeoJSON 数据放置模型
+ const gltfScene = gltf.scene;
+
+ layer.adjustMeshToMap(gltfScene);
+ layer.setMeshScale(gltfScene, 1000, 1000, 1000);
+
+ layer.setObjectLngLat(
+ gltfScene,
+ [ center.lng, center.lat ],
+ 0,
+ );
+
+ const animations = gltf.animations;
+ if (animations && animations.length) {
+ const mixer = new THREE.AnimationMixer(gltfScene);
+ const animation = animations[2];
+ const action = mixer.clipAction(animation);
+ action.play();
+ layer.addAnimateMixer(mixer);
+ }
+ // 向场景中添加模型
+ threeScene.add(gltfScene);
+
+ // 重绘图层
+ layer.render();
+ },
+ );
+ },
+ })
+ .animate(true);
+ scene.addLayer(threeJSLayer);
+ });
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/threejs/amap2.md b/dev-demos/features/threejs/amap2.md
new file mode 100644
index 0000000000..5e4be7dd14
--- /dev/null
+++ b/dev-demos/features/threejs/amap2.md
@@ -0,0 +1,90 @@
+### threejs - amap2
+```tsx
+import { Scene } from '@antv/l7';
+import { GaodeMapV2 } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import { ThreeLayer, ThreeRender } from '@antv/l7-three';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
+import { animate, easeInOut } from 'popmotion';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMapV2({
+ center: [111.4453125, 32.84267363195431],
+ pitch: 45,
+ rotation: 30,
+ zoom: 9,
+ }),
+ });
+ scene.registerRenderService(ThreeRender);
+ scene.on('loaded', () => {
+ const threeJSLayer = new ThreeLayer({
+ enableMultiPassRenderer: false,
+ // @ts-ignore
+ onAddMeshes: (threeScene: THREE.Scene, layer: ThreeLayer) => {
+ threeScene.add(new THREE.AmbientLight(0xffffff));
+ const sunlight = new THREE.DirectionalLight(0xffffff, 0.25);
+ sunlight.position.set(0, 80000000, 100000000);
+ sunlight.matrixWorldNeedsUpdate = true;
+ threeScene.add(sunlight);
+
+ let center = scene.getCenter();
+ let cubeGeometry = new THREE.BoxBufferGeometry(10000, 10000, 10000);
+ let cubeMaterial = new THREE.MeshNormalMaterial();
+ let cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
+ layer.setObjectLngLat(cube, [center.lng + 0.05, center.lat], 0);
+ threeScene.add(cube);
+
+ // 使用 Three.js glTFLoader 加载模型
+ const loader = new GLTFLoader();
+ loader.load(
+ 'https://gw.alipayobjects.com/os/bmw-prod/3ca0a546-92d8-4ba0-a89c-017c218d5bea.gltf',
+ (gltf) => {
+ // 根据 GeoJSON 数据放置模型
+ const gltfScene = gltf.scene;
+
+ layer.adjustMeshToMap(gltfScene);
+ layer.setMeshScale(gltfScene, 1000, 1000, 1000);
+
+ layer.setObjectLngLat(
+ gltfScene,
+ [ center.lng, center.lat ],
+ 0,
+ );
+
+ const animations = gltf.animations;
+ if (animations && animations.length) {
+ const mixer = new THREE.AnimationMixer(gltfScene);
+ const animation = animations[2];
+ const action = mixer.clipAction(animation);
+ action.play();
+ layer.addAnimateMixer(mixer);
+ }
+ // 向场景中添加模型
+ threeScene.add(gltfScene);
+
+ // 重绘图层
+ layer.render();
+ },
+ );
+ },
+ })
+ .animate(true);
+ scene.addLayer(threeJSLayer);
+ });
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/threejs/amapCar.md b/dev-demos/features/threejs/amapCar.md
new file mode 100644
index 0000000000..f8ce75175d
--- /dev/null
+++ b/dev-demos/features/threejs/amapCar.md
@@ -0,0 +1,250 @@
+### threejs - car
+```tsx
+import { Scene, PolygonLayer, LineLayer } from '@antv/l7';
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import { ThreeLayer, ThreeRender } from '@antv/l7-three';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
+import { animate, easeInOut } from 'popmotion';
+let isTravel = false;
+
+function travel(
+ mesh,
+ path,
+ duration,
+ callback
+) {
+ if (path.length < 2 || isTravel) return;
+ isTravel = true;
+ let startIndex = 0;
+ const len = path.length;
+ const currentP = path[0],
+ nextP = path[1];
+ const t = duration / len;
+
+ move(currentP, nextP);
+ function move(currentP, nextP) {
+ animate({
+ from: {
+ x: currentP.x,
+ y: currentP.y,
+ z: currentP.z
+ },
+ to: {
+ x: nextP.x,
+ y: nextP.y,
+ z: nextP.z
+ },
+ ease: easeInOut,
+ duration: t,
+ repeatType: 'loop',
+ onUpdate: o => {
+ mesh.position.set(o.x, o.y, o.z);
+ },
+ onComplete: () => {
+ startIndex++;
+ if (startIndex < len - 1) {
+ const currentP = path[startIndex],
+ nextP = path[startIndex + 1];
+ mesh.lookAt(nextP);
+
+ move(currentP, nextP);
+ } else {
+ isTravel = false;
+ callback && callback();
+ }
+ }
+ });
+ }
+}
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new GaodeMap({
+ center: [ 110, 35.39847 ],
+ pitch: 20,
+ style: 'dark',
+ zoom: 3
+ })
+ });
+
+ scene.on('loaded', () => {
+ scene.registerRenderService(ThreeRender);
+
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json'
+ )
+ .then(d => d.json())
+ .then(data => {
+ const polygonlayer = new PolygonLayer({})
+ .source(data)
+ .color('rgb(22,119,255)')
+ .shape('fill')
+ .active({
+ enable: true,
+ blend: 0.5
+ })
+ .style({
+ opacity: 0.6,
+ opacityLinear: {
+ enable: true,
+ dir: 'out' // in - out
+ }
+ });
+
+ const linelayer = new LineLayer({ })
+ .source(data)
+ .color('rgb(72,169,255)')
+ .shape('line')
+ .size(0.5)
+ .style({
+ opacity: 0.6
+ });
+
+ scene.addLayer(polygonlayer);
+ scene.addLayer(linelayer);
+ });
+
+
+ const threeJSLayer = new ThreeLayer({
+ zIndex: 2,
+ enableMultiPassRenderer: false,
+ onAddMeshes: (threeScene, layer) => {
+ // 添加光
+ threeScene.add(new THREE.AmbientLight(0xffffff));
+ const sunlight = new THREE.DirectionalLight(0xffffff, 0.25);
+ sunlight.position.set(0, 80000000, 100000000);
+ sunlight.matrixWorldNeedsUpdate = true;
+ threeScene.add(sunlight);
+
+ const lineData = [
+ [ 116.71874999999999, 26.745610382199022 ],
+ [ 117.3779296875, 28.8831596093235 ],
+ [ 115.75195312499999, 31.466153715024294 ],
+ [ 113.466796875, 33.32134852669881 ],
+ [ 113.9501953125, 35.85343961959182 ],
+ [ 115.400390625, 38.272688535980976 ],
+ [ 116.5869140625, 40.3130432088809 ],
+ [ 115.6201171875, 42.261049162113856 ],
+ [ 112.236328125, 42.94033923363181 ],
+ [ 109.3798828125, 41.04621681452063 ],
+ [ 103.84277343749999, 39.80853604144591 ],
+ [ 98.9208984375, 39.842286020743394 ],
+ [ 95.2294921875, 40.713955826286046 ],
+ [ 91.7138671875, 39.87601941962116 ],
+ [ 90.8349609375, 37.125286284966805 ],
+ [ 90.3076171875, 35.88905007936091 ],
+ [ 90.703125, 33.284619968887675 ],
+ [ 92.94433593749999, 31.98944183792288 ],
+ [ 96.2841796875, 32.21280106801518 ],
+ [ 98.87695312499999, 32.0639555946604 ],
+ [ 102.919921875, 28.459033019728043 ],
+ [ 107.9736328125, 28.497660832963472 ],
+ [ 108.10546875, 24.206889622398023 ],
+ [ 109.072265625, 23.039297747769726 ],
+ [ 112.763671875, 24.44714958973082 ],
+ [ 116.54296874999999, 25.958044673317843 ]
+ ];
+
+ const lineCoordData = lineData.map(d => {
+ return layer.lnglatToCoord(d);
+ });
+
+
+ const rawPoints = [];
+ lineCoordData.map(d => {
+ rawPoints.push(new THREE.Vector3(d[0], d[1], 0));
+ return '';
+ });
+ const curve = new THREE.CatmullRomCurve3(rawPoints);
+ const points = curve.getPoints(200);
+ const geometry = new THREE.BufferGeometry().setFromPoints(points);
+
+ const material = new THREE.LineBasicMaterial({ color: new THREE.Color('rgb(22,119,255)') });
+
+ const line = new THREE.LineLoop(geometry, material);
+ threeScene.add(line);
+
+
+ // 使用 Three.js glTFLoader 加载模型
+ const loader = new GLTFLoader();
+ loader.load(
+ 'https://gw.alipayobjects.com/os/antvdemo/assets/gltf/truck/CesiumMilkTruck.gltf', // Truck
+ gltf => {
+ // 根据 GeoJSON 数据放置模型
+ const gltfScene = gltf.scene.clone();
+ setMaterial(gltfScene);
+ layer.getSource().data.dataArray.forEach(() => {
+ layer.adjustMeshToMap(gltfScene);
+ gltfScene.scale.set(500000, 500000, 500000);
+
+ const animations = gltf.animations;
+ if (animations && animations.length) {
+ const mixer = new THREE.AnimationMixer(gltfScene);
+ // @ts-ignore
+ for (let i = 0; i < animations.length; i++) {
+ const animation = animations[i];
+
+ const action = mixer.clipAction(animation);
+
+ action.play();
+ }
+ layer.addAnimateMixer(mixer);
+ }
+
+ // 向场景中添加模型
+ threeScene.add(gltfScene);
+ });
+
+ travelLoop();
+ function travelLoop() {
+ travel(gltfScene, points, 5000, () => {
+ travelLoop();
+ });
+ }
+ // 重绘图层
+ layer.render();
+ }
+ );
+ }
+ })
+ .source({
+ type: 'FeatureCollection',
+ features: [
+ {
+ type: 'Feature',
+ properties: {},
+ geometry: {
+ type: 'Point',
+ coordinates: [ 112, 35.39847 ]
+ }
+ }
+ ]
+ })
+ .animate(true);
+ scene.addLayer(threeJSLayer);
+ });
+
+ function setMaterial(object) {
+ if (object.children && object.children.length && object.children.length > 0) {
+ object.children.map(child => setMaterial(child));
+ } else if (object.material) {
+ object.material.side = THREE.DoubleSide;
+ }
+ }
+
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/threejs/mapbox.md b/dev-demos/features/threejs/mapbox.md
new file mode 100644
index 0000000000..76c2ab76b7
--- /dev/null
+++ b/dev-demos/features/threejs/mapbox.md
@@ -0,0 +1,113 @@
+### threejs - Mapbox
+```tsx
+import { Scene } from '@antv/l7';
+import { Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import { ThreeLayer, ThreeRender } from '@antv/l7-three';
+import * as THREE from 'three';
+import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
+import { animate, easeInOut } from 'popmotion';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ map: new Mapbox({
+ center: [ 111.4453125, 32.84267363195431 ],
+ pitch: 45,
+ rotation: 30,
+ zoom: 12,
+ token: 'pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2w3dHk3dnN4MDYzaDNycDkyMDl2bzh6NiJ9.YIrG9kwUpayLj01f6W23Gw',
+ })
+ });
+
+ scene.on('loaded', () => {
+ scene.registerRenderService(ThreeRender);
+
+ const threeJSLayer = new ThreeLayer({
+ enableMultiPassRenderer: false,
+ onAddMeshes: (threeScene, layer) => {
+ threeScene.add(new THREE.AmbientLight(0xffffff));
+ const sunlight = new THREE.DirectionalLight(0xffffff, 0.25);
+ sunlight.position.set(0, 80000000, 100000000);
+ sunlight.matrixWorldNeedsUpdate = true;
+ threeScene.add(sunlight);
+
+ const center = scene.getCenter();
+
+ const cubeGeometry = new THREE.BoxBufferGeometry(10000, 10000, 10000);
+ const cubeMaterial = new THREE.MeshNormalMaterial({ side: THREE.DoubleSide });
+ const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
+ layer.setObjectLngLat(cube, [ center.lng + 0.05, center.lat ], 0);
+ threeScene.add(cube);
+
+ // 使用 Three.js glTFLoader 加载模型
+ const loader = new GLTFLoader();
+ loader.load(
+ 'https://gw.alipayobjects.com/os/bmw-prod/3ca0a546-92d8-4ba0-a89c-017c218d5bea.gltf',
+ gltf => {
+ const gltfScene = gltf.scene;
+ setDouble(gltfScene);
+ layer.adjustMeshToMap(gltfScene);
+ // gltfScene.scale.set(1000, 1000, 1000)
+ layer.setMeshScale(gltfScene, 100, 100, 100);
+
+ layer.setObjectLngLat(
+ gltfScene,
+ [ center.lng, center.lat ],
+ 0
+ );
+
+ const animations = gltf.animations;
+ if (animations && animations.length) {
+ const mixer = new THREE.AnimationMixer(gltfScene);
+
+ const animation = animations[2];
+
+ const action = mixer.clipAction(animation);
+
+ action.play();
+ layer.addAnimateMixer(mixer);
+ };
+ let t = 0;
+ setInterval(() => {
+ t += 0.01;
+ layer.setObjectLngLat(
+ gltfScene,
+ [ center.lng, center.lat + Math.sin(t) * 0.1 ],
+ 0
+ );
+ }, 16);
+
+ // 向场景中添加模型
+ threeScene.add(gltfScene);
+ // 重绘图层
+ layer.render();
+ }
+ );
+ }
+ })
+ .animate(true);
+ scene.addLayer(threeJSLayer);
+ });
+
+ function setDouble(object) {
+ if (object.children && object.children.length && object.children.length > 0) {
+ object.children.map(child => setDouble(child));
+ } else if (object.material) {
+ object.material.side = THREE.DoubleSide;
+ }
+ }
+ }, [])
+ return (
+
+ );
+}
+
+```
\ No newline at end of file
diff --git a/dev-demos/features/tile/basemap.md b/dev-demos/features/tile/basemap.md
new file mode 100644
index 0000000000..c184e89da1
--- /dev/null
+++ b/dev-demos/features/tile/basemap.md
@@ -0,0 +1,3 @@
+### Render Map - Base Tile Map ( L7Layer X 12)
+绘制地图
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/basemap/basemap.tsx b/dev-demos/features/tile/basemap/basemap.tsx
new file mode 100644
index 0000000000..2e1223081e
--- /dev/null
+++ b/dev-demos/features/tile/basemap/basemap.tsx
@@ -0,0 +1,191 @@
+// @ts-ignore
+import {
+ Scene,
+ LineLayer,
+ Source,
+ PolygonLayer,
+ PointLayer,
+ TileDebugLayer,
+} from '@antv/l7';
+// @ts-ignore
+import { Map } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ stencil: true,
+ map: new Map({
+ center: [121.268, 29],
+ // zoom: 12,
+ // zoom: 7,
+ zoom: 6,
+ }),
+ });
+
+ const url =
+ 'https://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=';
+ const token =
+ // 'pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2s5OXVzdHlzMDVneDNscDVjdzVmeXl0dyJ9.81SQ5qaJS0xExYLbDZAGpQ';
+ 'pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2w3dHk3dnN4MDYzaDNycDkyMDl2bzh6NiJ9.YIrG9kwUpayLj01f6W23Gw';
+ const source = new Source(url + token, {
+ parser: {
+ type: 'mvt',
+ tileSize: 256,
+ // extent: [-180, -85.051129, 179, 85.051129],
+ cancelExtent: true,
+ },
+ });
+ /**
+ * admin
+ * country_label
+ * marine_label
+ * place_label
+ * state_label
+ * water
+ * road
+ * road_label
+ * landuse
+ * landuse_overlay
+ * waterway
+ * tunnel
+ */
+
+ scene.on('loaded', () => {
+ const admin = new LineLayer({
+ sourceLayer: 'admin',
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('simple')
+ .color('#696969');
+
+ scene.addLayer(admin);
+
+ const road = new LineLayer({
+ sourceLayer: 'road',
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('simple')
+ .color('#FFA500');
+ scene.addLayer(road);
+
+ const poiLabel = new PointLayer({
+ sourceLayer: 'poi_label',
+ usage: 'basemap',
+ zIndex: 1,
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#333')
+ .size(10);
+ scene.addLayer(poiLabel);
+
+ const landuse_overlay = new PolygonLayer({
+ sourceLayer: 'landuse_overlay',
+ usage: 'basemap',
+ })
+ .source(source)
+ .color('#f00');
+ scene.addLayer(landuse_overlay);
+
+ // const waterway = new LineLayer({
+ // sourceLayer: 'waterway',
+ // usage: 'basemap',
+ // })
+ // .source(source)
+ // .shape('simple')
+ // // .color('#87CEFA');
+ // .color('#f00');
+ // scene.addLayer(waterway);
+
+ const tunnel = new LineLayer({
+ sourceLayer: 'tunnel',
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('simple')
+ // .color('#A9A9A9');
+ .color('#f00');
+ scene.addLayer(tunnel);
+
+ const landuse = new PolygonLayer({
+ sourceLayer: 'landuse',
+ usage: 'basemap',
+ })
+ .source(source)
+ .color('#90EE90');
+ scene.addLayer(landuse);
+
+ const state_label = new PointLayer({
+ sourceLayer: 'state_label',
+ zIndex: 1,
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#000')
+ .size(12);
+ scene.addLayer(state_label);
+
+ // const placeLabel = new PointLayer({
+ // sourceLayer: 'place_label',
+ // zIndex: 1,
+ // usage: 'basemap',
+ // })
+ // .source(source)
+ // .shape('name', 'text')
+ // .color('#000')
+ // .size(8);
+ // scene.addLayer(placeLabel);
+
+ const marineLabel = new PointLayer({
+ sourceColor: 'marine_label',
+ zIndex: 1,
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#0ff')
+ .size(15);
+ scene.addLayer(marineLabel);
+
+ const countryLabel = new PointLayer({
+ sourceLayer: 'country_label',
+ zIndex: 2,
+ usage: 'basemap',
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#f00')
+ .size(15);
+ scene.addLayer(countryLabel);
+
+ const water = new PolygonLayer({
+ sourceLayer: 'water',
+ usage: 'basemap',
+ })
+ .source(source)
+ .color('#87CEFA');
+ scene.addLayer(water);
+
+ const debugerLayer = new TileDebugLayer({ usage: 'basemap' });
+ scene.addLayer(debugerLayer);
+
+ // scene.on('zoom', () => {
+ // console.log(scene.getLayers().length)
+ // })
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/tile/basemap/vectormap.tsx b/dev-demos/features/tile/basemap/vectormap.tsx
new file mode 100644
index 0000000000..ee78ccd429
--- /dev/null
+++ b/dev-demos/features/tile/basemap/vectormap.tsx
@@ -0,0 +1,166 @@
+// @ts-ignore
+import {
+ Scene,
+ LineLayer,
+ Source,
+ PolygonLayer,
+ PointLayer,
+ TileDebugLayer,
+} from '@antv/l7';
+// @ts-ignore
+import { Map } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ stencil: true,
+ map: new Map({
+ center: [121.268, 30.3628],
+ // zoom: 12,
+ zoom: 7,
+ }),
+ });
+
+ const url =
+ 'https://a.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=';
+ const token =
+ // 'pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2s5OXVzdHlzMDVneDNscDVjdzVmeXl0dyJ9.81SQ5qaJS0xExYLbDZAGpQ';
+ 'pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2w3dHk3dnN4MDYzaDNycDkyMDl2bzh6NiJ9.YIrG9kwUpayLj01f6W23Gw';
+ const source = new Source(url + token, {
+ parser: {
+ type: 'mvt',
+ tileSize: 256,
+ // extent: [-180, -85.051129, 179, 85.051129],
+ },
+ });
+ /**
+ * admin
+ * country_label
+ * marine_label
+ * place_label
+ * state_label
+ * water
+ * road
+ * road_label
+ * landuse
+ * landuse_overlay
+ * waterway
+ * tunnel
+ */
+
+ scene.on('loaded', () => {
+ const admin = new LineLayer({
+ sourceLayer: 'admin',
+ })
+ .source(source)
+ .shape('simple')
+ .size(1)
+ .color('#696969');
+ scene.addLayer(admin);
+
+ const road = new LineLayer({
+ sourceLayer: 'road',
+ })
+ .source(source)
+ .shape('simple')
+ .color('#FFA500');
+ scene.addLayer(road);
+
+ // const landuse_overlay = new PolygonLayer({
+ // sourceLayer: 'landuse_overlay',
+ // })
+ // .source(source)
+ // .color('#f00');
+ // scene.addLayer(landuse_overlay);
+
+ // const waterway = new LineLayer({
+ // sourceLayer: 'waterway',
+ // })
+ // .source(source)
+ // .shape('simple')
+ // .color('#87CEFA');
+ // scene.addLayer(waterway);
+
+ // const tunnel = new LineLayer({
+ // sourceLayer: 'tunnel',
+ // })
+ // .source(source)
+ // .shape('simple')
+ // // .color('#A9A9A9');
+ // .color('#f00');
+ // scene.addLayer(tunnel);
+
+ const landuse = new PolygonLayer({
+ sourceLayer: 'landuse',
+ })
+ .source(source)
+ .color('#90EE90');
+ scene.addLayer(landuse);
+
+ const state_label = new PointLayer({
+ sourceLayer: 'state_label',
+ zIndex: 1,
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#000')
+ .size(10);
+ scene.addLayer(state_label);
+
+ // const placeLabel = new PointLayer({
+ // sourceLayer: 'place_label',
+ // zIndex: 1,
+ // })
+ // .source(source)
+ // .shape('name', 'text')
+ // .color('#000')
+ // .size(8);
+ // scene.addLayer(placeLabel);
+
+ const marineLabel = new PointLayer({
+ sourceColor: 'marine_label',
+ zIndex: 1,
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#0ff')
+ .size(15);
+ scene.addLayer(marineLabel);
+
+ const countryLabel = new PointLayer({
+ sourceLayer: 'country_label',
+ zIndex: 2,
+ })
+ .source(source)
+ .shape('name', 'text')
+ .color('#f00')
+ .size(15);
+ scene.addLayer(countryLabel);
+
+ const water = new PolygonLayer({
+ sourceLayer: 'water',
+ })
+ .source(source)
+ .color('#87CEFA');
+ scene.addLayer(water);
+
+ const debugerLayer = new TileDebugLayer();
+ scene.addLayer(debugerLayer);
+
+ // scene.on('zoom', () => {
+ // console.log(scene.getLayers().length)
+ // })
+ });
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/tile/geojson-vt.md b/dev-demos/features/tile/geojson-vt.md
deleted file mode 100644
index fc6139abaa..0000000000
--- a/dev-demos/features/tile/geojson-vt.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### geojson - vt
-
\ No newline at end of file
diff --git a/stories/tile/components/RasterImageDataTile.tsx b/dev-demos/features/tile/raster/imageDataMapping.tsx
similarity index 56%
rename from stories/tile/components/RasterImageDataTile.tsx
rename to dev-demos/features/tile/raster/imageDataMapping.tsx
index a201ba9350..2c60ba30a2 100644
--- a/stories/tile/components/RasterImageDataTile.tsx
+++ b/dev-demos/features/tile/raster/imageDataMapping.tsx
@@ -1,19 +1,13 @@
-import * as React from 'react';
-import * as turf from '@turf/turf';
-import { RasterLayer, Scene, LineLayer, ILayer } from '@antv/l7';
-import { GaodeMap, GaodeMapV2, Map, Mapbox } from '@antv/l7-maps';
+//@ts-ignore
+import { Scene, RasterLayer } from '@antv/l7';
+//@ts-ignore
+import { Map } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
-export default class OsmRasterTile extends React.Component {
- private scene: Scene;
- private gridLayer: ILayer;
-
- public componentWillUnmount() {
- this.scene.destroy();
- }
-
- public async componentDidMount() {
- this.scene = new Scene({
- id: 'map',
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map2',
map: new Map({
center: [130, 30],
pitch: 0,
@@ -22,9 +16,7 @@ export default class OsmRasterTile extends React.Component {
}),
});
- // this.scene.on('mapchange', this.updateGridLayer);
-
- this.scene.on('loaded', () => {
+ scene.on('loaded', () => {
const layer = new RasterLayer({})
.source(
'http://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
@@ -32,17 +24,15 @@ export default class OsmRasterTile extends React.Component {
parser: {
type: 'rasterTile',
tileSize: 256,
-
zoomOffset: 0,
updateStrategy: 'overlap',
},
},
)
- .shape('dataImage')
+ .shape('tileDataImage')
.style({
clampLow: false,
clampHigh: false,
- // opacity: 0.8,
domain: [0, 8000],
rampColors: {
colors: [
@@ -63,24 +53,16 @@ export default class OsmRasterTile extends React.Component {
pixelConstantRGB: 1,
});
- this.scene.addLayer(layer);
+ scene.addLayer(layer);
});
- }
-
- public render() {
- return (
- <>
-
- >
- );
- }
-}
+ }, []);
+ return (
+
+ );
+};
diff --git a/dev-demos/features/tile/rastertile.tsx b/dev-demos/features/tile/raster/satellite.tsx
similarity index 84%
rename from dev-demos/features/tile/rastertile.tsx
rename to dev-demos/features/tile/raster/satellite.tsx
index ee4b1ee5af..c708216675 100644
--- a/dev-demos/features/tile/rastertile.tsx
+++ b/dev-demos/features/tile/raster/satellite.tsx
@@ -35,14 +35,11 @@ export default () => {
zIndex: 0,
});
layerTile2.source(
- // '//t3.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=f1f2021a42d110057042177cd22d856f',
'http://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
{
parser: {
type: 'rasterTile',
tileSize: 256,
- // zoomOffset: 0
- // zoomOffset: 1,
},
},
);
diff --git a/dev-demos/features/tile/rasterData.md b/dev-demos/features/tile/rasterData.md
new file mode 100644
index 0000000000..b681b0f55c
--- /dev/null
+++ b/dev-demos/features/tile/rasterData.md
@@ -0,0 +1,10 @@
+### Raster - RasterData
+数据栅格
+#### 加载 tiff
+
+
+#### 加载 lerc
+
+
+#### 加载 image
+
\ No newline at end of file
diff --git a/stories/layerbuild/components/RasterDataTile.tsx b/dev-demos/features/tile/rasterData/loadImage.tsx
similarity index 61%
rename from stories/layerbuild/components/RasterDataTile.tsx
rename to dev-demos/features/tile/rasterData/loadImage.tsx
index 99d765cf38..ba7d19a8c7 100644
--- a/stories/layerbuild/components/RasterDataTile.tsx
+++ b/dev-demos/features/tile/rasterData/loadImage.tsx
@@ -1,14 +1,13 @@
-// @ts-nocheck
-// @ts-ignore
-import { Scene, Source } from '@antv/l7';
-import { RasterLayer } from '@antv/l7-layers';
+//@ts-ignore
+import { Scene, RasterLayer } from '@antv/l7';
+//@ts-ignore
import { Map } from '@antv/l7-maps';
-import * as React from 'react';
+import React, { useEffect } from 'react';
-export default class Demo extends React.Component {
- public async componentDidMount() {
+export default () => {
+ useEffect(() => {
const scene = new Scene({
- id: 'map',
+ id: 'map2',
map: new Map({
center: [105.732421875, 32.24997445586331],
pitch: 0,
@@ -20,17 +19,14 @@ export default class Demo extends React.Component {
const canvas = document.createElement('canvas');
canvas.width = 256;
canvas.height = 256;
- const ctx = canvas.getContext('2d');
+ const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
scene.on('loaded', () => {
const layer = new RasterLayer();
layer
.source(
- // 'http://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
- // 'https://api.mapbox.com/raster/v1/mapbox.mapbox-terrain-dem-v1/{zoom}/{x}/{y}.pngraw?sku=YOUR_MAPBOX_SKU_TOKEN&access_token=pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2s5OXVzdHlzMDVneDNscDVjdzVmeXl0dyJ9.81SQ5qaJS0xExYLbDZAGpQ',
- 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2s5OXVzdHlzMDVneDNscDVjdzVmeXl0dyJ9.81SQ5qaJS0xExYLbDZAGpQ',
- // 'https://s2downloads.eox.at/demo/EOxCloudless/2019/rgb/{z}/{y}/{x}.tif',
- // 'http://rd1yhmrzc.hn-bkt.clouddn.com/Mapnik/{z}/{x}/{y}.png',
+ 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=pk.eyJ1IjoiMTg5Njk5NDg2MTkiLCJhIjoiY2w3dHk3dnN4MDYzaDNycDkyMDl2bzh6NiJ9.YIrG9kwUpayLj01f6W23Gw',
+
{
parser: {
type: 'rasterTile',
@@ -46,8 +42,8 @@ export default class Demo extends React.Component {
const img = await createImageBitmap(blob);
ctx.clearRect(0, 0, 256, 256);
ctx.drawImage(img, 0, 0, 256, 256);
- let imgData = ctx.getImageData(0, 0, 256, 256).data;
- let arr = [];
+ const imgData = ctx.getImageData(0, 0, 256, 256).data;
+ const arr: number[] = [];
for (let i = 0; i < imgData.length; i += 4) {
const R = imgData[i];
const G = imgData[i + 1];
@@ -83,22 +79,18 @@ export default class Demo extends React.Component {
},
});
- scene.addLayer(layer);
+ scene.addLayer(layer)
+
});
- }
+ }, []);
- public render() {
- return (
-
- );
- }
-}
+ return (
+
+ );
+};
\ No newline at end of file
diff --git a/dev-demos/features/tile/rasterData/loadImageMask.tsx b/dev-demos/features/tile/rasterData/loadImageMask.tsx
new file mode 100644
index 0000000000..ca9df919d0
--- /dev/null
+++ b/dev-demos/features/tile/rasterData/loadImageMask.tsx
@@ -0,0 +1,98 @@
+//@ts-ignore
+import { Scene, RasterLayer } from '@antv/l7';
+//@ts-ignore
+import { Mapbox } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+
+export default () => {
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map3',
+ stencil: true,
+ map: new Mapbox({
+ center: [100, 30],
+ pitch: 0,
+ style: 'blank',
+ zoom: 4,
+ }),
+ });
+ const canvas = document.createElement('canvas');
+ canvas.width = 256;
+ canvas.height = 256;
+ const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
+ scene.on('loaded', () => {
+ fetch(
+ 'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
+ )
+ .then((res) => res.json())
+ .then((data) => {
+ const layer = new RasterLayer({
+ mask: true,
+ maskfence: data,
+ });
+ layer
+ .source(
+ 'http://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
+ {
+ parser: {
+ type: 'rasterTile',
+ dataType: 'arraybuffer',
+ tileSize: 256,
+
+ format: async (data: any) => {
+ const blob: Blob = new Blob([new Uint8Array(data)], {
+ type: 'image/png',
+ });
+ const img = await createImageBitmap(blob);
+ ctx.clearRect(0, 0, 256, 256);
+ ctx.drawImage(img, 0, 0, 256, 256);
+
+ const imgData = ctx.getImageData(0, 0, 256, 256).data;
+ const arr: number[] = [];
+ for (let i = 0; i < imgData.length; i += 4) {
+ arr.push(imgData[i]);
+ }
+ return {
+ rasterData: arr,
+ width: 256,
+ height: 256,
+ };
+ },
+ },
+ },
+ )
+ .style({
+ opacity: 1,
+ domain: [0, 256],
+ clampLow: true,
+ rampColors: {
+ colors: [
+
+ 'rgb(0,0,255)',
+ 'rgb(0,0,0)',
+ 'rgb(0,255,0)',
+ 'rgb(255,0,0)',
+ 'rgb(255,0,0)',
+ ],
+ positions: [0, 0.25, 0.5, 0.75, 1.0],
+ },
+ })
+ .select(true);
+
+ scene.addLayer(layer);
+
+
+ });
+ });
+ }, []);
+
+ return (
+
+ );
+};
\ No newline at end of file
diff --git a/dev-demos/features/tile/rasterData/loadLerc.tsx b/dev-demos/features/tile/rasterData/loadLerc.tsx
new file mode 100644
index 0000000000..bda0f2fe18
--- /dev/null
+++ b/dev-demos/features/tile/rasterData/loadLerc.tsx
@@ -0,0 +1,68 @@
+//@ts-ignore
+import { RasterLayer, Scene } from '@antv/l7';
+//@ts-ignore
+import { Map } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import * as Lerc from 'lerc';
+
+export default () => {
+
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'lerc',
+ map: new Map({
+ center: [120, 30],
+ style: 'blank',
+ zoom: 3
+ }),
+ });
+
+ scene.on('loaded', () => {
+ const layer = new RasterLayer();
+ layer
+ .source(
+ 'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/{z}/{y}/{x}',
+ {
+ parser: {
+ type: 'rasterTile',
+ dataType: 'arraybuffer',
+ tileSize: 256,
+ format: async (data: any) => {
+ const image = Lerc.decode(data);
+ return {
+ rasterData: image.pixels[0],
+ width: image.width,
+ height: image.height,
+ };
+ },
+ },
+ },
+ )
+ .style({
+ domain: [0, 1024],
+ rampColors: {
+ colors: [ '#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858' ],
+ positions: [ 0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0 ],
+ },
+ })
+ .select(true);
+
+ scene.addLayer(layer);
+ });
+
+
+ return () => {
+ scene.destroy();
+ };
+ }, []);
+
+ return (
+
+ );
+};
diff --git a/dev-demos/features/tile/rasterData/loadTiff.tsx b/dev-demos/features/tile/rasterData/loadTiff.tsx
new file mode 100644
index 0000000000..c3d1ccf2b3
--- /dev/null
+++ b/dev-demos/features/tile/rasterData/loadTiff.tsx
@@ -0,0 +1,131 @@
+import { RasterLayer, Scene, Source } from '@antv/l7';
+import { GaodeMap } from '@antv/l7-maps';
+import React, { useEffect } from 'react';
+import * as GeoTIFF from 'geotiff';
+
+const colorList = [
+ '#419bdf', // Water
+ '#419bdf',
+
+ '#397d49', // Tree
+ '#397d49',
+
+ '#88b053', // Grass
+ '#88b053',
+
+ '#7a87c6', // vegetation
+ '#7a87c6',
+
+ '#e49635', // Crops
+ '#e49635',
+
+ '#dfc35a', // shrub
+ '#dfc35a',
+
+ '#c4281b', // Built Area
+ '#c4281b',
+
+ '#a59b8f', // Bare ground
+ '#a59b8f',
+
+ '#a8ebff', // Snow
+ '#a8ebff',
+
+ '#616161', // Clouds
+ '#616161'
+];
+const positions = [
+ 0.0,
+ 0.1,
+ 0.1,
+ 0.2,
+ 0.2,
+ 0.3,
+ 0.3,
+ 0.4,
+ 0.4,
+ 0.5,
+ 0.5,
+ 0.6,
+ 0.6,
+ 0.7,
+ 0.7,
+ 0.8,
+ 0.8,
+ 0.9,
+ 0.9,
+ 1.0
+];
+export default () => {
+
+ useEffect(() => {
+ const scene = new Scene({
+ id: 'map',
+ stencil: true,
+ map: new GaodeMap({
+ center: [ 116, 27 ],
+ zoom: 6,
+ style: 'dark'
+ })
+ });
+
+ scene.on('loaded', () => {
+ fetch(
+ 'https://gw.alipayobjects.com/os/bmw-prod/fccd80c0-2611-49f9-9a9f-e2a4dd12226f.json'
+ )
+ .then(res => res.json())
+ .then(maskData => {
+ const layer = new RasterLayer({
+ mask: true,
+ maskfence: maskData
+ });
+
+ const tileSource = new Source('https://ganos.oss-cn-hangzhou.aliyuncs.com/m2/l7/tiff_jx/{z}/{x}/{y}.tiff',
+ {
+ parser: {
+ type: 'rasterTile',
+ dataType: 'arraybuffer',
+ tileSize: 256,
+ maxZoom: 13.1,
+ format: async data => {
+ const tiff = await GeoTIFF.fromArrayBuffer(data);
+ const image = await tiff.getImage();
+ const width = image.getWidth();
+ const height = image.getHeight();
+ const values = await image.readRasters();
+ return { rasterData: values[0], width, height };
+ }
+ }
+ });
+
+ layer.source(tileSource)
+ .style({
+ domain: [ 0.001, 11.001 ],
+ clampLow: false,
+ rampColors: {
+ colors: colorList,
+ positions
+ }
+ });
+
+ scene.addLayer(layer);
+ });
+ });
+
+
+
+ return () => {
+ scene.destroy();
+ };
+ }, []);
+
+ return (
+
+ );
+};
diff --git a/dev-demos/features/tile/rasterDataImage.md b/dev-demos/features/tile/rasterDataImage.md
new file mode 100644
index 0000000000..87f629e447
--- /dev/null
+++ b/dev-demos/features/tile/rasterDataImage.md
@@ -0,0 +1,5 @@
+### Raster - RasterDataImage
+raster 图片瓦片
+
+#### 图片瓦片 - 颜色映射
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/rasterDataMask.md b/dev-demos/features/tile/rasterDataMask.md
new file mode 100644
index 0000000000..6404a3beb3
--- /dev/null
+++ b/dev-demos/features/tile/rasterDataMask.md
@@ -0,0 +1,5 @@
+### Raster - RasterData - Mask
+数据栅格 + Mask
+
+#### 加载 image + Mask
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/rasterImage.md b/dev-demos/features/tile/rasterImage.md
new file mode 100644
index 0000000000..5cf250bd80
--- /dev/null
+++ b/dev-demos/features/tile/rasterImage.md
@@ -0,0 +1,8 @@
+### Raster - RasterImage
+raster 图片瓦片
+
+#### 卫星图
+
+
+#### 图片瓦片 - 颜色映射
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/rastertile.md b/dev-demos/features/tile/rastertile.md
deleted file mode 100644
index eeaa53083b..0000000000
--- a/dev-demos/features/tile/rastertile.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Raster Tile
-
\ No newline at end of file
diff --git a/dev-demos/features/tile/testTile.md b/dev-demos/features/tile/testTile.md
deleted file mode 100644
index 79ed00771f..0000000000
--- a/dev-demos/features/tile/testTile.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Test Tile
-
\ No newline at end of file
diff --git a/dev-demos/features/tile/vector.md b/dev-demos/features/tile/vector.md
new file mode 100644
index 0000000000..c68b2304c0
--- /dev/null
+++ b/dev-demos/features/tile/vector.md
@@ -0,0 +1,13 @@
+### Vector
+
+#### vector point
+
+
+#### vector line
+
+
+#### geojson-vt
+
+
+#### debugLayer
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/testTile.tsx b/dev-demos/features/tile/vector/debugLayer.tsx
similarity index 94%
rename from dev-demos/features/tile/testTile.tsx
rename to dev-demos/features/tile/vector/debugLayer.tsx
index 394ed4a59d..9aa4abb14c 100644
--- a/dev-demos/features/tile/testTile.tsx
+++ b/dev-demos/features/tile/vector/debugLayer.tsx
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react';
export default () => {
useEffect(() => {
const scene = new Scene({
- id: 'map',
+ id: 'test',
// stencil: true,
map: new Mapbox({
center: [121.268, 30.3628],
@@ -23,7 +23,7 @@ export default () => {
}, []);
return (
{
useEffect(() => {
const scene = new Scene({
- id: 'map',
+ id: 'geojsonvt',
stencil: true,
map: new Mapbox({
center: [121.268, 30.3628],
@@ -28,7 +28,7 @@ export default () => {
tileSize: 256,
zoomOffset: 0,
maxZoom: 9,
- extent: [-180, -85.051129, 179, 85.051129],
+ // extent: [-180, -85.051129, 179, 85.051129],
},
});
@@ -46,9 +46,14 @@ export default () => {
})
.source(source)
.color('COLOR')
- .active(true);
+ .active(true)
+ .style({
+ opacity: 0.6,
+ });
scene.addLayer(polygon);
+ // scene.on('zoom', (e) => console.log(scene.getZoom()));
+
// const point = new PointLayer({
// featureId: 'COLOR',
// sourceLayer: 'testName', // woods hillshade contour ecoregions ecoregions2 city
@@ -62,7 +67,7 @@ export default () => {
}, []);
return (
{
useEffect(() => {
const scene = new Scene({
- id: 'map',
+ id: 'line',
stencil: true,
map: new Mapbox({
center: [121.268, 30.3628],
@@ -34,8 +34,7 @@ export default () => {
},
},
)
- .shape('simple')
-
+ // .shape('simple')
.color('COLOR')
.size(2)
.select(true);
@@ -49,7 +48,7 @@ export default () => {
}, []);
return (
{
useEffect(() => {
const scene = new Scene({
- id: 'map',
+ id: 'point',
stencil: true,
map: new Mapbox({
center: [121.268, 30.3628],
@@ -108,7 +108,7 @@ export default () => {
}, []);
return (
\ No newline at end of file
diff --git a/dev-demos/features/tile/vectormap.md b/dev-demos/features/tile/vectormap.md
new file mode 100644
index 0000000000..911c47aa2a
--- /dev/null
+++ b/dev-demos/features/tile/vectormap.md
@@ -0,0 +1,3 @@
+### Render Map - Vector Tile Map
+绘制地图
+
\ No newline at end of file
diff --git a/dev-demos/features/tile/vectortile.md b/dev-demos/features/tile/vectortile.md
deleted file mode 100644
index 89472532cf..0000000000
--- a/dev-demos/features/tile/vectortile.md
+++ /dev/null
@@ -1,2 +0,0 @@
-### Vector Tile
-
\ No newline at end of file
diff --git a/packages/component/src/control/layer.ts b/packages/component/src/control/layer.ts
index c48c215f21..9c088bb13a 100644
--- a/packages/component/src/control/layer.ts
+++ b/packages/component/src/control/layer.ts
@@ -125,11 +125,11 @@ export default class Layers extends Control {
}
private initLayers() {
const { baseLayers = {}, overlayers = {} } = this.controlOption;
- Object.keys(baseLayers).forEach((name: string, index: number) => {
+ Object.keys(baseLayers).forEach((name: string) => {
// baseLayers[name].once('inited', this.update);
this.addLayer(baseLayers[name], name, false);
});
- Object.keys(overlayers).forEach((name: any, index: number) => {
+ Object.keys(overlayers).forEach((name: any) => {
// overlayers[name].once('inited', this.update);
this.addLayer(overlayers[name], name, true);
});
diff --git a/packages/component/src/marker.ts b/packages/component/src/marker.ts
index e700e29097..6a25de1f45 100644
--- a/packages/component/src/marker.ts
+++ b/packages/component/src/marker.ts
@@ -54,7 +54,7 @@ export default class Marker extends EventEmitter {
this.scene = scene;
this.mapsService = scene.get
(TYPES.IMapService);
this.sceneSerive = scene.get(TYPES.ISceneService);
- const { element, draggable } = this.markerOption;
+ const { element } = this.markerOption;
// this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
this.mapsService.getMarkerContainer().appendChild(element as HTMLElement);
this.registerMarkerEvent(element as HTMLElement);
@@ -189,6 +189,7 @@ export default class Marker extends EventEmitter {
return this.markerOption.offsets;
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public setDraggable(draggable: boolean) {
throw new Error('Method not implemented.');
}
@@ -214,6 +215,7 @@ export default class Marker extends EventEmitter {
DOM.setTransform(element as HTMLElement, `${anchorTranslate[anchor]}`);
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
private onMapClick(e: MouseEvent) {
const { element } = this.markerOption;
if (this.popup && element) {
@@ -344,10 +346,13 @@ export default class Marker extends EventEmitter {
lngLat: this.lngLat,
});
};
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
private addDragHandler(e: MouseEvent) {
throw new Error('Method not implemented.');
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
private onUp(e: MouseEvent) {
throw new Error('Method not implemented.');
}
diff --git a/packages/core/src/inversify.config.ts b/packages/core/src/inversify.config.ts
index 585f9c9b4b..e4b58adf83 100644
--- a/packages/core/src/inversify.config.ts
+++ b/packages/core/src/inversify.config.ts
@@ -125,6 +125,7 @@ export const lazyMultiInject = (
original.call(this, proto, key);
if (descriptor) {
// return link to proto, so own value wont be 'undefined' after component's creation
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
descriptor!.initializer = () => {
return proto[key];
};
diff --git a/packages/core/src/services/interaction/InteractionService.ts b/packages/core/src/services/interaction/InteractionService.ts
index 6262866062..87e1da06cb 100644
--- a/packages/core/src/services/interaction/InteractionService.ts
+++ b/packages/core/src/services/interaction/InteractionService.ts
@@ -107,7 +107,7 @@ export default class InteractionService extends EventEmitter
this.hammertime = hammertime;
}
- // // TODO: 根据场景注册事件到 L7 canvas 上
+ // Tip: 根据场景注册事件到 L7 canvas 上
}
}
private removeEventListenerOnMap() {
diff --git a/packages/core/src/services/interaction/PickingService.ts b/packages/core/src/services/interaction/PickingService.ts
index c0fca85a33..11fc388a7f 100644
--- a/packages/core/src/services/interaction/PickingService.ts
+++ b/packages/core/src/services/interaction/PickingService.ts
@@ -9,7 +9,7 @@ import {
IInteractionTarget,
InteractionEvent,
} from '../interaction/IInteractionService';
-import { ILayer, ILayerService } from '../layer/ILayerService';
+import { ILayer, ILayerService, ITileLayer } from '../layer/ILayerService';
import { ILngLat, IMapService } from '../map/IMapService';
import { gl } from '../renderer/gl';
import { IFramebuffer } from '../renderer/IFramebuffer';
@@ -303,7 +303,7 @@ export default class PickingService implements IPickingService {
.getLayers()
.filter((l) => l.tileLayer)
.map((l) => {
- l.tileLayer.clearPickState();
+ (l.tileLayer as ITileLayer).clearPickState();
});
}
}
@@ -322,24 +322,29 @@ export default class PickingService implements IPickingService {
}
}
private async pickingAllLayer(target: IInteractionTarget) {
- if (
- // TODO: this.alreadyInPicking 避免多次重复拾取
- this.alreadyInPicking ||
- // TODO: this.layerService.alreadyInRendering 一个渲染序列中只进行一次拾取操作
- this.layerService.alreadyInRendering ||
- // Tip: this.interactionService.dragging amap2 在点击操作的时候同时会触发 dragging 的情况(避免舍去)
- this.interactionService.indragging ||
- // TODO: 判断当前 是都进行 shader pick 拾取判断
- !this.layerService.getShaderPickStat()
- ) {
- return;
- }
+ // 判断是否进行拾取操作
+ if (!this.isPickingAllLayer()) return;
+
this.alreadyInPicking = true;
- await this.pickingLayers(target);
+ await this.pickingLayers(target);
this.layerService.renderLayers();
this.alreadyInPicking = false;
}
+ private isPickingAllLayer() {
+ // this.alreadyInPicking 避免多次重复拾取
+ if(this.alreadyInPicking) return false;
+ // this.layerService.alreadyInRendering 一个渲染序列中只进行一次拾取操作
+ if(this.layerService.alreadyInRendering) return false;
+ // this.interactionService.dragging amap2 在点击操作的时候同时会触发 dragging 的情况(避免舍去)
+ if(this.interactionService.indragging) return false;
+ // 判断当前进行 shader pick 拾取判断
+ if(!this.layerService.getShaderPickStat()) return false;
+
+ // 进行拾取
+ return true;
+ }
+
private resizePickingFBO() {
const { getContainer } = this.rendererService;
let { width, height } = this.getContainerSize(
@@ -359,10 +364,8 @@ export default class PickingService implements IPickingService {
}
private async pickingLayers(target: IInteractionTarget) {
const {
- getViewportSize,
useFramebuffer,
clear,
- getContainer,
} = this.rendererService;
this.resizePickingFBO();
@@ -387,12 +390,12 @@ export default class PickingService implements IPickingService {
});
// Tip: clear last picked tilelayer state
this.pickedTileLayers.map((pickedTileLayer) =>
- pickedTileLayer.tileLayer?.clearPick(target.type),
+ (pickedTileLayer.tileLayer as ITileLayer)?.clearPick(target.type),
);
// Tip: 如果当前 layer 是瓦片图层,则走瓦片图层独立的拾取逻辑
- if (layer.tileLayer) {
- return layer.tileLayer.pickLayers(target);
+ if (layer.tileLayer && (layer.tileLayer as ITileLayer).pickLayers) {
+ return (layer.tileLayer as ITileLayer).pickLayers(target);
}
layer.hooks.beforePickingEncode.call();
diff --git a/packages/core/src/services/layer/ILayerService.ts b/packages/core/src/services/layer/ILayerService.ts
index 26bf9bd66e..3d9618e6a6 100644
--- a/packages/core/src/services/layer/ILayerService.ts
+++ b/packages/core/src/services/layer/ILayerService.ts
@@ -19,6 +19,7 @@ import {
IPostProcessingPass,
} from '../renderer/IMultiPassRenderer';
import { IRendererService } from '../renderer/IRendererService';
+import { ITexture2D } from '../renderer/ITexture2D';
import { IUniform } from '../renderer/IUniform';
import { ISource, ISourceCFG, ITransform } from '../source/ISourceService';
import {
@@ -82,7 +83,7 @@ export interface ILayerModel {
buildModels(callbackModel: (models: IModel[]) => void): void;
initModels(callbackModel: (models: IModel[]) => void): void;
needUpdate(): boolean;
- clearModels(): void;
+ clearModels(refresh?: boolean): void;
// canvasLayer
clearCanvas?(): void;
@@ -135,8 +136,9 @@ export interface ISubLayerStyles {
* For tile subLayer
*/
export interface ISubLayerInitOptions {
+ usage?: string|undefined;
layerType: string;
- transforms: ITransform[];
+ transforms?: ITransform[];
shape?: string | string[] | IScaleValue;
// options
zIndex: number;
@@ -149,13 +151,16 @@ export interface ISubLayerInitOptions {
opacity: number;
color?: IScaleValue;
+ basemapColor?: string;
size?: IScaleValue;
+ basemapSize?: number;
// raster tiff
domain?: [number, number];
clampLow?: boolean;
clampHigh?: boolean;
rampColors?: IColorRamp;
+ colorTexture?: ITexture2D;
// 在初始化的时候使用
rampColorsData?: ImageData | IImagedata;
@@ -182,11 +187,10 @@ export interface ITilePickManager {
pickRender(layers: ILayer[], target: IInteractionTarget): boolean;
}
-export interface ITileLayerManager {
+export interface IBaseTileLayerManager {
sourceLayer: string;
parent: ILayer;
children: ILayer[];
- tilePickManager: ITilePickManager;
createTile(tile: Tile): { layers: ILayer[]; layerIDList: string[] };
@@ -198,21 +202,26 @@ export interface ITileLayerManager {
clearChild(): void;
hasChild(layer: ILayer): boolean;
render(isPicking?: boolean): void;
-
- pickLayers(target: IInteractionTarget): boolean;
-
updateLayersConfig(layers: ILayer[], key: string, value: any): void;
}
-export interface ITileLayer {
+export interface ITileLayerManager extends IBaseTileLayerManager{
+ tilePickManager: ITilePickManager;
+ pickLayers(target: IInteractionTarget): boolean;
+}
+
+export interface IBaseTileLayer {
type: string;
sourceLayer: string;
parent: ILayer;
- tileLayerManager: ITileLayerManager;
+ tileLayerManager: IBaseTileLayerManager;
tilesetManager: TilesetManager | undefined;
children: ILayer[];
scaleField: any;
render(isPicking?: boolean): void;
+}
+export interface ITileLayer extends IBaseTileLayer{
+ tileLayerManager: ITileLayerManager;
pickLayers(target: IInteractionTarget): boolean;
clearPick(type: string): void;
clearPickState(): void;
@@ -260,7 +269,7 @@ export interface ILayer {
layerModelNeedUpdate: boolean;
styleNeedUpdate: boolean;
layerModel: ILayerModel;
- tileLayer: ITileLayer;
+ tileLayer: IBaseTileLayer;
layerChildren: ILayer[]; // 在图层中添加子图层
masks: ILayer[]; // 图层的 mask 列表
sceneContainer: Container | undefined;
@@ -295,6 +304,7 @@ export interface ILayer {
// 初始化 layer 的时候指定 layer type 类型()兼容空数据的情况
layerType?: string | undefined;
isVector?: boolean;
+ isTileLayer?: boolean;
triangulation?: Triangulation | undefined;
/**
@@ -525,6 +535,7 @@ export interface ILayerConfig {
cursorEnabled?: boolean;
cursor?: string;
forward: boolean; // 正方向
+ usage?: string; // 指定图层的使用类型 - 用户地图底图绘制的优化
/**
* 开启拾取
@@ -580,6 +591,7 @@ export interface ILayerConfig {
/**
* 提供 Layer 管理服务
*/
+
export interface ILayerService {
pickedLayerId: number;
clock: Clock;
@@ -606,7 +618,9 @@ export interface ILayerService {
remove(layer: ILayer, parentLayer?: ILayer): void;
removeAllLayers(): void;
updateLayerRenderList(): void;
- renderLayers(type?: string): void;
+ reRender(): void;
+ throttleRenderLayers(): void;
+ renderLayers(): void;
setEnableRender(flag: boolean): void;
getOESTextureFloat(): boolean;
diff --git a/packages/core/src/services/layer/IStyleAttributeService.ts b/packages/core/src/services/layer/IStyleAttributeService.ts
index b2f505603d..9d054ce1fc 100644
--- a/packages/core/src/services/layer/IStyleAttributeService.ts
+++ b/packages/core/src/services/layer/IStyleAttributeService.ts
@@ -184,10 +184,6 @@ export interface IStyleAttributeUpdateOptions {
}
export interface IStyleAttributeService {
- // registerDefaultStyleOptions(
- // layerName: string,
- // options: ILayerStyleOptions,
- // ): void;
attributesAndIndices: {
attributes: {
[attributeName: string]: IAttribute;
diff --git a/packages/core/src/services/layer/LayerService.ts b/packages/core/src/services/layer/LayerService.ts
index c393860b73..1d938ad0c7 100644
--- a/packages/core/src/services/layer/LayerService.ts
+++ b/packages/core/src/services/layer/LayerService.ts
@@ -4,10 +4,10 @@ import 'reflect-metadata';
import { ILayer } from '../..';
import { TYPES } from '../../types';
import Clock from '../../utils/clock';
-import { IGlobalConfigService } from '../config/IConfigService';
import { IMapService } from '../map/IMapService';
import { IRendererService } from '../renderer/IRendererService';
import { ILayerService } from './ILayerService';
+import { throttle } from 'lodash';
@injectable()
export default class LayerService implements ILayerService {
@@ -38,8 +38,15 @@ export default class LayerService implements ILayerService {
@inject(TYPES.IMapService)
private readonly mapService: IMapService;
- @inject(TYPES.IGlobalConfigService)
- private readonly configService: IGlobalConfigService;
+ public reRender = throttle(() => {
+ this.updateLayerRenderList();
+ this.renderLayers();
+ }, 32)
+
+ public throttleRenderLayers = throttle(() => {
+ this.renderLayers();
+ }, 16)
+
public add(layer: ILayer) {
if (this.sceneInited) {
@@ -92,8 +99,7 @@ export default class LayerService implements ILayerService {
this.layers.splice(layerIndex, 1);
}
if (refresh) {
- this.updateLayerRenderList();
- this.renderLayers();
+ this.throttleRenderLayers();
}
}
@@ -112,7 +118,6 @@ export default class LayerService implements ILayerService {
}
this.updateLayerRenderList();
layer.destroy();
- this.renderLayers();
}
public removeAllLayers() {
@@ -157,18 +162,11 @@ export default class LayerService implements ILayerService {
}
layer.hooks.afterRender.call();
}
-
- // this.layerList.forEach((layer) => {
- // layer.hooks.beforeRenderData.call();
- // layer.hooks.beforeRender.call();
- // layer.render();
- // layer.hooks.afterRender.call();
- // });
this.alreadyInRendering = false;
}
public updateLayerRenderList() {
- // TODO: 每次更新都是从 layers 重新构建
+ // Tip: 每次更新都是从 layers 重新构建
this.layerList = [];
this.layers
.filter((layer) => layer.inited)
diff --git a/packages/core/src/services/layer/StyleAttributeService.ts b/packages/core/src/services/layer/StyleAttributeService.ts
index 8b1a36df50..5c32d77206 100644
--- a/packages/core/src/services/layer/StyleAttributeService.ts
+++ b/packages/core/src/services/layer/StyleAttributeService.ts
@@ -19,10 +19,6 @@ import {
} from './IStyleAttributeService';
import StyleAttribute from './StyleAttribute';
-function sleep(ms: number) {
- return new Promise((resolve) => setTimeout(resolve, ms));
-}
-
const bytesPerElementMap = {
[gl.FLOAT]: 4,
[gl.UNSIGNED_BYTE]: 1,
@@ -351,7 +347,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
vertexIdx, // 当前顶点所在feature索引
normal,
vertexIndex,
- // TODO: 传入顶点索引 vertexIdx
+ // 传入顶点索引 vertexIdx
),
);
} // end if
@@ -475,7 +471,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
vertexIdx, // 当前顶点所在feature索引
normal,
vertexIndex,
- // TODO: 传入顶点索引 vertexIdx
+ // 传入顶点索引 vertexIdx
),
);
} // end if
diff --git a/packages/core/src/services/renderer/IModel.ts b/packages/core/src/services/renderer/IModel.ts
index cb0e31ddad..6f8aeafc02 100644
--- a/packages/core/src/services/renderer/IModel.ts
+++ b/packages/core/src/services/renderer/IModel.ts
@@ -109,6 +109,10 @@ type BlendingFunctionSeparate = Partial<{
}>;
export interface IModelInitializationOptions {
+ /**
+ * 该 model 是否支持拾取
+ */
+ pick?: boolean;
/**
* Shader 字符串,假设此时已经经过 ShaderLib 处理
*/
diff --git a/packages/core/src/services/renderer/IRendererService.ts b/packages/core/src/services/renderer/IRendererService.ts
index 227685d889..31f6a29402 100644
--- a/packages/core/src/services/renderer/IRendererService.ts
+++ b/packages/core/src/services/renderer/IRendererService.ts
@@ -17,7 +17,7 @@ export interface IRenderConfig {
passes?: Array>;
antialias?: boolean;
preserveDrawingBuffer?: boolean;
- // TODO: 场景是否支持 stencil mask
+ // Tip: 场景是否支持 stencil mask
stencil?: boolean;
}
diff --git a/packages/core/src/services/scene/SceneService.ts b/packages/core/src/services/scene/SceneService.ts
index 8146f1ac2b..e154ebc747 100644
--- a/packages/core/src/services/scene/SceneService.ts
+++ b/packages/core/src/services/scene/SceneService.ts
@@ -430,7 +430,7 @@ export default class Scene extends EventEmitter implements ISceneService {
this.fontService.destroy();
this.iconService.destroy();
- // TODO: 销毁 container 容器
+ // 销毁 container 容器
this.$container?.parentNode?.removeChild(this.$container);
this.removeAllListeners();
diff --git a/packages/core/src/shaders/picking.frag.glsl b/packages/core/src/shaders/picking.frag.glsl
index 3cafb2aafc..7afade6481 100644
--- a/packages/core/src/shaders/picking.frag.glsl
+++ b/packages/core/src/shaders/picking.frag.glsl
@@ -56,7 +56,7 @@ vec4 filterPickingColor(vec4 color) {
* highlight color if this item is selected, otherwise unmodified argument.
*/
vec4 filterColor(vec4 color) {
- // TODO: 过滤多余的 shader 计算
+ // 过滤多余的 shader 计算
// return color;
if(u_shaderPick < 0.5) {
return color; // 暂时去除 直接取消计算在选中时拖拽地图会有问题
@@ -67,7 +67,7 @@ vec4 filterColor(vec4 color) {
}
vec4 filterColorAlpha(vec4 color, float alpha) {
- // TODO: 过滤多余的 shader 计算
+ // 过滤多余的 shader 计算
// return color;
if(u_shaderPick < 0.5) {
return color; // 暂时去除 直接取消计算在选中时拖拽地图会有问题
diff --git a/packages/layers/package.json b/packages/layers/package.json
index fcd913255a..1753a93f06 100644
--- a/packages/layers/package.json
+++ b/packages/layers/package.json
@@ -37,6 +37,7 @@
"@turf/meta": "^6.0.2",
"@turf/polygon-to-line": "^6.5.0",
"@turf/union": "^6.5.0",
+ "@turf/clone": "^6.5.0",
"d3-array": "1",
"d3-color": "^1.4.0",
"d3-interpolate": "1.4.0",
diff --git a/packages/layers/src/Geometry/index.ts b/packages/layers/src/Geometry/index.ts
index 008a159c62..e87ae8fce1 100644
--- a/packages/layers/src/Geometry/index.ts
+++ b/packages/layers/src/Geometry/index.ts
@@ -21,11 +21,15 @@ export default class GeometryLayer extends BaseLayer<
this.layerModel = new GeometryModels[modelType](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
diff --git a/packages/layers/src/Geometry/models/billboard.ts b/packages/layers/src/Geometry/models/billboard.ts
index 296429fc97..c9b79cd6e6 100644
--- a/packages/layers/src/Geometry/models/billboard.ts
+++ b/packages/layers/src/Geometry/models/billboard.ts
@@ -142,8 +142,7 @@ export default class BillBoardModel extends BaseModel {
wrapS: gl.CLAMP_TO_EDGE,
wrapT: gl.CLAMP_TO_EDGE,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
}
}
diff --git a/packages/layers/src/Geometry/models/plane.ts b/packages/layers/src/Geometry/models/plane.ts
index 66fa63caea..b1a3ae22d8 100644
--- a/packages/layers/src/Geometry/models/plane.ts
+++ b/packages/layers/src/Geometry/models/plane.ts
@@ -224,8 +224,7 @@ export default class PlaneModel extends BaseModel {
wrapS: gl.CLAMP_TO_EDGE,
wrapT: gl.CLAMP_TO_EDGE,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
};
img.src = mapTexture;
} else {
@@ -299,7 +298,7 @@ export default class PlaneModel extends BaseModel {
},
);
this.layer.updateModelData(modelData as IAttrubuteAndElements);
- this.layerService.renderLayers();
+ this.layerService.throttleRenderLayers();
}
/**
diff --git a/packages/layers/src/Geometry/models/sprite.ts b/packages/layers/src/Geometry/models/sprite.ts
index 94df676fd9..869f561c58 100644
--- a/packages/layers/src/Geometry/models/sprite.ts
+++ b/packages/layers/src/Geometry/models/sprite.ts
@@ -100,7 +100,7 @@ export default class SpriteModel extends BaseModel {
this.layer.models.map((m) => {
m.updateAttributes(attributes);
});
- this.layer.renderLayers();
+ this.layerService.throttleRenderLayers();
this.timer = requestAnimationFrame(this.updateModel);
};
@@ -213,8 +213,7 @@ export default class SpriteModel extends BaseModel {
wrapS: gl.CLAMP_TO_EDGE,
wrapT: gl.CLAMP_TO_EDGE,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
};
img.src = mapTexture;
} else {
diff --git a/packages/layers/src/canvas/index.ts b/packages/layers/src/canvas/index.ts
index 981da540f9..36c1030cdf 100644
--- a/packages/layers/src/canvas/index.ts
+++ b/packages/layers/src/canvas/index.ts
@@ -1,19 +1,53 @@
import BaseLayer from '../core/BaseLayer';
+import { ILayer } from '@antv/l7-core';
import { ICanvasLayerStyleOptions } from '../core/interface';
import CanvasModels, { CanvasModelType } from './models/index';
export default class CanvasLayer extends BaseLayer {
public type: string = 'CanvasLayer';
+ public forceRender: boolean = true;
public buildModels() {
const modelType = this.getModelType();
this.layerModel = new CanvasModels[modelType](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
+
+ public hide(): ILayer {
+ // 清除画布
+ this.layerModel.clearCanvas && this.layerModel?.clearCanvas();
+
+ this.updateLayerConfig({
+ visible: false,
+ });
+ this.reRender();
+ return this;
+ }
+
+ public renderModels() {
+ if (this?.layerModel?.renderUpdate) {
+ this.layerModel.renderUpdate();
+ }
+
+ this.models.forEach((model) => {
+ model.draw(
+ {
+ uniforms: this.layerModel.getUninforms(),
+ },
+ false,
+ );
+ });
+ return this;
+ }
+
protected getConfigSchema() {
return {
properties: {
diff --git a/packages/layers/src/citybuliding/building.ts b/packages/layers/src/citybuliding/building.ts
index bbc3d34371..9e95f17ff4 100644
--- a/packages/layers/src/citybuliding/building.ts
+++ b/packages/layers/src/citybuliding/building.ts
@@ -7,11 +7,15 @@ export default class CityBuildingLayer extends BaseLayer {
this.layerModel = new CityBuildModel(this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
public setLight(t: number) {
this.updateLayerConfig({
diff --git a/packages/layers/src/citybuliding/models/build.ts b/packages/layers/src/citybuliding/models/build.ts
index b3a1e5211a..b4874c8773 100644
--- a/packages/layers/src/citybuliding/models/build.ts
+++ b/packages/layers/src/citybuliding/models/build.ts
@@ -4,20 +4,7 @@ import BaseModel from '../../core/BaseModel';
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
import buildFrag from '../shaders/build_frag.glsl';
import buildVert from '../shaders/build_vert.glsl';
-interface ICityBuildLayerStyleOptions {
- opacity: number;
- baseColor: string;
- brightColor: string;
- windowColor: string;
- time: number;
- sweep: {
- enable: boolean;
- sweepRadius: number;
- sweepColor: string;
- sweepSpeed: number;
- sweepCenter?: [number, number];
- };
-}
+import { ICityBuildLayerStyleOptions } from '../../core/interface';
export default class CityBuildModel extends BaseModel {
private cityCenter: [number, number];
private cityMinSize: number;
@@ -145,9 +132,6 @@ export default class CityBuildModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 10 } = feature;
return Array.isArray(size) ? [size[0]] : [size as number];
@@ -170,9 +154,7 @@ export default class CityBuildModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
- const { size } = feature;
return [vertex[3], vertex[4]];
},
},
diff --git a/packages/layers/src/core/BaseLayer.ts b/packages/layers/src/core/BaseLayer.ts
index 1e3772bdba..6a6ea21416 100644
--- a/packages/layers/src/core/BaseLayer.ts
+++ b/packages/layers/src/core/BaseLayer.ts
@@ -139,10 +139,10 @@ export default class BaseLayer
values: any;
};
- // TODO: 记录 sceneContainer 供创建子图层的时候使用 如 imageTileLayer
+ // 记录 sceneContainer 供创建子图层的时候使用 如 imageTileLayer
public sceneContainer: Container | undefined;
public tileLayer: any | undefined;
- // TODO: 用于保存子图层对象
+ // 用于保存子图层对象
public layerChildren: ILayer[] = [];
public masks: ILayer[] = [];
// Tip: 用于标识矢量图层
@@ -187,7 +187,7 @@ export default class BaseLayer
/**
* 图层容器
*/
- private container: Container;
+ protected container: Container;
private encodedData: IEncodeFeature[];
@@ -195,14 +195,14 @@ export default class BaseLayer
private currentPickId: number | null = null;
- private rawConfig: Partial;
+ protected rawConfig: Partial;
private needUpdateConfig: Partial;
/**
* 待更新样式属性,在初始化阶段完成注册
*/
- private pendingStyleAttributes: Array<{
+ protected pendingStyleAttributes: Array<{
attributeName: string;
attributeField: StyleAttributeField;
attributeValues?: StyleAttributeOption;
@@ -216,7 +216,7 @@ export default class BaseLayer
private aniamateStatus: boolean = false;
- // TODO: layer 保底颜色
+ // Tip: layer 保底颜色
private bottomColor = 'rgba(0, 0, 0, 0)';
private isDestroied: boolean = false;
@@ -496,16 +496,7 @@ export default class BaseLayer
values?: StyleAttributeOption,
updateOptions?: Partial,
) {
- // 设置 color、size、shape、style 时由于场景服务尚未完成(并没有调用 scene.addLayer),因此暂时加入待更新属性列表
this.updateStyleAttribute('color', field, values, updateOptions);
-
- // this.pendingStyleAttributes.push({
- // attributeName: 'color',
- // attributeField: field,
- // attributeValues: values,
- // defaultName: 'colors',
- // updateOptions,
- // });
return this;
}
@@ -559,7 +550,7 @@ export default class BaseLayer
values,
};
this.updateStyleAttribute('shape', field, values, updateOptions);
- // TODO: 根据 shape 判断是否需要更新 model
+ // Tip: 根据 shape 判断是否需要更新 model
if (!this.tileLayer) {
updateShape(this, lastShape, currentShape);
}
@@ -691,11 +682,12 @@ export default class BaseLayer
}
public render(): ILayer {
- if (this.tileLayer !== undefined) {
+ if (this.tileLayer) {
// 瓦片图层执行单独的 render 渲染队列
this.tileLayer.render();
return this;
}
+
if (this.encodeDataLength <= 0 && !this.forceRender) return this;
// Tip: this.getEncodedData().length !== 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
this.renderModels();
@@ -841,10 +833,6 @@ export default class BaseLayer
}
public hide(): ILayer {
- if (this.type === 'CanvasLayer' && this.layerModel.clearCanvas) {
- // 对 canvasLayer 的 hide 操作做特殊处理
- this.layerModel.clearCanvas();
- }
this.updateLayerConfig({
visible: false,
});
@@ -981,19 +969,19 @@ export default class BaseLayer
}
// remove child layer
- this.layerChildren.map((child: ILayer) => child.destroy());
+ this.layerChildren.map((child: ILayer) => child.destroy(false));
this.layerChildren = [];
// remove mask list
- this.masks.map((mask: ILayer) => mask.destroy());
+ this.masks.map((mask: ILayer) => mask.destroy(false));
this.masks = [];
this.hooks.beforeDestroy.call();
// 清除sources事件
this.layerSource.off('sourceUpdate', this.sourceEvent);
- this.multiPassRenderer.destroy();
- // console.log(this.styleAttributeService.getAttributes())
+ this.multiPassRenderer?.destroy();
+
// 清除所有属性以及关联的 vao == 销毁所有 => model this.models.forEach((model) => model.destroy());
this.styleAttributeService.clearAllAttributes();
@@ -1001,8 +989,8 @@ export default class BaseLayer
this.hooks.afterDestroy.call();
- // TODO: 清除各个图层自定义的 models 资源
- this.layerModel?.clearModels();
+ // Tip: 清除各个图层自定义的 models 资源
+ this.layerModel?.clearModels(refresh);
this.models = [];
@@ -1170,56 +1158,58 @@ export default class BaseLayer
const { vs, fs, uniforms } = this.shaderModuleService.getModule(moduleName);
const { createModel } = this.rendererService;
return new Promise((resolve, reject) => {
- // filter supported worker & worker enabled layer
- if (
- workerOptions &&
- workerOptions.modelType in WorkerSourceMap &&
- workerEnabled
- ) {
- this.styleAttributeService
- .createAttributesAndIndicesAscy(
+ setTimeout(() => {
+ // filter supported worker & worker enabled layer
+ if (
+ workerOptions &&
+ workerOptions.modelType in WorkerSourceMap &&
+ workerEnabled
+ ) {
+ this.styleAttributeService
+ .createAttributesAndIndicesAscy(
+ this.encodedData,
+ segmentNumber,
+ workerOptions,
+ )
+ .then(({ attributes, elements }) => {
+ const m = createModel({
+ attributes,
+ uniforms,
+ fs,
+ vs,
+ elements,
+ blend: BlendTypes[BlendType.normal],
+ ...rest,
+ });
+ resolve(m);
+ })
+ .catch((err) => reject(err));
+ } else {
+ const {
+ attributes,
+ elements,
+ count,
+ } = this.styleAttributeService.createAttributesAndIndices(
this.encodedData,
+ triangulation,
segmentNumber,
- workerOptions,
- )
- .then(({ attributes, elements }) => {
- const m = createModel({
- attributes,
- uniforms,
- fs,
- vs,
- elements,
- blend: BlendTypes[BlendType.normal],
- ...rest,
- });
- resolve(m);
- })
- .catch((err) => reject(err));
- } else {
- const {
- attributes,
- elements,
- count,
- } = this.styleAttributeService.createAttributesAndIndices(
- this.encodedData,
- triangulation,
- segmentNumber,
- );
- const modeloptions = {
- attributes,
- uniforms,
- fs,
- vs,
- elements,
- blend: BlendTypes[BlendType.normal],
- ...rest,
- };
- if (count) {
- modeloptions.count = count;
+ );
+ const modeloptions = {
+ attributes,
+ uniforms,
+ fs,
+ vs,
+ elements,
+ blend: BlendTypes[BlendType.normal],
+ ...rest,
+ };
+ if (count) {
+ modeloptions.count = count;
+ }
+ const m = createModel(modeloptions);
+ resolve(m);
}
- const m = createModel(modeloptions);
- resolve(m);
- }
+ });
});
}
@@ -1258,6 +1248,9 @@ export default class BaseLayer
}
public needPick(type: string): boolean {
+ // 地图图层的判断
+ if (this.rawConfig.usage === 'basemap') return false;
+
const {
enableHighlight = true,
enableSelect = true,
@@ -1295,7 +1288,6 @@ export default class BaseLayer
public renderModels(isPicking?: boolean) {
// TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
if (this.encodeDataLength <= 0 && !this.forceRender) return this;
-
if (this.layerModelNeedUpdate && this.layerModel) {
this.layerModel.buildModels((models: IModel[]) => {
this.models = models;
@@ -1303,9 +1295,6 @@ export default class BaseLayer
this.layerModelNeedUpdate = false;
});
}
- if (this?.layerModel?.renderUpdate) {
- this.layerModel.renderUpdate();
- }
this.models.forEach((model) => {
model.draw(
@@ -1360,6 +1349,7 @@ export default class BaseLayer
* 继承空方法
* @param time
*/
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public setEarthTime(time: number) {
console.warn('empty fn');
}
@@ -1375,24 +1365,19 @@ export default class BaseLayer
return {};
}
- private sourceEvent = () => {
+ protected sourceEvent = () => {
this.dataState.dataSourceNeedUpdate = true;
const layerConfig = this.getLayerConfig();
if (layerConfig && layerConfig.autoFit) {
this.fitBounds(layerConfig.fitBoundsOptions);
}
- // 对外暴露事件 迁移到 DataMappingPlugin generateMapping,保证在重新重新映射后触发
- // this.emit('dataUpdate');
this.reRender();
};
- private reRender() {
- if (this.inited) {
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
- }
+ protected reRender() {
+ this.inited && this.layerService.reRender();
}
- private splitValuesAndCallbackInAttribute(
+ protected splitValuesAndCallbackInAttribute(
valuesOrCallback?: unknown[],
defaultValues?: unknown[],
) {
diff --git a/packages/layers/src/core/BaseModel.ts b/packages/layers/src/core/BaseModel.ts
index 5531a8c3d7..7c1739eca9 100644
--- a/packages/layers/src/core/BaseModel.ts
+++ b/packages/layers/src/core/BaseModel.ts
@@ -259,7 +259,7 @@ export default class BaseModel
* @returns
*/
public dataTextureNeedUpdate(options: {
- // TODO: thetaOffset 目前只有 lineLayer/arc 使用
+ // thetaOffset 目前只有 lineLayer/arc 使用
thetaOffset?: styleSingle;
opacity?: styleSingle;
strokeOpacity?: styleSingle;
@@ -514,13 +514,16 @@ export default class BaseModel
public needUpdate(): boolean {
return false;
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public buildModels(callbackModel: (models: IModel[]) => void): void {
throw new Error('Method not implemented.');
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public initModels(callbackModel: (models: IModel[]) => void): void {
throw new Error('Method not implemented.');
}
- public clearModels() {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ public clearModels(refresh = true) {
return;
}
public getAttribute(): {
diff --git a/packages/layers/src/core/interface.ts b/packages/layers/src/core/interface.ts
index b31f5e3183..8c16fa88e6 100644
--- a/packages/layers/src/core/interface.ts
+++ b/packages/layers/src/core/interface.ts
@@ -1,4 +1,4 @@
-import { IAnimateOption, IMapService } from '@antv/l7-core';
+import { IAnimateOption, IMapService, ITexture2D } from '@antv/l7-core';
import { IColorRamp, IImagedata } from '@antv/l7-utils';
import { styleOffset } from '../core/BaseModel';
import { anchorType } from '../utils/symbol-layout';
@@ -41,6 +41,10 @@ export interface IBaseLayerStyleOptions {
// 蒙层
mask?: boolean; // 可选参数 时候允许蒙层
maskInside?: boolean; // 可选参数 控制图层是否显示在蒙层的内部
+
+ usage?: string;
+ color?: string;
+ size?: number;
}
export interface ILineLayerStyleOptions extends IBaseLayerStyleOptions {
@@ -159,6 +163,7 @@ export interface IRasterTileLayerStyleOptions extends IBaseLayerStyleOptions {
export interface IMaskLayerStyleOptions extends IBaseLayerStyleOptions {
// define
opacity: number;
+ color: string;
}
export interface IWindLayerStyleOptions extends IBaseLayerStyleOptions {
@@ -184,6 +189,7 @@ export interface IImageLayerStyleOptions extends IBaseLayerStyleOptions {
clampHigh?: boolean;
rampColors?: IColorRamp;
rampColorsData?: ImageData | IImagedata;
+ colorTexture?: ITexture2D;
pixelConstant?: number;
pixelConstantR?: number;
pixelConstantG?: number;
@@ -191,6 +197,21 @@ export interface IImageLayerStyleOptions extends IBaseLayerStyleOptions {
pixelConstantRGB?: number;
}
+export interface ICityBuildLayerStyleOptions {
+ opacity: number;
+ baseColor: string;
+ brightColor: string;
+ windowColor: string;
+ time: number;
+ sweep: {
+ enable: boolean;
+ sweepRadius: number;
+ sweepColor: string;
+ sweepSpeed: number;
+ sweepCenter?: [number, number];
+ };
+}
+
export interface IGeometryLayerStyleOptions extends IBaseLayerStyleOptions {
mapTexture?: string;
terrainTexture?: string;
diff --git a/packages/layers/src/core/triangulation.ts b/packages/layers/src/core/triangulation.ts
index 63409da3f0..71130bd2dd 100644
--- a/packages/layers/src/core/triangulation.ts
+++ b/packages/layers/src/core/triangulation.ts
@@ -147,7 +147,15 @@ export function LineTriangulation(feature: IEncodeFeature) {
export function SimpleLineTriangulation(feature: IEncodeFeature) {
const { coordinates } = feature;
const pos: any[] = [];
-
+ if (!Array.isArray(coordinates[0])) {
+ return {
+ vertices: [],
+ indices: [],
+ normals: [],
+ size: 6,
+ count: 0,
+ };
+ }
const { results, totalDistance } = getSimpleLineVertices(
coordinates as IPosition[],
);
@@ -164,17 +172,43 @@ export function SimpleLineTriangulation(feature: IEncodeFeature) {
};
}
+export function TileSimpleLineTriangulation(feature: IEncodeFeature) {
+ const { coordinates } = feature;
+ const pos: any[] = [];
+ if (!Array.isArray(coordinates[0])) {
+ return {
+ vertices: [],
+ indices: [],
+ size: 4,
+ count: 0,
+ };
+ }
+ const { results } = getTileSimpleLineVertices(coordinates as IPosition[]);
+ results.map((point) => {
+ pos.push(point[0], point[1], point[2], point[3]);
+ });
+
+ return {
+ vertices: pos,
+ indices: [],
+ size: 4,
+ count: results.length,
+ };
+}
+
function lineSegmentDistance(b1: number[], a1: number[]) {
const dx = a1[0] - b1[0];
const dy = a1[1] - b1[1];
return Math.sqrt(dx * dx + dy * dy);
}
-function pushDis(point: number[], n: number) {
+function pushDis(point: number[], n?: number) {
if (point.length < 3) {
point.push(0);
}
- point.push(n);
+ if (n !== undefined) {
+ point.push(n);
+ }
return point;
}
@@ -212,6 +246,28 @@ function getSimpleLineVertices(points: number[][]) {
}
}
+function getTileSimpleLineVertices(points: number[][]) {
+ if (points.length < 2) {
+ return {
+ results: points,
+ };
+ } else {
+ const results: number[][] = [];
+ const point = pushDis(points[0]);
+ results.push(point);
+
+ for (let i = 1; i < points.length - 1; i++) {
+ const mulPoint = pushDis(points[i]);
+ results.push(mulPoint);
+ results.push(mulPoint);
+ }
+ results.push(pushDis(points[points.length - 1]));
+ return {
+ results,
+ };
+ }
+}
+
export function polygonTriangulation(feature: IEncodeFeature) {
const { coordinates } = feature;
const flattengeo = earcut.flatten(coordinates as number[][][]);
@@ -223,7 +279,7 @@ export function polygonTriangulation(feature: IEncodeFeature) {
};
}
-// TODO:构建几何图形(带有中心点和大小)
+// 构建几何图形(带有中心点和大小)
export function polygonTriangulationWithCenter(feature: IEncodeFeature) {
const { coordinates } = feature;
const flattengeo = earcut.flatten(coordinates as number[][][]);
diff --git a/packages/layers/src/earth/index.ts b/packages/layers/src/earth/index.ts
index 4cdf996769..f17c7e61a7 100644
--- a/packages/layers/src/earth/index.ts
+++ b/packages/layers/src/earth/index.ts
@@ -38,7 +38,8 @@ export default class EarthLayer extends BaseLayer {
this.layerModel = new EarthModels[shape](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
diff --git a/packages/layers/src/earth/models/base.ts b/packages/layers/src/earth/models/base.ts
index f84b78be5c..ce681673fa 100644
--- a/packages/layers/src/earth/models/base.ts
+++ b/packages/layers/src/earth/models/base.ts
@@ -57,7 +57,7 @@ export default class BaseEarthModel extends BaseModel {
this.sunX = Math.cos(this.earthTime) * (this.sunRadius - this.sunY);
this.sunZ = Math.sin(this.earthTime) * (this.sunRadius - this.sunY);
- this.layerService.renderLayers();
+ this.layerService.throttleRenderLayers();
}
public initModels(callbackModel: (models: IModel[]) => void) {
@@ -78,8 +78,7 @@ export default class BaseEarthModel extends BaseModel {
width: imageData[0].width,
height: imageData[0].height,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
});
this.buildModels(callbackModel);
diff --git a/packages/layers/src/earth/shaders/atmosphere_frag.glsl b/packages/layers/src/earth/shaders/atmosphere_frag.glsl
index 1d288be36f..307768695c 100644
--- a/packages/layers/src/earth/shaders/atmosphere_frag.glsl
+++ b/packages/layers/src/earth/shaders/atmosphere_frag.glsl
@@ -10,7 +10,7 @@ void main() {
// float intensity = pow(0.5 + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);
float intensity = pow(v_offset + dot(normalize(vVertexNormal), normalize(u_CameraPosition)), 3.0);
- // TODO: 去除背面
+ // 去除背面
if(intensity > 1.0) intensity = 0.0;
gl_FragColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);
diff --git a/packages/layers/src/earth/shaders/bloomsphere_frag.glsl b/packages/layers/src/earth/shaders/bloomsphere_frag.glsl
index ee8ad4e5d1..9711824fb4 100644
--- a/packages/layers/src/earth/shaders/bloomsphere_frag.glsl
+++ b/packages/layers/src/earth/shaders/bloomsphere_frag.glsl
@@ -8,7 +8,7 @@ void main() {
float intensity = - dot(normalize(vVertexNormal), normalize(u_CameraPosition));
- // TODO: 去除背面
+ // 去除背面
if(intensity > 1.0) intensity = 0.0;
gl_FragColor = vec4(v_Color.rgb, v_Color.a * intensity * u_opacity);
diff --git a/packages/layers/src/heatmap/index.ts b/packages/layers/src/heatmap/index.ts
index 0388e0e2f4..3b5578eb46 100644
--- a/packages/layers/src/heatmap/index.ts
+++ b/packages/layers/src/heatmap/index.ts
@@ -10,11 +10,15 @@ export default class HeatMapLayer extends BaseLayer {
this.layerModel = new HeatMapModels[shape](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
public renderModels() {
const shape = this.getModelType();
diff --git a/packages/layers/src/heatmap/models/heatmap.ts b/packages/layers/src/heatmap/models/heatmap.ts
index 7f2f65008c..163eba7d48 100644
--- a/packages/layers/src/heatmap/models/heatmap.ts
+++ b/packages/layers/src/heatmap/models/heatmap.ts
@@ -63,10 +63,8 @@ export default class HeatMapModel extends BaseModel {
public async initModels(callbackModel: (models: IModel[]) => void) {
const {
createFramebuffer,
- clear,
getViewportSize,
createTexture2D,
- useFramebuffer,
} = this.rendererService;
const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(
'shape',
@@ -177,6 +175,7 @@ export default class HeatMapModel extends BaseModel {
dstAlpha: 1,
},
},
+ pick: false
});
return model;
}
@@ -201,6 +200,7 @@ export default class HeatMapModel extends BaseModel {
createModel,
} = this.rendererService;
return createModel({
+ pick: false,
vs,
fs,
attributes: {
diff --git a/packages/layers/src/image/index.ts b/packages/layers/src/image/index.ts
index 9e26e64ca2..513b64dd68 100644
--- a/packages/layers/src/image/index.ts
+++ b/packages/layers/src/image/index.ts
@@ -8,11 +8,15 @@ export default class ImageLayer extends BaseLayer {
this.layerModel = new ImageModels[modelType](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
return {
@@ -30,6 +34,7 @@ export default class ImageLayer extends BaseLayer {
const defaultConfig = {
image: {},
dataImage: {},
+ tileDataImage: {},
};
return defaultConfig[type];
}
@@ -43,6 +48,8 @@ export default class ImageLayer extends BaseLayer {
return 'dataImage';
} else if (shape === 'image') {
return 'image';
+ } else if (shape === 'tileDataImage') {
+ return 'tileDataImage';
} else {
return 'image';
}
diff --git a/packages/layers/src/image/models/dataImage.ts b/packages/layers/src/image/models/dataImage.ts
index 213ab384a7..9801101d8f 100644
--- a/packages/layers/src/image/models/dataImage.ts
+++ b/packages/layers/src/image/models/dataImage.ts
@@ -6,7 +6,7 @@ import {
IModelUniform,
ITexture2D,
} from '@antv/l7-core';
-import { generateColorRamp, getMask, IColorRamp, isMini } from '@antv/l7-utils';
+import { generateColorRamp, getMask, IColorRamp } from '@antv/l7-utils';
import { isEqual } from 'lodash';
import BaseModel from '../../core/BaseModel';
import { IImageLayerStyleOptions } from '../../core/interface';
@@ -70,35 +70,16 @@ export default class ImageDataModel extends BaseModel {
width: 0,
});
- if (isMini) {
- // @ts-ignore
- const canvas = this.layerService.sceneService.getSceneConfig().canvas;
- const img = canvas.createImage();
- img.crossOrigin = 'anonymous';
- img.src = source.data.originData;
-
- img.onload = () => {
+ source.data.images.then(
+ (imageData: Array) => {
this.texture = createTexture2D({
- data: img,
- width: img.width,
- height: img.height,
+ data: imageData[0],
+ width: imageData[0].width,
+ height: imageData[0].height,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
- };
- } else {
- source.data.images.then(
- (imageData: Array) => {
- this.texture = createTexture2D({
- data: imageData[0],
- width: imageData[0].width,
- height: imageData[0].height,
- });
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
- },
- );
- }
+ this.layerService.reRender();
+ },
+ );
const rampImageData = rampColorsData
? rampColorsData
@@ -120,6 +101,7 @@ export default class ImageDataModel extends BaseModel {
depth: { enable: false },
blend: this.getBlend(),
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
@@ -152,14 +134,12 @@ export default class ImageDataModel extends BaseModel {
}
protected registerBuiltinAttributes() {
- // point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'uv',
type: AttributeType.Attribute,
descriptor: {
name: 'a_Uv',
buffer: {
- // give the WebGL driver a hint that this buffer may change
usage: gl.DYNAMIC_DRAW,
data: [],
type: gl.FLOAT,
@@ -169,7 +149,6 @@ export default class ImageDataModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[3], vertex[4]];
},
diff --git a/packages/layers/src/image/models/image.ts b/packages/layers/src/image/models/image.ts
index bc27fb4b22..2ec12a82d8 100644
--- a/packages/layers/src/image/models/image.ts
+++ b/packages/layers/src/image/models/image.ts
@@ -49,8 +49,7 @@ export default class ImageModel extends BaseModel {
width: img.width,
height: img.height,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
};
} else {
source.data.images.then(
@@ -62,8 +61,7 @@ export default class ImageModel extends BaseModel {
mag: gl.LINEAR,
min: gl.LINEAR,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
},
);
}
@@ -81,6 +79,7 @@ export default class ImageModel extends BaseModel {
},
depth: { enable: false },
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
diff --git a/packages/layers/src/image/models/index.ts b/packages/layers/src/image/models/index.ts
index d2753e18b5..2242c88bbf 100644
--- a/packages/layers/src/image/models/index.ts
+++ b/packages/layers/src/image/models/index.ts
@@ -1,10 +1,12 @@
import DataImageModel from './dataImage';
import ImageModel from './image';
-export type ImageModelType = 'image' | 'dataImage';
+import TileDataImageModel from './tileDataImage';
+export type ImageModelType = 'image' | 'dataImage' | 'tileDataImage';
const ImageModels: { [key in ImageModelType]: any } = {
image: ImageModel,
dataImage: DataImageModel,
+ tileDataImage: TileDataImageModel,
};
export default ImageModels;
diff --git a/packages/layers/src/image/models/tileDataImage.ts b/packages/layers/src/image/models/tileDataImage.ts
new file mode 100644
index 0000000000..6bfa3100db
--- /dev/null
+++ b/packages/layers/src/image/models/tileDataImage.ts
@@ -0,0 +1,143 @@
+import {
+ AttributeType,
+ gl,
+ IEncodeFeature,
+ IModel,
+ IModelUniform,
+ ITexture2D,
+} from '@antv/l7-core';
+import { getMask } from '@antv/l7-utils';
+import BaseModel from '../../core/BaseModel';
+import { IImageLayerStyleOptions } from '../../core/interface';
+import { RasterImageTriangulation } from '../../core/triangulation';
+import ImageFrag from '../shaders/dataImage_frag.glsl';
+import ImageVert from '../shaders/image_vert.glsl';
+
+export default class ImageDataModel extends BaseModel {
+ protected texture: ITexture2D;
+ public getUninforms(): IModelUniform {
+ const { createTexture2D } = this.rendererService;
+ const {
+ opacity,
+ clampLow = true,
+ clampHigh = true,
+ noDataValue = -9999999,
+ domain = [0, 1],
+
+ colorTexture = createTexture2D({
+ height: 0,
+ width: 0,
+ }),
+ pixelConstant = 0.0,
+ pixelConstantR = 256 * 256,
+ pixelConstantG = 256,
+ pixelConstantB = 1,
+ pixelConstantRGB = 0.1,
+ } = this.layer.getLayerConfig() as IImageLayerStyleOptions;
+
+ return {
+ u_opacity: opacity || 1,
+ u_texture: this.texture,
+
+ u_pixelConstant: pixelConstant,
+ u_pixelConstantR: pixelConstantR,
+ u_pixelConstantG: pixelConstantG,
+ u_pixelConstantB: pixelConstantB,
+ u_pixelConstantRGB: pixelConstantRGB,
+
+ u_domain: domain,
+ u_clampLow: clampLow,
+ u_clampHigh: typeof clampHigh !== 'undefined' ? clampHigh : clampLow,
+ u_noDataValue: noDataValue,
+ u_colorTexture: colorTexture,
+ };
+ }
+ public initModels(callbackModel: (models: IModel[]) => void) {
+ const {
+ mask = false,
+ maskInside = true,
+ } = this.layer.getLayerConfig() as IImageLayerStyleOptions;
+
+ const source = this.layer.getSource();
+ const { createTexture2D } = this.rendererService;
+ this.texture = createTexture2D({
+ height: 0,
+ width: 0,
+ });
+
+ source.data.images.then(
+ (imageData: Array) => {
+ this.texture = createTexture2D({
+ data: imageData[0],
+ width: imageData[0].width,
+ height: imageData[0].height,
+ });
+ this.layerService.reRender();
+ },
+ );
+
+
+ this.layer
+ .buildLayerModel({
+ moduleName: 'RasterTileDataImage',
+ vertexShader: ImageVert,
+ fragmentShader: ImageFrag,
+ triangulation: RasterImageTriangulation,
+ primitive: gl.TRIANGLES,
+ depth: { enable: false },
+ blend: this.getBlend(),
+ stencil: getMask(mask, maskInside),
+ pick: false,
+ })
+ .then((model) => {
+ callbackModel([model]);
+ })
+ .catch((err) => {
+ console.warn(err);
+ callbackModel([]);
+ });
+ }
+
+ public clearModels(): void {
+ this.texture?.destroy();
+ }
+
+ public buildModels(callbackModel: (models: IModel[]) => void) {
+ this.initModels(callbackModel);
+ }
+
+ protected getConfigSchema() {
+ return {
+ properties: {
+ opacity: {
+ type: 'number',
+ minimum: 0,
+ maximum: 1,
+ },
+ },
+ };
+ }
+
+ protected registerBuiltinAttributes() {
+ this.styleAttributeService.registerStyleAttribute({
+ name: 'uv',
+ type: AttributeType.Attribute,
+ descriptor: {
+ name: 'a_Uv',
+ buffer: {
+ usage: gl.DYNAMIC_DRAW,
+ data: [],
+ type: gl.FLOAT,
+ },
+ size: 2,
+ update: (
+ feature: IEncodeFeature,
+ featureIdx: number,
+ vertex: number[],
+ ) => {
+ return [vertex[3], vertex[4]];
+ },
+ },
+ });
+ }
+}
diff --git a/packages/layers/src/line/index.ts b/packages/layers/src/line/index.ts
index c77306789d..98066a1c6f 100644
--- a/packages/layers/src/line/index.ts
+++ b/packages/layers/src/line/index.ts
@@ -5,6 +5,7 @@ import { isVectorTile } from '../tile/utils';
export default class LineLayer extends BaseLayer {
public type: string = 'LineLayer';
+ public arrowInsertCount: number = 0;
public defaultSourceConfig = {
data: [
{
@@ -30,11 +31,15 @@ export default class LineLayer extends BaseLayer {
this.layerModel = new LineModels[shape](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
diff --git a/packages/layers/src/line/models/arc.ts b/packages/layers/src/line/models/arc.ts
index ab129e0526..daa16e5608 100644
--- a/packages/layers/src/line/models/arc.ts
+++ b/packages/layers/src/line/models/arc.ts
@@ -179,7 +179,7 @@ export default class ArcModel extends BaseModel {
maskInside = true,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
const { frag, vert, type } = this.getShaders();
-
+ //
this.layer
.buildLayerModel({
moduleName: 'lineArc2d' + type,
diff --git a/packages/layers/src/line/models/half.ts b/packages/layers/src/line/models/half.ts
index c92d9aca1e..5abc643946 100644
--- a/packages/layers/src/line/models/half.ts
+++ b/packages/layers/src/line/models/half.ts
@@ -173,11 +173,7 @@ export default class LineModel extends BaseModel {
size: 4,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
- // console.log(feature)
const startPoint = (feature.coordinates[0] || [0, 0]) as number[];
const endPoint = (feature.coordinates[3] || [0, 0]) as number[];
@@ -200,9 +196,6 @@ export default class LineModel extends BaseModel {
size: 2,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 1 } = feature;
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
@@ -251,7 +244,6 @@ export default class LineModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[4]];
},
diff --git a/packages/layers/src/line/models/line.ts b/packages/layers/src/line/models/line.ts
index 9db3291346..1163c007aa 100644
--- a/packages/layers/src/line/models/line.ts
+++ b/packages/layers/src/line/models/line.ts
@@ -173,6 +173,7 @@ export default class LineModel extends BaseModel {
enablePicking,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
const { frag, vert, type } = this.getShaders();
+ // console.log(frag)
this.layer.triangulation = LineTriangulation;
this.layer
.buildLayerModel({
@@ -277,7 +278,6 @@ export default class LineModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[5]];
},
@@ -298,9 +298,6 @@ export default class LineModel extends BaseModel {
size: 2,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 1 } = feature;
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
@@ -349,7 +346,6 @@ export default class LineModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[4]];
},
@@ -370,9 +366,6 @@ export default class LineModel extends BaseModel {
size: 2,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const iconMap = this.iconService.getIconMap();
const { texture } = feature;
diff --git a/packages/layers/src/line/models/simpleLine.ts b/packages/layers/src/line/models/simpleLine.ts
index 19ff3df987..fe6f9d0e89 100644
--- a/packages/layers/src/line/models/simpleLine.ts
+++ b/packages/layers/src/line/models/simpleLine.ts
@@ -125,6 +125,7 @@ export default class SimpleLineModel extends BaseModel {
depth: { enable: false },
blend: this.getBlend(),
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
diff --git a/packages/layers/src/line/models/simpleTileLine.ts b/packages/layers/src/line/models/simpleTileLine.ts
new file mode 100644
index 0000000000..74e5f301a2
--- /dev/null
+++ b/packages/layers/src/line/models/simpleTileLine.ts
@@ -0,0 +1,65 @@
+import {
+ gl,
+ IModel,
+ IModelUniform,
+} from '@antv/l7-core';
+import { getMask, rgb2arr } from '@antv/l7-utils';
+import { isNumber } from 'lodash';
+import BaseModel from '../../core/BaseModel';
+import { ILineLayerStyleOptions } from '../../core/interface';
+import { TileSimpleLineTriangulation } from '../../core/triangulation';
+import simple_line_frag from '../../shader/minify_frag.glsl';
+import simple_line_vert from '../shaders/tile/simpleline_vert.glsl';
+
+import simple_line_map_frag from '../../shader/minify_frag.glsl';
+import simple_line_map_vert from '../shaders/tile/simpleline_map_vert.glsl';
+export default class SimpleTileLineModel extends BaseModel {
+ public getUninforms(): IModelUniform {
+ const {
+ opacity = 1,
+ usage,
+ color = '#fff'
+ } = this.layer.getLayerConfig() as ILineLayerStyleOptions;
+ return {
+ u_opacity: isNumber(opacity) ? opacity : 1.0,
+ u_color: usage === 'basemap' ? rgb2arr(color): [0, 0, 0, 0]
+ };
+ }
+
+ public initModels(callbackModel: (models: IModel[]) => void) {
+ this.buildModels(callbackModel);
+ }
+
+ public clearModels() {
+ }
+
+ public buildModels(callbackModel: (models: IModel[]) => void) {
+ const {
+ mask = false,
+ maskInside = true,
+ usage
+ } = this.layer.getLayerConfig() as ILineLayerStyleOptions;
+ this.layer
+ .buildLayerModel({
+ moduleName: 'lineTileSimpleNormal_' + usage,
+ vertexShader: usage === 'basemap' ? simple_line_map_vert : simple_line_vert,
+ fragmentShader: usage === 'basemap' ? simple_line_map_frag : simple_line_frag,
+ triangulation: TileSimpleLineTriangulation,
+ primitive: gl.LINES,
+ depth: { enable: false },
+ blend: this.getBlend(),
+ stencil: getMask(mask, maskInside),
+ pick: false,
+ })
+ .then((model) => {
+ callbackModel([model]);
+ })
+ .catch((err) => {
+ console.warn(err);
+ callbackModel([]);
+ });
+ }
+
+ protected registerBuiltinAttributes() {
+ }
+}
diff --git a/packages/layers/src/line/models/tile.ts b/packages/layers/src/line/models/tile.ts
index 4a8a83fd7a..2ce4e75b97 100644
--- a/packages/layers/src/line/models/tile.ts
+++ b/packages/layers/src/line/models/tile.ts
@@ -4,136 +4,60 @@ import {
IEncodeFeature,
IModel,
IModelUniform,
- ITexture2D,
} from '@antv/l7-core';
-
import { getMask, rgb2arr } from '@antv/l7-utils';
import BaseModel from '../../core/BaseModel';
import { ILineLayerStyleOptions } from '../../core/interface';
import { LineTriangulation } from '../../core/triangulation';
-import line_tile_frag from '../shaders/tile/line_tile_frag.glsl';
+import line_tile_frag from '../../shader/minify_picking_frag.glsl';
import line_tile_vert from '../shaders/tile/line_tile_vert.glsl';
+import line_tile_map_frag from '../../shader/minify_frag.glsl';
+import line_tile_map_vert from '../shaders/tile/line_tile_map_vert.glsl'
export default class LineModel extends BaseModel {
- protected texture: ITexture2D;
public getUninforms(): IModelUniform {
const {
opacity = 1,
- textureBlend = 'normal',
- lineTexture = false,
- iconStep = 100,
- vertexHeightScale = 20.0,
- borderWidth = 0.0,
- borderColor = '#ccc',
- heightfixed = false,
- arrow = {
- enable: false,
- arrowWidth: 2,
- arrowHeight: 3,
- tailWidth: 1,
- },
- coord = 'lnglat',
- tileOrigin,
+ usage,
+ color = '#fff',
+ size = 1
+ // coord = 'lnglat',
+ // tileOrigin,
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
- if (this.rendererService.getDirty()) {
- this.texture.bind();
- }
-
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
- this.judgeStyleAttributes({ opacity });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
return {
- u_tileOrigin: tileOrigin || [0, 0],
- u_coord: coord === 'lnglat' ? 1.0 : 0.0,
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
+ // u_tileOrigin: tileOrigin || [0, 0],
+ // u_coord: coord === 'lnglat' ? 1.0 : 0.0,
u_opacity: Number(opacity),
- u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
-
- // 纹理支持参数
- u_texture: this.texture, // 贴图
- u_line_texture: lineTexture ? 1.0 : 0.0, // 传入线的标识
- u_icon_step: iconStep,
- u_textSize: [1024, this.iconService.canvasHeight || 128],
-
- // line border 参数
- u_borderWidth: borderWidth,
- u_borderColor: rgb2arr(borderColor),
-
- // 是否固定高度
- u_heightfixed: Number(heightfixed),
-
- // 顶点高度 scale
- u_vertexScale: vertexHeightScale,
-
- // arrow
- u_arrow: Number(arrow.enable),
- u_arrowHeight: arrow.arrowHeight || 3,
- u_arrowWidth: arrow.arrowWidth || 2,
- u_tailWidth: arrow.tailWidth === undefined ? 1 : arrow.tailWidth,
+ u_color: usage === 'basemap' ? rgb2arr(color): [0, 0, 0, 0],
+ u_size: usage === 'basemap' ? size: 1
};
}
public initModels(callbackModel: (models: IModel[]) => void) {
- this.updateTexture();
- this.iconService.on('imageUpdate', this.updateTexture);
-
this.buildModels(callbackModel);
}
- public clearModels() {
- this.texture?.destroy();
- this.dataTexture?.destroy();
- this.iconService.off('imageUpdate', this.updateTexture);
- }
-
public async buildModels(callbackModel: (models: IModel[]) => void) {
const {
mask = false,
maskInside = true,
depth = false,
+ usage
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
-
this.layer.triangulation = LineTriangulation;
this.layer
.buildLayerModel({
- moduleName: 'lineTile',
- vertexShader: line_tile_vert,
- fragmentShader: line_tile_frag,
+ moduleName: 'lineTile_' + usage,
+ vertexShader: usage === 'basemap' ? line_tile_map_vert : line_tile_vert,
+ fragmentShader: usage === 'basemap' ? line_tile_map_frag : line_tile_frag,
triangulation: LineTriangulation,
blend: this.getBlend(),
depth: { enable: depth },
- // depth: { enable: true },
stencil: getMask(mask, maskInside),
+ pick: usage !== 'basemap'
})
.then((model) => {
callbackModel([model]);
@@ -145,77 +69,30 @@ export default class LineModel extends BaseModel {
}
protected registerBuiltinAttributes() {
- this.styleAttributeService.registerStyleAttribute({
- name: 'distanceAndIndex',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_DistanceAndIndex',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.STATIC_DRAW,
- data: [],
- type: gl.FLOAT,
+ const { usage } = this.layer.getLayerConfig();
+ if(usage !== 'basemap') {
+ this.styleAttributeService.registerStyleAttribute({
+ name: 'size',
+ type: AttributeType.Attribute,
+ descriptor: {
+ name: 'a_Size',
+ buffer: {
+ // give the WebGL driver a hint that this buffer may change
+ usage: gl.DYNAMIC_DRAW,
+ data: [],
+ type: gl.FLOAT,
+ },
+ size: 2,
+ update: (
+ feature: IEncodeFeature,
+ ) => {
+ const { size = 1 } = feature;
+ return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
+ },
},
- size: 2,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- normal: number[],
- vertexIndex?: number,
- ) => {
- return vertexIndex === undefined
- ? [vertex[3], 10]
- : [vertex[3], vertexIndex];
- },
- },
- });
- this.styleAttributeService.registerStyleAttribute({
- name: 'total_distance',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_Total_Distance',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.STATIC_DRAW,
- data: [],
- type: gl.FLOAT,
- },
- size: 1,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
- return [vertex[5]];
- },
- },
- });
-
- this.styleAttributeService.registerStyleAttribute({
- name: 'size',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_Size',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.DYNAMIC_DRAW,
- data: [],
- type: gl.FLOAT,
- },
- size: 2,
- update: (
- feature: IEncodeFeature,
- ) => {
- const { size = 1 } = feature;
- return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
- },
- },
- });
-
- // point layer size;
+ });
+ }
+
this.styleAttributeService.registerStyleAttribute({
name: 'normal',
type: AttributeType.Attribute,
@@ -263,49 +140,5 @@ export default class LineModel extends BaseModel {
},
});
- this.styleAttributeService.registerStyleAttribute({
- name: 'uv',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_iconMapUV',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.DYNAMIC_DRAW,
- data: [],
- type: gl.FLOAT,
- },
- size: 2,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
- const iconMap = this.iconService.getIconMap();
- const { texture } = feature;
- const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
- return [x, y];
- },
- },
- });
}
-
- private updateTexture = () => {
- const { createTexture2D } = this.rendererService;
- if (this.texture) {
- this.texture.update({
- data: this.iconService.getCanvas(),
- });
- this.layer.render();
- return;
- }
- this.texture = createTexture2D({
- data: this.iconService.getCanvas(),
- mag: gl.NEAREST,
- min: gl.NEAREST,
- premultiplyAlpha: false,
- width: 1024,
- height: this.iconService.canvasHeight || 128,
- });
- };
}
diff --git a/packages/layers/src/line/models/wall.ts b/packages/layers/src/line/models/wall.ts
index 58e9bbc4e4..31bf92402f 100644
--- a/packages/layers/src/line/models/wall.ts
+++ b/packages/layers/src/line/models/wall.ts
@@ -13,8 +13,8 @@ import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
import { ILineLayerStyleOptions } from '../../core/interface';
import { LineTriangulation } from '../../core/triangulation';
-import line_frag from '../shaders/wall_frag.glsl';
-import line_vert from '../shaders/wall_vert.glsl';
+import line_frag from '../shaders/wall/wall_frag.glsl';
+import line_vert from '../shaders/wall/wall_vert.glsl';
export default class LineWallModel extends BaseModel {
protected texture: ITexture2D;
@@ -44,41 +44,9 @@ export default class LineWallModel extends BaseModel {
useLinearColor = 1;
}
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
- this.judgeStyleAttributes({ opacity });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
-
return {
u_heightfixed: Number(heightfixed),
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
-
+
u_opacity: isNumber(opacity) ? opacity : 1.0,
u_textureBlend: textureBlend === 'normal' ? 0.0 : 1.0,
@@ -112,7 +80,6 @@ export default class LineWallModel extends BaseModel {
public clearModels() {
this.texture?.destroy();
- this.dataTexture?.destroy();
this.iconService.off('imageUpdate', this.updateTexture);
}
@@ -172,7 +139,6 @@ export default class LineWallModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[5]];
},
@@ -193,9 +159,6 @@ export default class LineWallModel extends BaseModel {
size: 2,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 1 } = feature;
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
@@ -245,7 +208,6 @@ export default class LineWallModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[4]];
},
@@ -266,9 +228,6 @@ export default class LineWallModel extends BaseModel {
size: 2,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const iconMap = this.iconService.getIconMap();
const { texture } = feature;
diff --git a/packages/layers/src/line/shaders/dash/arc_dash_vert.glsl b/packages/layers/src/line/shaders/dash/arc_dash_vert.glsl
index a8f023fece..2f82166b03 100644
--- a/packages/layers/src/line/shaders/dash/arc_dash_vert.glsl
+++ b/packages/layers/src/line/shaders/dash/arc_dash_vert.glsl
@@ -48,6 +48,8 @@ vec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {
// return mid;
}
float getSegmentRatio(float index) {
+ // dash: index / (segmentNumber - 1.);
+ // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
return index / (segmentNumber - 1.);
}
vec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {
diff --git a/packages/layers/src/line/shaders/dash/line_dash_frag.glsl b/packages/layers/src/line/shaders/dash/line_dash_frag.glsl
index 9f49cdb9e2..ae5b65d98f 100644
--- a/packages/layers/src/line/shaders/dash/line_dash_frag.glsl
+++ b/packages/layers/src/line/shaders/dash/line_dash_frag.glsl
@@ -9,7 +9,7 @@ varying vec4 v_dash_array;
#pragma include "picking"
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // 控制运动
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ]; // 控制运动
varying mat4 styleMappingMat;
// [animate, duration, interval, trailLength],
diff --git a/packages/layers/src/line/shaders/line_arc2d_vert.glsl b/packages/layers/src/line/shaders/line_arc2d_vert.glsl
index 6c82f012d4..0add0db068 100644
--- a/packages/layers/src/line/shaders/line_arc2d_vert.glsl
+++ b/packages/layers/src/line/shaders/line_arc2d_vert.glsl
@@ -7,7 +7,7 @@ attribute vec4 a_Instance;
attribute float a_Size;
uniform mat4 u_ModelMatrix;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
varying vec2 v_normal;
diff --git a/packages/layers/src/line/shaders/line_arc_3d_frag.glsl b/packages/layers/src/line/shaders/line_arc_3d_frag.glsl
index b81e7df804..a456ddc2ca 100644
--- a/packages/layers/src/line/shaders/line_arc_3d_frag.glsl
+++ b/packages/layers/src/line/shaders/line_arc_3d_frag.glsl
@@ -20,7 +20,7 @@ uniform float segmentNumber;
varying vec2 v_iconMapUV;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying mat4 styleMappingMat;
diff --git a/packages/layers/src/line/shaders/line_arc_3d_vert.glsl b/packages/layers/src/line/shaders/line_arc_3d_vert.glsl
index 15efcd9e1c..475f44abc2 100644
--- a/packages/layers/src/line/shaders/line_arc_3d_vert.glsl
+++ b/packages/layers/src/line/shaders/line_arc_3d_vert.glsl
@@ -13,7 +13,7 @@ uniform float u_global_height: 10;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
// varying vec2 v_normal;
uniform float u_line_type: 0.0;
@@ -85,11 +85,11 @@ float torad(float deg) {
vec3 lglt2xyz(vec2 lnglat) {
float pi = 3.1415926;
- // TODO: + Math.PI/2 是为了对齐坐标
+ // + Math.PI/2 是为了对齐坐标
float lng = torad(lnglat.x) + pi / 2.0;
float lat = torad(lnglat.y);
- // TODO: 手动增加一些偏移,减轻面的冲突
+ // 手动增加一些偏移,减轻面的冲突
float radius = u_globel_radius;
float z = radius * cos(lat) * cos(lng);
diff --git a/packages/layers/src/line/shaders/line_arc_frag.glsl b/packages/layers/src/line/shaders/line_arc_frag.glsl
index 6711ca6732..3a50ead93f 100644
--- a/packages/layers/src/line/shaders/line_arc_frag.glsl
+++ b/packages/layers/src/line/shaders/line_arc_frag.glsl
@@ -11,7 +11,7 @@ varying vec4 v_dash_array;
varying vec4 v_color;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
uniform float u_line_texture;
uniform sampler2D u_texture;
diff --git a/packages/layers/src/line/shaders/line_arc_great_circle_frag.glsl b/packages/layers/src/line/shaders/line_arc_great_circle_frag.glsl
index 434bcdeedd..9a9acfa91c 100644
--- a/packages/layers/src/line/shaders/line_arc_great_circle_frag.glsl
+++ b/packages/layers/src/line/shaders/line_arc_great_circle_frag.glsl
@@ -13,7 +13,7 @@ varying float v_distance_ratio;
varying vec4 v_color;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
uniform float u_line_texture: 0.0;
uniform sampler2D u_texture;
diff --git a/packages/layers/src/line/shaders/line_arc_great_circle_vert.glsl b/packages/layers/src/line/shaders/line_arc_great_circle_vert.glsl
index ef6e965583..e714b27388 100644
--- a/packages/layers/src/line/shaders/line_arc_great_circle_vert.glsl
+++ b/packages/layers/src/line/shaders/line_arc_great_circle_vert.glsl
@@ -10,7 +10,7 @@ attribute float a_Size;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
// varying vec2 v_normal;
diff --git a/packages/layers/src/line/shaders/line_arc_vert.glsl b/packages/layers/src/line/shaders/line_arc_vert.glsl
index 1d3d7ae695..854dafd271 100644
--- a/packages/layers/src/line/shaders/line_arc_vert.glsl
+++ b/packages/layers/src/line/shaders/line_arc_vert.glsl
@@ -8,7 +8,7 @@ attribute float a_Size;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
uniform float u_lineDir: 1.0;
@@ -52,8 +52,10 @@ vec2 midPoint(vec2 source, vec2 target, float arcThetaOffset) {
// return mid;
}
float getSegmentRatio(float index) {
- // return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
- return index / (segmentNumber - 1.);
+ // dash: index / (segmentNumber - 1.);
+ // normal: smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
+ return smoothstep(0.0, 1.0, index / (segmentNumber - 1.));
+ // return index / (segmentNumber - 1.);
}
vec2 interpolate (vec2 source, vec2 target, float t, float arcThetaOffset) {
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
diff --git a/packages/layers/src/line/shaders/line_bezier_vert.glsl b/packages/layers/src/line/shaders/line_bezier_vert.glsl
index 7baa167c7e..2735b91696 100644
--- a/packages/layers/src/line/shaders/line_bezier_vert.glsl
+++ b/packages/layers/src/line/shaders/line_bezier_vert.glsl
@@ -7,7 +7,7 @@ attribute vec4 a_Instance;
attribute float a_Size;
uniform mat4 u_ModelMatrix;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
varying vec2 v_normal;
diff --git a/packages/layers/src/line/shaders/line_frag.glsl b/packages/layers/src/line/shaders/line_frag.glsl
index a9f745a39d..3dc3c5393d 100644
--- a/packages/layers/src/line/shaders/line_frag.glsl
+++ b/packages/layers/src/line/shaders/line_frag.glsl
@@ -19,7 +19,7 @@ varying vec2 v_iconMapUV;
#pragma include "picking"
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // 控制运动
+uniform vec4 u_aimate: [ 1, 2., 1.0, 0.2 ]; // 控制运动
varying mat4 styleMappingMat;
// [animate, duration, interval, trailLength],
@@ -95,6 +95,5 @@ void main() {
gl_FragColor.a *= mix(u_blur.g, u_blur.b, (blurV - 0.5)/0.5);
}
-
gl_FragColor = filterColor(gl_FragColor);
}
diff --git a/packages/layers/src/line/shaders/line_vert.glsl b/packages/layers/src/line/shaders/line_vert.glsl
index adc74dc014..cfe1bb38c5 100644
--- a/packages/layers/src/line/shaders/line_vert.glsl
+++ b/packages/layers/src/line/shaders/line_vert.glsl
@@ -15,7 +15,7 @@ attribute vec2 a_DistanceAndIndex;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
uniform float u_icon_step: 100;
uniform float u_heightfixed: 0.0;
diff --git a/packages/layers/src/line/shaders/linear/arc3d_linear_frag.glsl b/packages/layers/src/line/shaders/linear/arc3d_linear_frag.glsl
index fb0516f91e..f57e91c058 100644
--- a/packages/layers/src/line/shaders/linear/arc3d_linear_frag.glsl
+++ b/packages/layers/src/line/shaders/linear/arc3d_linear_frag.glsl
@@ -8,7 +8,7 @@ uniform float segmentNumber;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
uniform float u_linearColor: 0;
uniform vec4 u_sourceColor;
diff --git a/packages/layers/src/line/shaders/linear/arc3d_linear_vert.glsl b/packages/layers/src/line/shaders/linear/arc3d_linear_vert.glsl
index 15efcd9e1c..475f44abc2 100644
--- a/packages/layers/src/line/shaders/linear/arc3d_linear_vert.glsl
+++ b/packages/layers/src/line/shaders/linear/arc3d_linear_vert.glsl
@@ -13,7 +13,7 @@ uniform float u_global_height: 10;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
uniform float segmentNumber;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
varying vec4 v_color;
// varying vec2 v_normal;
uniform float u_line_type: 0.0;
@@ -85,11 +85,11 @@ float torad(float deg) {
vec3 lglt2xyz(vec2 lnglat) {
float pi = 3.1415926;
- // TODO: + Math.PI/2 是为了对齐坐标
+ // + Math.PI/2 是为了对齐坐标
float lng = torad(lnglat.x) + pi / 2.0;
float lat = torad(lnglat.y);
- // TODO: 手动增加一些偏移,减轻面的冲突
+ // 手动增加一些偏移,减轻面的冲突
float radius = u_globel_radius;
float z = radius * cos(lat) * cos(lng);
diff --git a/packages/layers/src/line/shaders/linear/arc_linear_frag.glsl b/packages/layers/src/line/shaders/linear/arc_linear_frag.glsl
index 0e755bf3ac..f4c681be51 100644
--- a/packages/layers/src/line/shaders/linear/arc_linear_frag.glsl
+++ b/packages/layers/src/line/shaders/linear/arc_linear_frag.glsl
@@ -10,7 +10,7 @@ varying vec4 v_dash_array;
varying vec4 v_color;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
uniform float u_line_texture;
uniform sampler2D u_texture;
diff --git a/packages/layers/src/line/shaders/tile/line_tile_frag.glsl b/packages/layers/src/line/shaders/tile/line_tile_frag.glsl
deleted file mode 100644
index 4d816342dd..0000000000
--- a/packages/layers/src/line/shaders/tile/line_tile_frag.glsl
+++ /dev/null
@@ -1,79 +0,0 @@
-#define LineTexture 1.0
-uniform float u_blur : 0.99;
-uniform float u_opacity : 1.0;
-uniform float u_textureBlend;
-
-uniform float u_borderWidth: 0.0;
-uniform vec4 u_borderColor;
-varying vec4 v_color;
-
-// line texture
-uniform float u_line_texture;
-uniform sampler2D u_texture;
-uniform vec2 u_textSize;
-
-varying vec2 v_iconMapUV;
-
-#pragma include "picking"
-
-varying mat4 styleMappingMat;
-
-void main() {
- float opacity = styleMappingMat[0][0];
- float d_distance_ratio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
- gl_FragColor = v_color;
- // anti-alias
- // float blur = 1.0 - smoothstep(u_blur, 1., length(v_normal.xy));
- gl_FragColor.a *= opacity; // 全局透明度
-
-
- if(u_line_texture == LineTexture) { // while load texture
- float aDistance = styleMappingMat[3].g; // 当前顶点的距离
- float d_texPixelLen = styleMappingMat[3].b; // 贴图的像素长度,根据地图层级缩放
- float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen);
- float v = styleMappingMat[3].a; // 线图层贴图部分的 v 坐标值
-
- // v = max(smoothstep(0.95, 1.0, v), v);
- vec2 uv= v_iconMapUV / u_textSize + vec2(u, v) / u_textSize * 64.;
-
- // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, vec2(u, v)));
- // gl_FragColor = filterColor(gl_FragColor + texture2D(u_texture, uv));
- vec4 pattern = texture2D(u_texture, uv);
-
- if(u_textureBlend == 0.0) { // normal
- pattern.a = 0.0;
- gl_FragColor += pattern;
- } else { // replace
- pattern.a *= opacity;
- if(gl_FragColor.a <= 0.0) {
- pattern.a = 0.0;
- }
- gl_FragColor = pattern;
- }
- }
-
- float v = styleMappingMat[3].a;
- float borderWidth = min(0.5, u_borderWidth);
- // 绘制 border
- if(borderWidth > 0.01) {
- float borderOuterWidth = borderWidth/2.0;
-
- if(v >= 1.0 - borderWidth || v <= borderWidth) {
- if(v > borderWidth) {
- float linear = smoothstep(0.0, 1.0, (v - (1.0 - borderWidth))/borderWidth);
- gl_FragColor.rgb = mix(gl_FragColor.rgb, u_borderColor.rgb, linear);
- } else if(v <= borderWidth) {
- float linear = smoothstep(0.0, 1.0, v/borderWidth);
- gl_FragColor.rgb = mix(u_borderColor.rgb, gl_FragColor.rgb, linear);
- }
- }
-
- if(v < borderOuterWidth) {
- gl_FragColor.a = mix(0.0, gl_FragColor.a, v/borderOuterWidth);
- } else if(v > 1.0 - borderOuterWidth) {
- gl_FragColor.a = mix(gl_FragColor.a, 0.0, (v - (1.0 - borderOuterWidth))/borderOuterWidth);
- }
- }
-
- gl_FragColor = filterColor(gl_FragColor);
-}
diff --git a/packages/layers/src/line/shaders/tile/line_tile_map_vert.glsl b/packages/layers/src/line/shaders/tile/line_tile_map_vert.glsl
new file mode 100644
index 0000000000..7e74783439
--- /dev/null
+++ b/packages/layers/src/line/shaders/tile/line_tile_map_vert.glsl
@@ -0,0 +1,25 @@
+attribute float a_Miter;
+attribute vec4 a_Color;
+attribute vec3 a_Normal;
+attribute vec3 a_Position;
+
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+uniform float u_size;
+
+#pragma include "projection"
+
+void main() {
+
+ vec3 size = a_Miter * u_size * reverse_offset_normal(a_Normal);
+
+ vec2 offset = project_pixel(size.xy);
+
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
+
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
+ }
+}
diff --git a/packages/layers/src/line/shaders/tile/line_tile_vert.glsl b/packages/layers/src/line/shaders/tile/line_tile_vert.glsl
index aaf25efa1b..f240c0bc60 100644
--- a/packages/layers/src/line/shaders/tile/line_tile_vert.glsl
+++ b/packages/layers/src/line/shaders/tile/line_tile_vert.glsl
@@ -1,210 +1,52 @@
-
attribute float a_Miter;
attribute vec4 a_Color;
attribute vec2 a_Size;
attribute vec3 a_Normal;
attribute vec3 a_Position;
-attribute vec2 a_iconMapUV;
-
-// dash line
-attribute float a_Total_Distance;
-attribute vec2 a_DistanceAndIndex;
-
-uniform vec2 u_tileOrigin;
-uniform float u_coord;
+// uniform vec2 u_tileOrigin;
+// uniform float u_coord;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
-uniform float u_icon_step: 100;
-uniform float u_heightfixed: 0.0;
-uniform float u_vertexScale: 1.0;
#pragma include "projection"
#pragma include "picking"
varying vec4 v_color;
-// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
-varying vec2 v_iconMapUV;
-
-
-uniform float u_linearColor: 0;
-uniform float u_arrow: 0.0;
-uniform float u_arrowHeight: 3.0;
-uniform float u_arrowWidth: 2.0;
-uniform float u_tailWidth: 1.0;
-
-uniform float u_opacity: 1.0;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
-
-vec2 calculateArrow(vec2 offset) {
- /*
- * 在支持箭头的时候,第二、第三组顶点是额外插入用于构建顶点的
- */
- float arrowFlag = -1.0;
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
- // 高德 2.0 的旋转角度不同
- arrowFlag = 1.0;
- }
- float pi = arrowFlag * 3.1415926/2.;
- if(a_Miter < 0.) {
- // 根据线的两侧偏移不同、旋转的方向相反
- pi = -pi;
- }
- highp float angle_sin = sin(pi);
- highp float angle_cos = cos(pi);
- // 计算垂直与线方向的旋转矩阵
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
- float arrowWidth = u_arrowWidth;
- float arrowHeight = u_arrowHeight;
-
- vec2 arrowOffset = vec2(0.0);
- /*
- * a_DistanceAndIndex.y 用于标记当前顶点属于哪一组(两个顶点一组,构成线的其实是矩形,最简需要四个顶点、两组顶点构成)
- */
- if(a_DistanceAndIndex.y == 0.0) {
- // 箭头尖部
- offset = vec2(0.0);
- } else if(a_DistanceAndIndex.y == 1.0) {
- // 箭头两侧
- arrowOffset = rotation_matrix*(offset * arrowHeight);
- offset += arrowOffset; // 沿线偏移
- offset = offset * arrowWidth; // 垂直线向外偏移(是构建箭头两侧的顶点)
- } else if(a_DistanceAndIndex.y == 2.0 || a_DistanceAndIndex.y == 3.0 || a_DistanceAndIndex.y == 4.0) {
- // 偏移其余的点位(将长度让位给箭头)
- arrowOffset = rotation_matrix*(offset * arrowHeight) * arrowWidth;
- offset += arrowOffset;// 沿线偏移
- }
-
- return offset;
-}
-
void main() {
- // cal style mapping - 数据纹理映射部分的计算
- styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
- // cal style mapping - 数据纹理映射部分的计算
-
- float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
-
- v_iconMapUV = a_iconMapUV;
- d_texPixelLen = project_float_pixel(u_icon_step);
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
- d_texPixelLen *= 10.0;
- }
-
v_color = a_Color;
vec3 size = a_Miter * setPickingSize(a_Size.x) * reverse_offset_normal(a_Normal);
vec2 offset = project_pixel(size.xy);
- float lineDistance = a_DistanceAndIndex.x;
- float currentLinePointRatio = lineDistance / a_Total_Distance;
-
- if(u_arrow > 0.0) {
- // 计算箭头
- offset = calculateArrow(offset);
-
- if(a_DistanceAndIndex.y > 4.0) {
- offset *= mix(1.0, u_tailWidth, currentLinePointRatio);
- }
- }
-
- float lineOffsetWidth = length(offset + offset * sign(a_Miter)); // 线横向偏移的距离(向两侧偏移的和)
- float linePixelSize = project_pixel(a_Size.x) * 2.0; // 定点位置偏移,按地图等级缩放后的距离 单侧 * 2
- float texV = lineOffsetWidth/linePixelSize; // 线图层贴图部分的 v 坐标值
-
- // 设置数据集的参数
- styleMappingMat[3][0] = currentLinePointRatio; // 当前点位距离占线总长的比例
- styleMappingMat[3][1] = lineDistance; // 当前顶点的距离
- styleMappingMat[3][2] = d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
- styleMappingMat[3][3] = texV; // 线图层贴图部分的 v 坐标值
-
vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, a_Size.y, 1.0));
-
- float h = float(a_Position.z) * u_vertexScale; // 线顶点的高度 - 兼容不存在第三个数值的情况 vertex height
- float lineHeight = a_Size.y; // size 第二个参数代表的高度 [linewidth, lineheight]
-
-if(u_coord > 0.0) {
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
- lineHeight *= 0.2; // 保持和 amap/mapbox 一致的效果
- h *= 0.2;
- if(u_heightfixed < 1.0) {
- lineHeight = project_pixel(a_Size.y);
- }
- gl_Position = u_Mvp * (vec4(project_pos.xy + offset, lineHeight + h, 1.0));
- } else {
- // mapbox - amap
-
- // 兼容 mapbox 在线高度上的效果表现基本一致
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- // mapbox
- // 保持高度相对不变
- float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
- h *= mapboxZoomScale;
- if(u_heightfixed > 0.0) {
- lineHeight *= mapboxZoomScale;
- }
-
+ // if(u_coord > 0.0) { // 使用经纬度坐标
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));
} else {
- // amap
- // lineHeight 顶点偏移高度
- if(u_heightfixed < 1.0) {
- lineHeight *= pow(2.0, 20.0 - u_Zoom);
- }
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
}
+ // } else { // 使用偏移坐标
+ // vec2 pointPos = a_Position.xy;
+ // vec4 tileWorld = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, lineHeight + h, 1.0));
- }
-} else {
- vec2 pointPos = a_Position.xy;
- vec4 tileWorld = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
+ // vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
+
+ // tileWorld.xy += pointOffset;
- vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
-
- tileWorld.xy += pointOffset;
-
- tileWorld.xy += offset;
-
- if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- // Needs to be divided with project_uCommonUnitsPerMeter
- tileWorld.w *= u_PixelsPerMeter.z;
- }
-
- gl_Position = u_ViewProjectionMatrix * tileWorld + u_ViewportCenterProjection;
-}
+ // tileWorld.xy += offset;
+ // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
+ // // Needs to be divided with project_uCommonUnitsPerMeter
+ // tileWorld.w *= u_PixelsPerMeter.z;
+ // }
+ // gl_Position = u_ViewProjectionMatrix * tileWorld + u_ViewportCenterProjection;
+ // }
setPickingColor(a_PickingColor);
-
-
}
diff --git a/packages/layers/src/line/shaders/tile/simpleline_map_vert.glsl b/packages/layers/src/line/shaders/tile/simpleline_map_vert.glsl
new file mode 100644
index 0000000000..07529b33c1
--- /dev/null
+++ b/packages/layers/src/line/shaders/tile/simpleline_map_vert.glsl
@@ -0,0 +1,15 @@
+attribute vec3 a_Position;
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+
+#pragma include "projection"
+
+void main() {
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
+
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xy, 0.0, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
+ }
+}
\ No newline at end of file
diff --git a/packages/layers/src/line/shaders/tile/simpleline_vert.glsl b/packages/layers/src/line/shaders/tile/simpleline_vert.glsl
new file mode 100644
index 0000000000..87fab6d435
--- /dev/null
+++ b/packages/layers/src/line/shaders/tile/simpleline_vert.glsl
@@ -0,0 +1,21 @@
+attribute vec4 a_Color;
+attribute vec3 a_Position;
+
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+
+#pragma include "projection"
+
+varying vec4 v_color;
+
+void main() {
+ v_color = a_Color;
+
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
+
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xy, 0.0, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, 0.0, 1.0));
+ }
+}
diff --git a/packages/layers/src/line/shaders/wall_frag.glsl b/packages/layers/src/line/shaders/wall/wall_frag.glsl
similarity index 79%
rename from packages/layers/src/line/shaders/wall_frag.glsl
rename to packages/layers/src/line/shaders/wall/wall_frag.glsl
index 28cb7d4348..e893f944f9 100644
--- a/packages/layers/src/line/shaders/wall_frag.glsl
+++ b/packages/layers/src/line/shaders/wall/wall_frag.glsl
@@ -1,36 +1,32 @@
#define Animate 0.0
#define LineTexture 1.0
-uniform float u_opacity : 1.0;
-uniform float u_textureBlend;
-uniform float u_iconStepCount;
-
-varying vec4 v_color;
-
// line texture
uniform float u_line_texture;
uniform sampler2D u_texture;
uniform vec2 u_textSize;
-
-varying vec2 v_iconMapUV;
-varying float v_blur;
-
uniform float u_linearColor: 0;
uniform vec4 u_sourceColor;
uniform vec4 u_targetColor;
+uniform float u_opacity : 1.0;
+uniform float u_textureBlend;
+uniform float u_iconStepCount;
+uniform float u_time;
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ]; // 控制运动
+
+varying vec2 v_iconMapUV;
+varying float v_blur;
+varying float v_radio;
+varying vec4 v_color;
+varying vec4 v_dataset;
#pragma include "picking"
-uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ]; // 控制运动
-
-varying mat4 styleMappingMat;
-// [animate, duration, interval, trailLength],
void main() {
- float opacity = styleMappingMat[0][0];
+ float opacity = u_opacity;
float animateSpeed = 0.0; // 运动速度
- float d_distance_ratio = styleMappingMat[3].r; // 当前点位距离占线总长的比例
- float v = styleMappingMat[3].a;
+ float d_distance_ratio = v_dataset.r; // 当前点位距离占线总长的比例
+ float v = v_dataset.a;
if(u_linearColor == 1.0) { // 使用渐变颜色
gl_FragColor = mix(u_sourceColor, u_targetColor, v);
@@ -48,10 +44,10 @@ void main() {
}
if(u_line_texture == LineTexture) { // while load texture
- float aDistance = styleMappingMat[3].g; // 当前顶点的距离
- float d_texPixelLen = styleMappingMat[3].b; // 贴图的像素长度,根据地图层级缩放
+ float aDistance = v_dataset.g; // 当前顶点的距离
+ float d_texPixelLen = v_dataset.b; // 贴图的像素长度,根据地图层级缩放
float u = fract(mod(aDistance, d_texPixelLen)/d_texPixelLen - animateSpeed);
- float v = styleMappingMat[3].a; // 线图层贴图部分的 v 坐标值
+ float v = v_dataset.a; // 线图层贴图部分的 v 坐标值
// 计算纹理间隔 start
float flag = 0.0;
diff --git a/packages/layers/src/line/shaders/wall/wall_vert.glsl b/packages/layers/src/line/shaders/wall/wall_vert.glsl
new file mode 100644
index 0000000000..c070e10265
--- /dev/null
+++ b/packages/layers/src/line/shaders/wall/wall_vert.glsl
@@ -0,0 +1,77 @@
+#define Animate 0.0
+
+attribute float a_Miter;
+attribute vec4 a_Color;
+attribute vec2 a_Size;
+attribute vec3 a_Normal;
+attribute vec3 a_Position;
+attribute vec2 a_iconMapUV;
+attribute float a_Total_Distance;
+attribute float a_Distance;
+
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
+uniform float u_icon_step: 100;
+uniform float u_heightfixed;
+uniform float u_linearColor: 0;
+
+#pragma include "projection"
+#pragma include "light"
+#pragma include "picking"
+
+// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
+varying vec2 v_iconMapUV;
+varying vec4 v_color;
+varying float v_blur;
+varying float v_radio;
+varying vec4 v_dataset;
+
+void main() {
+
+
+ float d_distance_ratio; // 当前点位距离占线总长的比例
+ float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
+
+ v_iconMapUV = a_iconMapUV;
+ if(u_heightfixed < 1.0) { // 高度随 zoom 调整
+ d_texPixelLen = project_pixel(u_icon_step);
+ } else {
+ d_texPixelLen = u_icon_step;
+ }
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
+ d_texPixelLen *= 10.0;
+ }
+
+ if(u_aimate.x == Animate || u_linearColor == 1.0) {
+ d_distance_ratio = a_Distance / a_Total_Distance;
+ }
+
+ float miter = (a_Miter + 1.0)/2.0;
+ // 设置数据集的参数
+ v_dataset[0] = d_distance_ratio; // 当前点位距离占线总长的比例
+ v_dataset[1] = a_Distance; // 当前顶点的距离
+ v_dataset[2] = d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
+ v_dataset[3] = miter; // 线图层贴图部分的 v 坐标值 0 - 1
+
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
+
+ float originSize = a_Size.x; // 固定高度
+ if(u_heightfixed < 1.0) { // 高度随 zoom 调整
+ originSize = project_float_pixel(a_Size.x);
+ }
+
+ float wallHeight = originSize * miter;
+ float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));
+
+ v_blur = min(project_float_pixel(2.0) / originSize, 0.05);
+ v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);
+
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));
+ }
+
+ setPickingColor(a_PickingColor);
+}
diff --git a/packages/layers/src/line/shaders/wall_vert.glsl b/packages/layers/src/line/shaders/wall_vert.glsl
deleted file mode 100644
index 6384c47dc5..0000000000
--- a/packages/layers/src/line/shaders/wall_vert.glsl
+++ /dev/null
@@ -1,111 +0,0 @@
-#define Animate 0.0
-
-attribute float a_Miter;
-attribute vec4 a_Color;
-attribute vec2 a_Size;
-attribute vec3 a_Normal;
-attribute vec3 a_Position;
-attribute vec2 a_iconMapUV;
-
-attribute float a_Total_Distance;
-attribute float a_Distance;
-
-uniform mat4 u_ModelMatrix;
-uniform mat4 u_Mvp;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
-uniform float u_icon_step: 100;
-uniform float u_heightfixed;
-
-#pragma include "projection"
-#pragma include "light"
-#pragma include "picking"
-
-varying vec4 v_color;
-varying float v_blur;
-
-// texV 线图层 - 贴图部分的 v 坐标(线的宽度方向)
-varying vec2 v_iconMapUV;
-
-uniform float u_linearColor: 0;
-
-uniform float u_opacity: 1.0;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
-#pragma include "styleMapping"
-#pragma include "light"
-#pragma include "styleMappingCalOpacity"
-
-void main() {
- // cal style mapping - 数据纹理映射部分的计算
- styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0 // distance_ratio/distance/pixelLen/texV
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
- // cal style mapping - 数据纹理映射部分的计算
-
- float d_distance_ratio; // 当前点位距离占线总长的比例
- float d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
-
- v_iconMapUV = a_iconMapUV;
- if(u_heightfixed < 1.0) { // 高度随 zoom 调整
- d_texPixelLen = project_pixel(u_icon_step);
- } else {
- d_texPixelLen = u_icon_step;
- }
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) {
- d_texPixelLen *= 10.0;
- }
-
- if(u_aimate.x == Animate || u_linearColor == 1.0) {
- d_distance_ratio = a_Distance / a_Total_Distance;
- }
-
- float miter = (a_Miter + 1.0)/2.0;
- // 设置数据集的参数
- styleMappingMat[3][0] = d_distance_ratio; // 当前点位距离占线总长的比例
- styleMappingMat[3][1] = a_Distance; // 当前顶点的距离
- styleMappingMat[3][2] = d_texPixelLen; // 贴图的像素长度,根据地图层级缩放
- styleMappingMat[3][3] = miter; // 线图层贴图部分的 v 坐标值 0 - 1
-
- vec4 project_pos = project_position(vec4(a_Position.xy, 0, 1.0));
-
- float originSize = a_Size.x; // 固定高度
- if(u_heightfixed < 1.0) { // 高度随 zoom 调整
- originSize = project_float_pixel(a_Size.x);
- }
-
- float wallHeight = originSize * miter;
- float lightWeight = calc_lighting(vec4(project_pos.xy, wallHeight, 1.0));
-
- v_blur = min(project_float_pixel(2.0) / originSize, 0.05);
-
- v_color = vec4(a_Color.rgb * lightWeight, a_Color.w);
- // v_color = a_Color;
-
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
- gl_Position = u_Mvp * (vec4(project_pos.xy, wallHeight, 1.0));
- } else {
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, wallHeight, 1.0));
- }
-
- setPickingColor(a_PickingColor);
-}
diff --git a/packages/layers/src/mask/index.ts b/packages/layers/src/mask/index.ts
index a8513d4fe9..06ec2878fd 100644
--- a/packages/layers/src/mask/index.ts
+++ b/packages/layers/src/mask/index.ts
@@ -1,7 +1,17 @@
import BaseLayer from '../core/BaseLayer';
import { IMaskLayerStyleOptions } from '../core/interface';
import MaskModels, { MaskModelType } from './models';
-
+import {
+ TYPES,
+ ICameraService,
+ ICoordinateSystemService,
+ ILayerPlugin,
+ ILayerService,
+ IMapService,
+ IRendererService,
+ IShaderModuleService,
+ IStyleAttributeService,
+} from '@antv/l7-core';
export default class MaskLayer extends BaseLayer {
public type: string = 'MaskLayer';
public defaultSourceConfig: {
@@ -12,16 +22,97 @@ export default class MaskLayer extends BaseLayer {
};
};
};
+
+ public init() {
+ // 设置配置项
+ const sceneId = this.container.get(TYPES.SceneID);
+
+ this.configService.setLayerConfig(sceneId, this.id, this.rawConfig);
+ this.layerType = this.rawConfig.layerType;
+
+ this.rendererService = this.container.get(
+ TYPES.IRendererService,
+ );
+ this.layerService = this.container.get(TYPES.ILayerService);
+
+ this.mapService = this.container.get(TYPES.IMapService);
+
+ this.cameraService = this.container.get(
+ TYPES.ICameraService,
+ );
+ this.coordinateService = this.container.get(
+ TYPES.ICoordinateSystemService,
+ );
+ this.shaderModuleService = this.container.get(
+ TYPES.IShaderModuleService,
+ );
+ this.postProcessingPassFactory = this.container.get(
+ TYPES.IFactoryPostProcessingPass,
+ );
+ this.normalPassFactory = this.container.get(TYPES.IFactoryNormalPass);
+
+ // 图层容器服务
+ this.styleAttributeService = this.container.get(
+ TYPES.IStyleAttributeService,
+ );
+
+ // 完成样式服务注册完成前添加的属性
+ this.pendingStyleAttributes.forEach(
+ ({ attributeName, attributeField, attributeValues, updateOptions }) => {
+ this.styleAttributeService.updateStyleAttribute(
+ attributeName,
+ {
+ // @ts-ignore
+ scale: {
+ field: attributeField,
+ ...this.splitValuesAndCallbackInAttribute(
+ // @ts-ignore
+ attributeValues,
+ // @ts-ignore
+ this.getLayerConfig()[attributeName],
+ ),
+ },
+ },
+ // @ts-ignore
+ updateOptions,
+ );
+ },
+ );
+ this.pendingStyleAttributes = [];
+
+ // 获取插件集
+ this.plugins = this.container.getAll(TYPES.ILayerPlugin);
+ // 完成插件注册,传入场景和图层容器内的服务
+ for (const plugin of this.plugins) {
+ plugin.apply(this, {
+ rendererService: this.rendererService,
+ mapService: this.mapService,
+ styleAttributeService: this.styleAttributeService,
+ normalPassFactory: this.normalPassFactory,
+ postProcessingPassFactory: this.postProcessingPassFactory,
+ });
+ }
+
+ // 触发 init 生命周期插件
+ this.hooks.init.call();
+ this.hooks.afterInit.call();
+
+ return this;
+ }
+
public buildModels() {
const shape = this.getModelType();
this.layerModel = new MaskModels[shape](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
return {
diff --git a/packages/layers/src/mask/models/fill.ts b/packages/layers/src/mask/models/fill.ts
index 3b9362f277..a1842d8365 100644
--- a/packages/layers/src/mask/models/fill.ts
+++ b/packages/layers/src/mask/models/fill.ts
@@ -1,18 +1,21 @@
import { gl, IModel } from '@antv/l7-core';
+import { rgb2arr } from '@antv/l7-utils';
import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
import { IMaskLayerStyleOptions } from '../../core/interface';
import { polygonTriangulation } from '../../core/triangulation';
-import mask_frag from '../shaders/mask_frag.glsl';
+import mask_frag from '../../shader/minify_frag.glsl';
import mask_vert from '../shaders/mask_vert.glsl';
export default class MaskModel extends BaseModel {
public getUninforms() {
const {
opacity = 0,
+ color = '#000'
} = this.layer.getLayerConfig() as IMaskLayerStyleOptions;
return {
u_opacity: isNumber(opacity) ? opacity : 0.0,
+ u_color: rgb2arr(color),
};
}
@@ -43,6 +46,7 @@ export default class MaskModel extends BaseModel {
zpass: gl.REPLACE,
},
},
+ pick: false
})
.then((model) => {
callbackModel([model]);
@@ -53,9 +57,8 @@ export default class MaskModel extends BaseModel {
});
}
- public clearModels() {
- this.dataTexture?.destroy();
- this.layerService.clear();
+ public clearModels(refresh = true) {
+ refresh && this.layerService.clear();
}
protected registerBuiltinAttributes() {
diff --git a/packages/layers/src/mask/shaders/mask_frag.glsl b/packages/layers/src/mask/shaders/mask_frag.glsl
deleted file mode 100644
index f1debbb1fb..0000000000
--- a/packages/layers/src/mask/shaders/mask_frag.glsl
+++ /dev/null
@@ -1,7 +0,0 @@
-uniform float u_opacity;
-varying vec4 v_Color;
-
-void main() {
- gl_FragColor = v_Color;
- gl_FragColor.a *= u_opacity;
-}
diff --git a/packages/layers/src/mask/shaders/mask_vert.glsl b/packages/layers/src/mask/shaders/mask_vert.glsl
index dbceb0975e..125b5ac452 100644
--- a/packages/layers/src/mask/shaders/mask_vert.glsl
+++ b/packages/layers/src/mask/shaders/mask_vert.glsl
@@ -1,17 +1,11 @@
-attribute vec4 a_Color;
attribute vec3 a_Position;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
-varying vec4 v_Color;
-
#pragma include "projection"
void main() {
-
- v_Color = a_Color;
vec4 project_pos = project_position(vec4(a_Position, 1.0));
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
diff --git a/packages/layers/src/plugins/DataMappingPlugin.ts b/packages/layers/src/plugins/DataMappingPlugin.ts
index 33bbdbf25f..ccd80837d7 100644
--- a/packages/layers/src/plugins/DataMappingPlugin.ts
+++ b/packages/layers/src/plugins/DataMappingPlugin.ts
@@ -1,7 +1,6 @@
import {
IEncodeFeature,
IFontService,
- IGlobalConfigService,
ILayer,
ILayerPlugin,
IMapService,
@@ -20,9 +19,6 @@ import { ILineLayerStyleOptions } from '../core/interface';
@injectable()
export default class DataMappingPlugin implements ILayerPlugin {
- @inject(TYPES.IGlobalConfigService)
- private readonly configService: IGlobalConfigService;
-
@inject(TYPES.IMapService)
private readonly mapService: IMapService;
@@ -45,7 +41,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
this.generateMaping(layer, { styleAttributeService });
});
}
- // this.generateMaping(layer, { styleAttributeService });
});
layer.hooks.beforeRenderData.tap('DataMappingPlugin', () => {
@@ -59,8 +54,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
});
}
- // this.generateMaping(layer, { styleAttributeService });
-
return true;
});
@@ -90,20 +83,24 @@ export default class DataMappingPlugin implements ILayerPlugin {
if (attributesToRemapping.length) {
// 过滤数据
if (filter?.needRemapping) {
- layer.setEncodedData(
- this.mapping(layer, attributes, filterData, undefined, bottomColor),
+ const encodeData = this.mapping(
+ layer,
+ attributes,
+ filterData,
+ undefined,
+ bottomColor,
);
+ layer.setEncodedData(encodeData);
filter.needRemapping = false;
} else {
- layer.setEncodedData(
- this.mapping(
- layer,
- attributesToRemapping,
- filterData,
- layer.getEncodedData(),
- bottomColor,
- ),
+ const encodeData = this.mapping(
+ layer,
+ attributesToRemapping,
+ filterData,
+ layer.getEncodedData(),
+ bottomColor,
);
+ layer.setEncodedData(encodeData);
}
// 处理文本更新
layer.emit('remapping', null);
@@ -127,23 +124,18 @@ export default class DataMappingPlugin implements ILayerPlugin {
return this.applyAttributeMapping(filter, record, bottomColor)[0];
});
}
- layer.setEncodedData(
- this.mapping(layer, attributes, filterData, undefined, bottomColor),
+ const encodeData = this.mapping(
+ layer,
+ attributes,
+ filterData,
+ undefined,
+ bottomColor,
);
+ layer.setEncodedData(encodeData);
// 对外暴露事件
layer.emit('dataUpdate', null);
}
- private getArrowPoints(p1: Position, p2: Position) {
- const dir = [p2[0] - p1[0], p2[1] - p1[1]];
- const normalizeDir = normalize(dir);
- const arrowPoint = [
- p1[0] + normalizeDir[0] * 0.0001,
- p1[1] + normalizeDir[1] * 0.0001,
- ];
- return arrowPoint;
- }
-
private mapping(
layer: ILayer,
attributes: IStyleAttribute[],
@@ -155,7 +147,14 @@ export default class DataMappingPlugin implements ILayerPlugin {
arrow = {
enable: false,
},
+ usage,
} = layer.getLayerConfig() as ILineLayerStyleOptions;
+ if (usage === 'basemap') {
+ return this.mapLayerMapping(layer, attributes, data, predata);
+ }
+ const usedAttributes = attributes.filter(
+ (attribute) => attribute.scale !== undefined,
+ );
const mappedData = data.map((record: IParseDataItem, i) => {
const preRecord = predata ? predata[i] : {};
const encodeRecord: IEncodeFeature = {
@@ -163,25 +162,88 @@ export default class DataMappingPlugin implements ILayerPlugin {
coordinates: record.coordinates,
...preRecord,
};
- attributes
- .filter((attribute) => attribute.scale !== undefined)
- .forEach((attribute: IStyleAttribute) => {
- // console.log('record', record)
- let values = this.applyAttributeMapping(
- attribute,
- record,
- minimumColor,
+ usedAttributes.forEach((attribute: IStyleAttribute) => {
+ let values = this.applyAttributeMapping(
+ attribute,
+ record,
+ minimumColor,
+ );
+ attribute.needRemapping = false;
+
+ // TODO: 支持每个属性配置 postprocess
+ if (attribute.name === 'color') {
+ values = values.map((c: unknown) => {
+ return rgb2arr(c as string);
+ });
+ }
+ // @ts-ignore
+ encodeRecord[attribute.name] =
+ Array.isArray(values) && values.length === 1 ? values[0] : values;
+
+ // 增加对 layer/text/iconfont unicode 映射的解析
+ if (attribute.name === 'shape') {
+ encodeRecord.shape = this.fontService.getIconFontKey(
+ encodeRecord[attribute.name] as string,
);
- // console.log('values', values)
+ }
+ });
+
+ if (
+ arrow.enable &&
+ (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')
+ ) {
+ // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
+ const coords = encodeRecord.coordinates as Position[];
+ // @ts-ignore
+ if (layer.arrowInsertCount < layer.encodeDataLength) {
+ // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
+ const arrowPoint = this.getArrowPoints(coords[0], coords[1]);
+ encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
+ // @ts-ignore
+ layer.arrowInsertCount++;
+ }
+ }
+ return encodeRecord;
+ }) as IEncodeFeature[];
+
+ // 调整数据兼容 Amap2.0
+ this.adjustData2Amap2Coordinates(mappedData, layer);
+
+ // 调整数据兼容 SimpleCoordinates
+ this.adjustData2SimpleCoordinates(mappedData);
+
+ return mappedData;
+ }
+
+ private mapLayerMapping(
+ layer: ILayer,
+ attributes: IStyleAttribute[],
+ data: IParseDataItem[],
+ predata?: IEncodeFeature[],
+ ): IEncodeFeature[] {
+ const usedAttributes = attributes.filter(
+ (attribute) => attribute.scale !== undefined,
+ );
+ const mappedData = data.map((record: IParseDataItem, i) => {
+ const preRecord = predata ? predata[i] : {};
+ const encodeRecord: IEncodeFeature = {
+ id: record._id,
+ coordinates: record.coordinates,
+ ...preRecord,
+ };
+ usedAttributes.forEach((attribute: IStyleAttribute) => {
+ if (
+ attribute.name === 'shape' &&
+ // @ts-ignore
+ layer.shapeOption?.field === 'simple'
+ ) {
+ encodeRecord[attribute.name] = 'simple';
+ attribute.needRemapping = false;
+ } else {
+ const values = this.applyMapLayerAttributeMapping(attribute, record);
+
attribute.needRemapping = false;
- // TODO: 支持每个属性配置 postprocess
- if (attribute.name === 'color') {
- // console.log('attribute', attribute)
- values = values.map((c: unknown) => {
- return rgb2arr(c as string);
- });
- }
// @ts-ignore
encodeRecord[attribute.name] =
Array.isArray(values) && values.length === 1 ? values[0] : values;
@@ -192,27 +254,19 @@ export default class DataMappingPlugin implements ILayerPlugin {
encodeRecord[attribute.name] as string,
);
}
- });
+ }
+ });
- if (
- arrow.enable &&
- (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')
- ) {
- // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
- const coords = encodeRecord.coordinates as Position[];
- const arrowPoint = this.getArrowPoints(coords[0], coords[1]);
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
+ if (encodeRecord.size === undefined) {
+ // in case not set size
+ encodeRecord.size = 1;
}
return encodeRecord;
}) as IEncodeFeature[];
- // console.log('mappedData', mappedData)
// 调整数据兼容 Amap2.0
this.adjustData2Amap2Coordinates(mappedData, layer);
- // 调整数据兼容 SimpleCoordinates
- this.adjustData2SimpleCoordinates(mappedData);
-
return mappedData;
}
@@ -264,11 +318,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
}
}
- private getLayerCenter(layer: ILayer) {
- const source = layer.getSource();
- return source.center;
- }
-
private adjustData2SimpleCoordinates(mappedData: IEncodeFeature[]) {
if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
mappedData.map((d) => {
@@ -280,6 +329,11 @@ export default class DataMappingPlugin implements ILayerPlugin {
}
}
+ private getLayerCenter(layer: ILayer) {
+ const source = layer.getSource();
+ return source.center;
+ }
+
private unProjectCoordinates(coordinates: any) {
if (typeof coordinates[0] === 'number') {
return this.mapService.simpleMapCoord.unproject(
@@ -337,8 +391,6 @@ export default class DataMappingPlugin implements ILayerPlugin {
params.push(record[field]);
}
});
- // console.log('params', params)
- // console.log('attribute', attribute)
const mappingResult = attribute.mapping ? attribute.mapping(params) : [];
if (attribute.name === 'color' && !isColor(mappingResult[0])) {
@@ -347,4 +399,37 @@ export default class DataMappingPlugin implements ILayerPlugin {
return mappingResult;
// return attribute.mapping ? attribute.mapping(params) : [];
}
+
+ private applyMapLayerAttributeMapping(
+ attribute: IStyleAttribute,
+ record: { [key: string]: unknown },
+ ) {
+ if (!attribute.scale) {
+ return [];
+ }
+ const scalers = attribute?.scale?.scalers || [];
+ const params: unknown[] = [];
+
+ scalers.forEach(({ field }) => {
+ if (
+ record.hasOwnProperty(field) ||
+ attribute.scale?.type === 'variable'
+ ) {
+ params.push(record[field]);
+ }
+ });
+
+ const mappingResult = attribute.mapping ? attribute.mapping(params) : [];
+ return mappingResult;
+ }
+
+ private getArrowPoints(p1: Position, p2: Position) {
+ const dir = [p2[0] - p1[0], p2[1] - p1[1]];
+ const normalizeDir = normalize(dir);
+ const arrowPoint = [
+ p1[0] + normalizeDir[0] * 0.0001,
+ p1[1] + normalizeDir[1] * 0.0001,
+ ];
+ return arrowPoint;
+ }
}
diff --git a/packages/layers/src/plugins/DataSourcePlugin.ts b/packages/layers/src/plugins/DataSourcePlugin.ts
index 1b248f9e05..c03855ab40 100644
--- a/packages/layers/src/plugins/DataSourcePlugin.ts
+++ b/packages/layers/src/plugins/DataSourcePlugin.ts
@@ -24,7 +24,6 @@ export default class DataSourcePlugin implements ILayerPlugin {
this.updateClusterData(layer);
});
}
- // this.updateClusterData(layer);
});
// 检测数据是否需要更新
@@ -37,6 +36,8 @@ export default class DataSourcePlugin implements ILayerPlugin {
}
private updateClusterData(layer: ILayer): boolean {
+ // Tip: 矢量瓦片不需要进行聚合操作
+ if (layer.isTileLayer || layer.tileLayer) return false;
const source = layer.getSource();
const cluster = source.cluster;
const { zoom = 0 } = source.clusterOptions;
diff --git a/packages/layers/src/plugins/FeatureScalePlugin.ts b/packages/layers/src/plugins/FeatureScalePlugin.ts
index 54c9d7e66b..9163be661e 100644
--- a/packages/layers/src/plugins/FeatureScalePlugin.ts
+++ b/packages/layers/src/plugins/FeatureScalePlugin.ts
@@ -1,5 +1,4 @@
import {
- IGlobalConfigService,
ILayer,
ILayerPlugin,
IScale,
@@ -10,14 +9,13 @@ import {
ScaleTypeName,
ScaleTypes,
StyleScaleType,
- TYPES,
IParserData,
} from '@antv/l7-core';
import { IParseDataItem } from '@antv/l7-source';
import { extent } from 'd3-array';
import * as d3interpolate from 'd3-interpolate';
import * as d3 from 'd3-scale';
-import { inject, injectable } from 'inversify';
+import { injectable } from 'inversify';
import { isNil, isString, uniq } from 'lodash';
import 'reflect-metadata';
@@ -42,13 +40,6 @@ const scaleMap = {
*/
@injectable()
export default class FeatureScalePlugin implements ILayerPlugin {
- @inject(TYPES.IGlobalConfigService)
- private readonly configService: IGlobalConfigService;
- // key = field_attribute name
- private scaleCache: {
- [field: string]: IStyleScale;
- } = {};
-
private scaleOptions: IScaleOptions = {};
private getSourceData(layer: ILayer, callback: (data: IParserData) => void) {
@@ -79,14 +70,6 @@ export default class FeatureScalePlugin implements ILayerPlugin {
this.caculateScalesForAttributes(attributes || [], dataArray);
}
});
- // const { dataArray } = layer.getSource().data;
- // if (dataArray.length === 0) {
- // return;
- // }
- // this.caculateScalesForAttributes(
- // attributes || [],
- // dataArray as IParseDataItem[],
- // );
});
// 检测数据是否需要更新
@@ -101,15 +84,6 @@ export default class FeatureScalePlugin implements ILayerPlugin {
this.caculateScalesForAttributes(attributes || [], dataArray);
layer.layerModelNeedUpdate = true;
});
- // const { dataArray } = layer.getSource().data;
- // if (dataArray.length === 0) {
- // return;
- // }
- // this.caculateScalesForAttributes(
- // attributes || [],
- // dataArray
- // );
- // layer.layerModelNeedUpdate = true;
return true;
});
@@ -131,20 +105,6 @@ export default class FeatureScalePlugin implements ILayerPlugin {
this.caculateScalesForAttributes(attributesToRescale, dataArray);
}
});
-
- // const { dataArray } = layer.getSource().data;
- // if (dataArray.length === 0) {
- // return;
- // }
- // const attributesToRescale = attributes.filter(
- // (attribute) => attribute.needRescale,
- // );
- // if (attributesToRescale.length) {
- // this.caculateScalesForAttributes(
- // attributesToRescale,
- // dataArray,
- // );
- // }
}
});
}
@@ -156,7 +116,6 @@ export default class FeatureScalePlugin implements ILayerPlugin {
attributes: IStyleAttribute[],
dataArray: IParseDataItem[],
) {
- this.scaleCache = {};
attributes.forEach((attribute) => {
if (attribute.scale) {
// 创建Scale
diff --git a/packages/layers/src/plugins/LayerAnimateStylePlugin.ts b/packages/layers/src/plugins/LayerAnimateStylePlugin.ts
index a572e341de..b95743c080 100644
--- a/packages/layers/src/plugins/LayerAnimateStylePlugin.ts
+++ b/packages/layers/src/plugins/LayerAnimateStylePlugin.ts
@@ -1,33 +1,19 @@
-import {
- ICameraService,
- ILayer,
- ILayerPlugin,
- IModel,
- IRendererService,
- TYPES,
-} from '@antv/l7-core';
-import { inject, injectable } from 'inversify';
+import { ILayer, ILayerPlugin, IModel } from '@antv/l7-core';
+import { injectable } from 'inversify';
import 'reflect-metadata';
@injectable()
export default class LayerAnimateStylePlugin implements ILayerPlugin {
- @inject(TYPES.ICameraService)
- private readonly cameraService: ICameraService;
-
- @inject(TYPES.IRendererService)
- private readonly rendererService: IRendererService;
-
public apply(layer: ILayer) {
- // layer.hooks.beforeRender.tap('LayerAnimateStylePlugin', () => {
-
- // })
layer.hooks.beforeRender.tap('LayerAnimateStylePlugin', () => {
- // 重新计算坐标系参数
- layer.models.forEach((model: IModel) => {
- model.addUniforms({
- ...layer.layerModel.getAnimateUniforms(),
+ // @ts-ignore
+ const aniamateStatus = layer.aniamateStatus;
+ aniamateStatus &&
+ layer.models.forEach((model: IModel) => {
+ model.addUniforms({
+ ...layer.layerModel.getAnimateUniforms(),
+ });
});
- });
});
}
}
diff --git a/packages/layers/src/plugins/LayerModelPlugin.ts b/packages/layers/src/plugins/LayerModelPlugin.ts
index 922d22d44f..4bb7853043 100644
--- a/packages/layers/src/plugins/LayerModelPlugin.ts
+++ b/packages/layers/src/plugins/LayerModelPlugin.ts
@@ -11,8 +11,6 @@ export default class LayerModelPlugin implements ILayerPlugin {
layer.prepareBuildModel();
// 初始化 Model
layer.buildModels();
- // emit layer model loaded
- layer.emit('modelLoaded', null);
layer.styleNeedUpdate = false;
}
@@ -22,8 +20,6 @@ export default class LayerModelPlugin implements ILayerPlugin {
layer.clearModels();
// 初始化 Model
layer.buildModels();
- // emit layer model loaded
- layer.emit('modelLoaded', null);
layer.layerModelNeedUpdate = false;
}
diff --git a/packages/layers/src/plugins/LightingPlugin.ts b/packages/layers/src/plugins/LightingPlugin.ts
index 5b3dbcab1d..3c97a53dd1 100644
--- a/packages/layers/src/plugins/LightingPlugin.ts
+++ b/packages/layers/src/plugins/LightingPlugin.ts
@@ -65,8 +65,6 @@ const DEFAULT_SPOT_LIGHT = {
blur: 5,
};
-const COLOR_ATTRIBUTES = ['ambient', 'diffuse', 'specular'];
-
export function generateLightingUniforms(
lights?: Array>,
) {
@@ -88,12 +86,6 @@ export function generateLightingUniforms(
const lightsUniformName = lightTypeUniformMap[type].lights;
const lightsNumUniformName = lightTypeUniformMap[type].num;
- // Object.keys(rest).forEach(key => {
- // if (Util.isString(rest[key]) && COLOR_ATTRIBUTES.indexOf(key) > -1) {
- // rest[key] = ColorUtil.color2RGBA(rest[key]).slice(0, 3);
- // }
- // });
-
// @ts-ignore
const num = lightsMap[lightsNumUniformName];
// @ts-ignore
diff --git a/packages/layers/src/plugins/MultiPassRendererPlugin.ts b/packages/layers/src/plugins/MultiPassRendererPlugin.ts
index 350e7af4a3..f5e7539db9 100644
--- a/packages/layers/src/plugins/MultiPassRendererPlugin.ts
+++ b/packages/layers/src/plugins/MultiPassRendererPlugin.ts
@@ -1,13 +1,11 @@
import {
- IGlobalConfigService,
ILayer,
ILayerPlugin,
IPass,
IPostProcessingPass,
IRendererService,
- TYPES,
} from '@antv/l7-core';
-import { inject, injectable } from 'inversify';
+import { injectable } from 'inversify';
import 'reflect-metadata';
import { createMultiPassRenderer } from '../utils/multiPassRender';
@@ -26,9 +24,6 @@ import { createMultiPassRenderer } from '../utils/multiPassRender';
*/
@injectable()
export default class MultiPassRendererPlugin implements ILayerPlugin {
- @inject(TYPES.IGlobalConfigService)
- private readonly configService: IGlobalConfigService;
-
private enabled: boolean;
public apply(
diff --git a/packages/layers/src/plugins/PixelPickingPlugin.ts b/packages/layers/src/plugins/PixelPickingPlugin.ts
index 43600d9d24..06a11db22a 100644
--- a/packages/layers/src/plugins/PixelPickingPlugin.ts
+++ b/packages/layers/src/plugins/PixelPickingPlugin.ts
@@ -26,7 +26,6 @@ export default class PixelPickingPlugin implements ILayerPlugin {
public apply(
layer: ILayer,
{
- rendererService,
styleAttributeService,
}: {
rendererService: IRendererService;
@@ -35,8 +34,7 @@ export default class PixelPickingPlugin implements ILayerPlugin {
) {
// TODO: 由于 Shader 目前无法根据是否开启拾取进行内容修改,因此即使不开启也需要生成 a_PickingColor
layer.hooks.init.tap('PixelPickingPlugin', () => {
- const { enablePicking, enableMultiPassRenderer } = layer.getLayerConfig();
- // const enablePicking = true;
+ const { enablePicking } = layer.getLayerConfig();
styleAttributeService.registerStyleAttribute({
name: 'pickingColor',
type: AttributeType.Attribute,
@@ -48,7 +46,7 @@ export default class PixelPickingPlugin implements ILayerPlugin {
},
size: 3,
// TODO: 固定 feature range 范围内的 pickingColor 都是固定的,可以生成 cache
- update: (feature: IEncodeFeature, featureIdx: number) => {
+ update: (feature: IEncodeFeature) => {
// 只有开启拾取才需要 encode
const { id } = feature;
return enablePicking ? encodePickingColor(id as number) : [0, 0, 0];
@@ -57,7 +55,6 @@ export default class PixelPickingPlugin implements ILayerPlugin {
});
});
// 必须要与 PixelPickingPass 结合使用,因此必须开启 multiPassRenderer
- // if (layer.multiPassRenderer) {
layer.hooks.beforePickingEncode.tap('PixelPickingPlugin', () => {
const { enablePicking } = layer.getLayerConfig();
if (enablePicking && layer.isVisible()) {
@@ -85,36 +82,21 @@ export default class PixelPickingPlugin implements ILayerPlugin {
'PixelPickingPlugin',
(pickedColor: number[]) => {
const { highlightColor, activeMix = 0 } = layer.getLayerConfig();
- // const {
- // highlightColor,
- // activeMix = 0,
- // enableSelect,
- // } = layer.getLayerConfig();
+
const highlightColorInArray =
typeof highlightColor === 'string'
? rgb2arr(highlightColor)
: highlightColor || [1, 0, 0, 1];
- // const { selectColor } = layer.getLayerConfig();
- // const selectColorInArray =
- // typeof selectColor === 'string'
- // ? rgb2arr(selectColor)
- // : selectColor || [1, 0, 0, 1];
layer.updateLayerConfig({
pickedFeatureID: decodePickingColor(new Uint8Array(pickedColor)),
});
- // const currentSelectedId = layer.getCurrentSelectedId();
layer.models.forEach((model) =>
model.addUniforms({
u_PickingStage: PickingStage.HIGHLIGHT,
u_PickingColor: pickedColor,
u_HighlightColor: highlightColorInArray.map((c) => c * 255),
u_activeMix: activeMix,
- // u_CurrentSelectedId: currentSelectedId
- // ? encodePickingColor(layer.getCurrentSelectedId()!)
- // : [0, 0, 0],
- // u_SelectColor: selectColorInArray.map((c) => c * 255),
- // u_EnableSelect: +(enableSelect || false),
}),
);
},
@@ -144,6 +126,5 @@ export default class PixelPickingPlugin implements ILayerPlugin {
);
},
);
- // }
}
}
diff --git a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts
index 3e1b8edaf9..515c2f79b2 100644
--- a/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts
+++ b/packages/layers/src/plugins/RegisterStyleAttributePlugin.ts
@@ -21,12 +21,50 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
}: { styleAttributeService: IStyleAttributeService },
) {
layer.hooks.init.tap('RegisterStyleAttributePlugin', () => {
- this.registerBuiltinAttributes(styleAttributeService);
+ this.registerBuiltinAttributes(styleAttributeService, layer);
});
}
private registerBuiltinAttributes(
styleAttributeService: IStyleAttributeService,
+ layer: ILayer,
+ ) {
+ // 过滤 tileGroup layer (瓦片图层)
+ const source = layer.getSource();
+ switch (source.parser.type) {
+ case 'mvt':
+ case 'testTile':
+ case 'rasterTile':
+ // layer 仅作为 group 使用
+ return;
+ }
+
+ if (layer.type === 'MaskLayer') {
+ this.registerPositionAttribute(styleAttributeService);
+ return;
+ }
+
+ const { usage } = layer.getLayerConfig();
+ if (usage === 'basemap ') {
+ this.registerPositionAttribute(styleAttributeService);
+ return;
+ }
+
+ if (layer.isTileLayer) {
+ this.registerPositionAttribute(styleAttributeService);
+ this.registerColorAttribute(styleAttributeService);
+ return;
+ }
+
+ // Tip: normal render layer
+ this.registerPositionAttribute(styleAttributeService);
+ this.registerFilterAttribute(styleAttributeService);
+ this.registerColorAttribute(styleAttributeService);
+ this.registerVertexIdAttribute(styleAttributeService);
+ }
+
+ private registerPositionAttribute(
+ styleAttributeService: IStyleAttributeService,
) {
styleAttributeService.registerStyleAttribute({
name: 'position',
@@ -49,7 +87,11 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
},
},
});
+ }
+ private registerFilterAttribute(
+ styleAttributeService: IStyleAttributeService,
+ ) {
styleAttributeService.registerStyleAttribute({
name: 'filter',
type: AttributeType.Attribute,
@@ -62,12 +104,17 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
type: gl.FLOAT,
},
size: 1,
- update: (feature: IEncodeFeature, featureIdx: number) => {
+ update: (feature: IEncodeFeature) => {
const { filter } = feature;
return filter ? [1] : [0];
},
},
});
+ }
+
+ private registerColorAttribute(
+ styleAttributeService: IStyleAttributeService,
+ ) {
styleAttributeService.registerStyleAttribute({
name: 'color',
type: AttributeType.Attribute,
@@ -80,12 +127,17 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
type: gl.FLOAT,
},
size: 4,
- update: (feature: IEncodeFeature, featureIdx: number) => {
+ update: (feature: IEncodeFeature) => {
const { color } = feature;
return !color || !color.length ? [1, 1, 1, 1] : color;
},
},
});
+ }
+
+ private registerVertexIdAttribute(
+ styleAttributeService: IStyleAttributeService,
+ ) {
styleAttributeService.registerStyleAttribute({
// 统一注册每个顶点的唯一编号(目前用于样式的数据映射计算使用)
name: 'vertexId',
@@ -99,12 +151,7 @@ export default class RegisterStyleAttributePlugin implements ILayerPlugin {
type: gl.FLOAT,
},
size: 1,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
+ update: (feature: IEncodeFeature, featureIdx: number) => {
return [featureIdx];
},
},
diff --git a/packages/layers/src/plugins/ShaderUniformPlugin.ts b/packages/layers/src/plugins/ShaderUniformPlugin.ts
index 4815575f59..f9d2249f03 100644
--- a/packages/layers/src/plugins/ShaderUniformPlugin.ts
+++ b/packages/layers/src/plugins/ShaderUniformPlugin.ts
@@ -85,7 +85,7 @@ export default class ShaderUniformPlugin implements ILayerPlugin {
u_DevicePixelRatio: $window.devicePixelRatio,
// u_ModelMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,
- // TODO: 当前地图是否在拖动
+ // Tip: 当前地图是否在拖动
u_shaderPick: Number(layer.getShaderPickStat()),
});
});
diff --git a/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts b/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts
index 2642ee3ef0..0381064e82 100644
--- a/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts
+++ b/packages/layers/src/plugins/UpdateStyleAttributePlugin.ts
@@ -17,11 +17,6 @@ export default class UpdateStyleAttributePlugin implements ILayerPlugin {
this.initStyleAttribute(layer, { styleAttributeService });
});
- // layer.hooks.beforeRenderData.tap('styleAttributeService', () => {
- // // layer.layerModelNeedUpdate = true;
- // return true;
- // });
-
layer.hooks.beforeRender.tap('UpdateStyleAttributePlugin', () => {
if (layer.layerModelNeedUpdate) {
return;
@@ -37,12 +32,7 @@ export default class UpdateStyleAttributePlugin implements ILayerPlugin {
) {
const attributes = styleAttributeService.getLayerStyleAttributes() || [];
const filter = styleAttributeService.getLayerStyleAttribute('filter');
- const shape = styleAttributeService.getLayerStyleAttribute('shape');
- if (
- filter &&
- filter.needRegenerateVertices // ||
- // (shape && shape.needRegenerateVertices) // TODO:Shape 更新重新build
- ) {
+ if (filter && filter.needRegenerateVertices) {
layer.layerModelNeedUpdate = true;
attributes.forEach((attr) => (attr.needRegenerateVertices = false));
return;
diff --git a/packages/layers/src/point/index.ts b/packages/layers/src/point/index.ts
index 92236959b3..ee70cbf4cd 100644
--- a/packages/layers/src/point/index.ts
+++ b/packages/layers/src/point/index.ts
@@ -23,11 +23,15 @@ export default class PointLayer extends BaseLayer {
this.layerModel.initModels((models) => {
this.models = models;
this.layerService.updateLayerRenderList();
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
/**
diff --git a/packages/layers/src/point/models/fillmage.ts b/packages/layers/src/point/models/fillmage.ts
index ea1ac3cb8a..5994ac04d9 100644
--- a/packages/layers/src/point/models/fillmage.ts
+++ b/packages/layers/src/point/models/fillmage.ts
@@ -347,7 +347,7 @@ export default class FillImageModel extends BaseModel {
});
// this.layer.render();
// TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层
- this.layer.renderLayers();
+ this.layerService.throttleRenderLayers();
return;
}
this.texture = createTexture2D({
diff --git a/packages/layers/src/point/models/image.ts b/packages/layers/src/point/models/image.ts
index cf8e3fce89..900fcabc48 100644
--- a/packages/layers/src/point/models/image.ts
+++ b/packages/layers/src/point/models/image.ts
@@ -183,7 +183,7 @@ export default class ImageModel extends BaseModel {
mipmap: true,
});
// TODO: 更新完纹理后在更新的图层的时候需要更新所有的图层
- this.layer.renderLayers();
+ this.layerService.throttleRenderLayers();
return;
}
this.texture = createTexture2D({
diff --git a/packages/layers/src/point/models/normal.ts b/packages/layers/src/point/models/normal.ts
index 11a1da0f0c..ef570f32fb 100644
--- a/packages/layers/src/point/models/normal.ts
+++ b/packages/layers/src/point/models/normal.ts
@@ -1,6 +1,5 @@
import {
AttributeType,
- BlendType,
gl,
IEncodeFeature,
IModel,
@@ -31,55 +30,10 @@ export default class NormalModel extends BaseModel {
public getUninforms(): IModelUniform {
const {
opacity = 1,
- offsets = [0, 0],
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
- if (
- this.dataTextureTest &&
- this.dataTextureNeedUpdate({
- opacity,
- offsets,
- })
- ) {
- // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
- this.judgeStyleAttributes({
- opacity,
- offsets,
- });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
return {
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
u_opacity: isNumber(opacity) ? opacity : 1.0,
- u_offsets: this.isOffsetStatic(offsets)
- ? (offsets as [number, number])
- : [0, 0],
};
}
@@ -104,6 +58,7 @@ export default class NormalModel extends BaseModel {
primitive: gl.POINTS,
blend: this.getBlend(),
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
@@ -115,7 +70,6 @@ export default class NormalModel extends BaseModel {
}
public clearModels() {
- this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
@@ -134,9 +88,6 @@ export default class NormalModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 1 } = feature;
return Array.isArray(size) ? [size[0]] : [size as number];
@@ -144,10 +95,4 @@ export default class NormalModel extends BaseModel {
},
});
}
-
- private defaultStyleOptions(): Partial {
- return {
- blend: BlendType.additive,
- };
- }
}
diff --git a/packages/layers/src/point/models/radar.ts b/packages/layers/src/point/models/radar.ts
index f398634d5a..0e001efcad 100644
--- a/packages/layers/src/point/models/radar.ts
+++ b/packages/layers/src/point/models/radar.ts
@@ -26,62 +26,15 @@ export default class RadarModel extends BaseModel {
public getUninforms(): IModelUniform {
const {
opacity = 1,
- offsets = [0, 0],
blend,
speed = 1,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
- if (
- this.dataTextureTest &&
- this.dataTextureNeedUpdate({
- opacity,
- offsets,
- })
- ) {
- // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
- this.judgeStyleAttributes({
- opacity,
- offsets,
- });
-
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
return {
u_isMeter: Number(this.isMeter),
u_speed: speed,
u_additive: blend === 'additive' ? 1.0 : 0.0,
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
-
u_opacity: isNumber(opacity) ? opacity : 1.0,
- u_offsets: this.isOffsetStatic(offsets)
- ? (offsets as [number, number])
- : [0, 0],
};
}
public getAnimateUniforms(): IModelUniform {
@@ -218,7 +171,6 @@ export default class RadarModel extends BaseModel {
attributeIdx: number,
) => {
const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
-
const extrudeIndex = (attributeIdx % 4) * 3;
return [
extrude[extrudeIndex],
@@ -244,9 +196,6 @@ export default class RadarModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 5 } = feature;
return Array.isArray(size)
@@ -255,32 +204,5 @@ export default class RadarModel extends BaseModel {
},
},
});
-
- // point layer size;
- this.styleAttributeService.registerStyleAttribute({
- name: 'shape',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_Shape',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.DYNAMIC_DRAW,
- data: [],
- type: gl.FLOAT,
- },
- size: 1,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
- const { shape = 2 } = feature;
- const shape2d = this.layer.getLayerConfig().shape2d as string[];
- const shapeIndex = shape2d.indexOf(shape as string);
- return [shapeIndex];
- },
- },
- });
}
}
diff --git a/packages/layers/src/point/models/simplePoint.ts b/packages/layers/src/point/models/simplePoint.ts
index d19bbe7cb4..2cb1e07c4b 100644
--- a/packages/layers/src/point/models/simplePoint.ts
+++ b/packages/layers/src/point/models/simplePoint.ts
@@ -1,6 +1,5 @@
import {
AttributeType,
- BlendType,
gl,
IEncodeFeature,
IModel,
@@ -129,14 +128,12 @@ export default class SimplePointModel extends BaseModel {
}
protected registerBuiltinAttributes() {
- // point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'size',
type: AttributeType.Attribute,
descriptor: {
name: 'a_Size',
buffer: {
- // give the WebGL driver a hint that this buffer may change
usage: gl.DYNAMIC_DRAW,
data: [],
type: gl.FLOAT,
@@ -144,9 +141,6 @@ export default class SimplePointModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 1 } = feature;
return Array.isArray(size) ? [size[0]] : [size as number];
@@ -154,10 +148,4 @@ export default class SimplePointModel extends BaseModel {
},
});
}
-
- private defaultStyleOptions(): Partial {
- return {
- blend: BlendType.additive,
- };
- }
}
diff --git a/packages/layers/src/point/models/text.ts b/packages/layers/src/point/models/text.ts
index ace9357245..ccf35c5d80 100644
--- a/packages/layers/src/point/models/text.ts
+++ b/packages/layers/src/point/models/text.ts
@@ -231,6 +231,7 @@ export default class TextModel extends BaseModel {
this.reBuildModel();
return true;
}
+
return false;
}
@@ -253,9 +254,6 @@ export default class TextModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { rotate = 0 } = feature;
return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];
@@ -278,7 +276,6 @@ export default class TextModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[5], vertex[6]];
},
@@ -300,9 +297,6 @@ export default class TextModel extends BaseModel {
size: 1,
update: (
feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
) => {
const { size = 12 } = feature;
return Array.isArray(size) ? [size[0]] : [size as number];
@@ -327,7 +321,6 @@ export default class TextModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[3], vertex[4]];
},
@@ -402,7 +395,7 @@ export default class TextModel extends BaseModel {
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
*/
private generateGlyphLayout(iconfont: boolean) {
- // TODO:更新文字布局
+ // 更新文字布局
const { mapping } = this.fontService;
const {
spacing = 2,
@@ -483,7 +476,6 @@ export default class TextModel extends BaseModel {
anchorPointY: pixels.y,
});
if (box && box.length) {
- // TODO:featureIndex
collisionIndex.insertCollisionBox(box, id);
return true;
} else {
@@ -546,7 +538,7 @@ export default class TextModel extends BaseModel {
})
.then((model) => {
this.layer.models = [model];
- this.layer.renderLayers();
+ this.layerService.throttleRenderLayers();
})
.catch((err) => {
console.warn(err);
diff --git a/packages/layers/src/point/models/tile.ts b/packages/layers/src/point/models/tile.ts
index 9c098433e3..ef859a7f84 100644
--- a/packages/layers/src/point/models/tile.ts
+++ b/packages/layers/src/point/models/tile.ts
@@ -8,95 +8,37 @@ import {
IModel,
IModelUniform,
} from '@antv/l7-core';
-import { getCullFace, getMask } from '@antv/l7-utils';
+import { getCullFace } from '@antv/l7-utils';
import BaseModel from '../../core/BaseModel';
import { IPointLayerStyleOptions } from '../../core/interface';
import { PointFillTriangulation } from '../../core/triangulation';
import point_tile_frag from '../shaders/tile/fill_tile_frag.glsl';
import point_tile_vert from '../shaders/tile/fill_tile_vert.glsl';
-
-import { Version } from '@antv/l7-maps';
export default class FillModel extends BaseModel {
- public meter2coord: number = 1;
- private isMeter: boolean = false;
+
public getUninforms(): IModelUniform {
const {
opacity = 1,
strokeOpacity = 1,
strokeWidth = 0,
stroke = 'rgba(0,0,0,0)',
- offsets = [0, 0],
+
blend,
- blur = 0,
- coord = 'lnglat',
- tileOrigin,
+ // coord = 'lnglat',
+ // tileOrigin,
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
- if (
- this.dataTextureTest &&
- this.dataTextureNeedUpdate({
- opacity,
- strokeOpacity,
- strokeWidth,
- stroke,
- offsets,
- })
- ) {
- // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量
- this.judgeStyleAttributes({
- opacity,
- strokeOpacity,
- strokeWidth,
- stroke,
- offsets,
- });
-
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
return {
- u_tileOrigin: tileOrigin || [0, 0],
- u_coord: coord === 'lnglat' ? 1.0 : 0.0,
-
- u_isMeter: Number(this.isMeter),
- u_blur: blur,
-
+ // u_tileOrigin: tileOrigin || [0, 0],
+ // u_coord: coord === 'lnglat' ? 1.0 : 0.0,
+
u_additive: blend === 'additive' ? 1.0 : 0.0,
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
-
+
u_opacity: Number(opacity),
u_stroke_opacity: Number(strokeOpacity),
u_stroke_width: Number(strokeWidth),
u_stroke_color: this.getStrokeColor(stroke),
- u_offsets: this.isOffsetStatic(offsets)
- ? (offsets as [number, number])
- : [0, 0],
};
}
@@ -113,77 +55,21 @@ export default class FillModel extends BaseModel {
}
public initModels(callbackModel: (models: IModel[]) => void) {
- const {
- unit = 'l7size',
- } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
- const { version } = this.mapService;
- if (
- unit === 'meter' &&
- version !== Version.L7MAP &&
- version !== Version.GLOBEL
- ) {
- this.isMeter = true;
- this.calMeter2Coord();
- }
-
this.buildModels(callbackModel);
}
- /**
- * 计算等面积点图层(unit meter)笛卡尔坐标标度与世界坐标标度的比例
- * @returns
- */
- public calMeter2Coord() {
- const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
- const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
-
- const { version } = this.mapService;
- if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
- const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(
- { lng: center[0], lat: center[1] },
- 0,
- );
- const offsetInMeters = 1;
- const offsetInMercatorCoordinateUnits =
- offsetInMeters * coord.meterInMercatorCoordinateUnits();
- const westCoord = new window.mapboxgl.MercatorCoordinate(
- coord.x - offsetInMercatorCoordinateUnits,
- coord.y,
- coord.z,
- );
- const westLnglat = westCoord.toLngLat();
-
- this.meter2coord = center[0] - westLnglat.lng;
- return;
- }
-
- // @ts-ignore
- const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
- // @ts-ignore
- const m2 = this.mapService.meterToCoord(center, [
- maxLng === minLng ? maxLng + 0.1 : maxLng,
- maxLat === minLat ? minLat + 0.1 : maxLat,
- ]);
- this.meter2coord = (m1 + m2) / 2;
- if (!this.meter2coord) {
- // Tip: 兼容单个数据导致的 m1、m2 为 NaN
- this.meter2coord = 7.70681090738883;
- }
- }
public buildModels(callbackModel: (models: IModel[]) => void) {
const {
- mask = false,
- maskInside = true,
workerEnabled = false,
+ usage
} = this.layer.getLayerConfig() as Partial<
ILayerConfig & IPointLayerStyleOptions
>;
-
this.layer.triangulation = PointFillTriangulation;
this.layer
.buildLayerModel({
- moduleName: 'pointTile',
+ moduleName: 'pointTile_' + usage,
vertexShader: point_tile_vert,
fragmentShader: point_tile_frag,
triangulation: PointFillTriangulation,
@@ -193,11 +79,11 @@ export default class FillModel extends BaseModel {
face: getCullFace(this.mapService.version),
},
blend: this.getBlend(),
- stencil: getMask(mask, maskInside),
workerEnabled,
workerOptions: {
modelType: 'pointTile',
},
+ pick: usage !== 'basemap'
})
.then((model) => {
callbackModel([model]);
@@ -209,10 +95,8 @@ export default class FillModel extends BaseModel {
}
public clearModels() {
- this.dataTexture?.destroy();
}
- // overwrite baseModel func
protected registerBuiltinAttributes() {
this.styleAttributeService.registerStyleAttribute({
name: 'extrude',
@@ -244,7 +128,6 @@ export default class FillModel extends BaseModel {
},
});
- // point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'size',
type: AttributeType.Attribute,
@@ -264,15 +147,13 @@ export default class FillModel extends BaseModel {
attributeIdx: number,
) => {
const { size = 5 } = feature;
- // console.log('featureIdx', featureIdx, feature)
return Array.isArray(size)
- ? [size[0] * this.meter2coord]
- : [(size as number) * this.meter2coord];
+ ? [size[0]]
+ : [(size as number)];
},
},
});
- // point layer size;
this.styleAttributeService.registerStyleAttribute({
name: 'shape',
type: AttributeType.Attribute,
diff --git a/packages/layers/src/point/models/tileText.ts b/packages/layers/src/point/models/tileText.ts
index dd4a75ad3e..0d62b0ec6f 100644
--- a/packages/layers/src/point/models/tileText.ts
+++ b/packages/layers/src/point/models/tileText.ts
@@ -8,8 +8,8 @@ import {
} from '@antv/l7-core';
import {
calculateCentroid,
- getMask,
padBounds,
+ rgb2arr
} from '@antv/l7-utils';
import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
@@ -20,8 +20,10 @@ import {
IGlyphQuad,
shapeText,
} from '../../utils/symbol-layout';
-import textFrag from '../shaders/text_frag.glsl';
-import textVert from '../shaders/text_vert.glsl';
+import text_frag from '../shaders/tile/text_frag.glsl';
+import text_vert from '../shaders/tile/text_vert.glsl';
+import text_map_frag from '../shaders/tile/text_map_frag.glsl';
+import text_map_vert from '../shaders/tile/text_map_vert.glsl';
export function TextTriangulation(feature: IEncodeFeature) {
// @ts-ignore
@@ -80,7 +82,6 @@ export function TextTriangulation(feature: IEncodeFeature) {
size: 7,
};
}
-
export default class TextModel extends BaseModel {
public glyphInfo: IEncodeFeature[];
public glyphInfoMap: {
@@ -105,7 +106,9 @@ export default class TextModel extends BaseModel {
textAllowOverlap = false,
halo = 0.5,
gamma = 2.0,
- raisingHeight = 0,
+ usage,
+ color = '#fff',
+ size = 1
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
const { canvas, mapping } = this.fontService;
if (Object.keys(mapping).length !== this.textCount) {
@@ -117,53 +120,7 @@ export default class TextModel extends BaseModel {
textAllowOverlap,
};
- if (
- this.dataTextureTest &&
- this.dataTextureNeedUpdate({
- opacity,
- strokeWidth,
- stroke,
- })
- ) {
- this.judgeStyleAttributes({
- opacity,
- strokeWidth,
- stroke,
- });
-
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
-
return {
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
- u_raisingHeight: Number(raisingHeight),
-
u_opacity: isNumber(opacity) ? opacity : 1.0,
u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,
u_stroke_color: this.getStrokeColor(stroke),
@@ -172,11 +129,13 @@ export default class TextModel extends BaseModel {
u_halo_blur: halo,
u_gamma_scale: gamma,
u_sdf_map_size: [canvas.width, canvas.height],
+
+ u_color: usage === 'basemap' ? rgb2arr(color): [0, 0, 0, 0],
+ u_size: usage === 'basemap' ? size : 1
};
}
public initModels(callbackModel: (models: IModel[]) => void) {
- this.layer.on('remapping', this.mapping);
this.extent = this.textExtent();
const {
textAnchor = 'center',
@@ -190,21 +149,17 @@ export default class TextModel extends BaseModel {
}
public buildModels = async (callbackModel: (models: IModel[]) => void) => {
- const {
- mask = false,
- maskInside = true,
- } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
this.mapping();
-
+ const { usage } = this.layer.getLayerConfig();
this.layer
.buildLayerModel({
- moduleName: 'pointText',
- vertexShader: textVert,
- fragmentShader: textFrag,
+ moduleName: 'pointTileText_' + usage,
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
triangulation: TextTriangulation.bind(this),
depth: { enable: false },
blend: this.getBlend(),
- stencil: getMask(mask, maskInside),
+ pick: usage !== 'basemap'
})
.then((model) => {
callbackModel([model]);
@@ -217,39 +172,15 @@ export default class TextModel extends BaseModel {
public clearModels() {
this.texture?.destroy();
- this.dataTexture?.destroy();
- this.layer.off('remapping', this.mapping);
}
protected registerBuiltinAttributes() {
- this.styleAttributeService.registerStyleAttribute({
- name: 'rotate',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_Rotate',
- buffer: {
- usage: gl.DYNAMIC_DRAW,
- data: [],
- type: gl.FLOAT,
- },
- size: 1,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
- const { rotate = 0 } = feature;
- return Array.isArray(rotate) ? [rotate[0]] : [rotate as number];
- },
- },
- });
+ const { usage } = this.layer.getLayerConfig();
this.styleAttributeService.registerStyleAttribute({
name: 'textOffsets',
type: AttributeType.Attribute,
descriptor: {
name: 'a_textOffsets',
buffer: {
- // give the WebGL driver a hint that this buffer may change
usage: gl.STATIC_DRAW,
data: [],
type: gl.FLOAT,
@@ -266,32 +197,32 @@ export default class TextModel extends BaseModel {
},
});
- // point layer size;
- this.styleAttributeService.registerStyleAttribute({
- name: 'size',
- type: AttributeType.Attribute,
- descriptor: {
- name: 'a_Size',
- buffer: {
- // give the WebGL driver a hint that this buffer may change
- usage: gl.DYNAMIC_DRAW,
- data: [],
- type: gl.FLOAT,
+ if(usage !== 'basemap') {
+ this.styleAttributeService.registerStyleAttribute({
+ name: 'size',
+ type: AttributeType.Attribute,
+ descriptor: {
+ name: 'a_Size',
+ buffer: {
+ // give the WebGL driver a hint that this buffer may change
+ usage: gl.DYNAMIC_DRAW,
+ data: [],
+ type: gl.FLOAT,
+ },
+ size: 1,
+ update: (
+ feature: IEncodeFeature,
+ featureIdx: number,
+ vertex: number[],
+ attributeIdx: number,
+ ) => {
+ const { size = 12 } = feature;
+ return Array.isArray(size) ? [size[0]] : [size as number];
+ },
},
- size: 1,
- update: (
- feature: IEncodeFeature,
- featureIdx: number,
- vertex: number[],
- attributeIdx: number,
- ) => {
- const { size = 12 } = feature;
- return Array.isArray(size) ? [size[0]] : [size as number];
- },
- },
- });
-
- // point layer size;
+ });
+ }
+
this.styleAttributeService.registerStyleAttribute({
name: 'textUv',
type: AttributeType.Attribute,
@@ -354,36 +285,10 @@ export default class TextModel extends BaseModel {
});
}
- /**
- * 生成 iconfont 纹理字典
- */
- private initIconFontTex() {
- const {
- fontWeight = '400',
- fontFamily = 'sans-serif',
- } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
- const data = this.layer.getEncodedData();
- const characterSet: string[] = [];
- data.forEach((item: IEncodeFeature) => {
- let { shape = '' } = item;
- shape = `${shape}`;
- if (characterSet.indexOf(shape) === -1) {
- characterSet.push(shape);
- }
- });
- this.fontService.setFontOptions({
- characterSet,
- fontWeight,
- fontFamily,
- iconfont: true,
- });
- }
-
/**
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
*/
- private generateGlyphLayout(iconfont: boolean) {
- // TODO:更新文字布局
+ private generateGlyphLayout() {
const { mapping } = this.fontService;
const {
spacing = 2,
@@ -403,7 +308,7 @@ export default class TextModel extends BaseModel {
'left',
spacing,
textOffset,
- iconfont,
+ false,
);
const glyphQuads = getGlyphQuads(shaping, textOffset, false);
feature.shaping = shaping;
@@ -459,7 +364,6 @@ export default class TextModel extends BaseModel {
anchorPointY: pixels.y,
});
if (box && box.length) {
- // TODO:featureIndex
collisionIndex.insertCollisionBox(box, id);
return true;
} else {
@@ -475,12 +379,11 @@ export default class TextModel extends BaseModel {
* 初始化文字布局
*/
private initGlyph() {
- const { iconfont = false } = this.layer.getLayerConfig();
- // 1.生成文字纹理(或是生成 iconfont)
- iconfont ? this.initIconFontTex() : this.initTextFont();
+ // 1.生成文字纹理
+ this.initTextFont();
// 2.生成文字布局
- this.generateGlyphLayout(iconfont);
+ this.generateGlyphLayout();
}
/**
* 更新文字纹理
@@ -503,24 +406,22 @@ export default class TextModel extends BaseModel {
}
private reBuildModel() {
- const {
- mask = false,
- maskInside = true,
- } = this.layer.getLayerConfig() as IPointLayerStyleOptions;
+ const { usage } = this.layer.getLayerConfig();
+
this.filterGlyphs();
this.layer
.buildLayerModel({
- moduleName: 'pointTileText',
- vertexShader: textVert,
- fragmentShader: textFrag,
+ moduleName: 'pointTileText_' + usage,
+ vertexShader: usage === 'basemap' ? text_map_vert : text_vert,
+ fragmentShader: usage === 'basemap' ? text_map_frag : text_frag,
triangulation: TextTriangulation.bind(this),
depth: { enable: false },
blend: this.getBlend(),
- stencil: getMask(mask, maskInside),
+ pick: usage !== 'basemap'
})
.then((model) => {
this.layer.models = [model];
- this.layer.renderLayers();
+ this.layerService.throttleRenderLayers();
})
.catch((err) => {
console.warn(err);
diff --git a/packages/layers/src/point/shaders/animate/wave_frag.glsl b/packages/layers/src/point/shaders/animate/wave_frag.glsl
index bdac0493c6..4448a05dfd 100644
--- a/packages/layers/src/point/shaders/animate/wave_frag.glsl
+++ b/packages/layers/src/point/shaders/animate/wave_frag.glsl
@@ -7,7 +7,7 @@ varying vec4 v_data;
varying vec4 v_color;
varying float v_radius;
uniform float u_time;
-uniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];
+uniform vec4 u_aimate: [ 1., 2., 1.0, 0.2 ];
#pragma include "sdf_2d"
#pragma include "picking"
@@ -53,10 +53,10 @@ void main() {
}
float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);
- // TODO: 根据叠加模式选择效果
+ // 根据叠加模式选择效果
if(u_additive > 0.0) {
gl_FragColor *= intensity;
- // TODO: 优化水波点 blend additive 模式下有的拾取效果
+ // 优化水波点 blend additive 模式下有的拾取效果
gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);
} else {
gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);
diff --git a/packages/layers/src/point/shaders/earth/fill_vert.glsl b/packages/layers/src/point/shaders/earth/fill_vert.glsl
index 820eb28544..369a7756da 100644
--- a/packages/layers/src/point/shaders/earth/fill_vert.glsl
+++ b/packages/layers/src/point/shaders/earth/fill_vert.glsl
@@ -111,7 +111,6 @@ void main() {
// radius(16-bit)
v_radius = newSize;
- // TODO: billboard
// anti-alias
// float antialiased_blur = -max(u_blur, antialiasblur);
float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);
diff --git a/packages/layers/src/point/shaders/fill_vert.glsl b/packages/layers/src/point/shaders/fill_vert.glsl
index 3d572947c1..53362767fc 100644
--- a/packages/layers/src/point/shaders/fill_vert.glsl
+++ b/packages/layers/src/point/shaders/fill_vert.glsl
@@ -130,7 +130,6 @@ void main() {
// radius(16-bit)
v_radius = newSize;
- // TODO: billboard
// anti-alias
// float antialiased_blur = -max(u_blur, antialiasblur);
float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);
diff --git a/packages/layers/src/point/shaders/normal_frag.glsl b/packages/layers/src/point/shaders/normal_frag.glsl
index f3b0d8bf06..2771f19fa9 100644
--- a/packages/layers/src/point/shaders/normal_frag.glsl
+++ b/packages/layers/src/point/shaders/normal_frag.glsl
@@ -1,15 +1,6 @@
-
uniform float u_opacity : 1;
-uniform vec2 u_offsets;
varying vec4 v_color;
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
-
-#pragma include "picking"
void main() {
- float opacity = styleMappingMat[0][0];
-
gl_FragColor = v_color;
- // gl_FragColor.a =gl_FragColor.a * u_opacity;
- gl_FragColor.a =gl_FragColor.a * opacity;
- gl_FragColor = filterColor(gl_FragColor);
+ gl_FragColor.a *= u_opacity;
}
diff --git a/packages/layers/src/point/shaders/normal_vert.glsl b/packages/layers/src/point/shaders/normal_vert.glsl
index 233c3fa355..8f3a9c366a 100644
--- a/packages/layers/src/point/shaders/normal_vert.glsl
+++ b/packages/layers/src/point/shaders/normal_vert.glsl
@@ -4,76 +4,21 @@ uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
attribute float a_Size;
attribute vec4 a_Color;
+
varying vec4 v_color;
-uniform float u_opacity : 1;
-uniform vec2 u_offsets;
-
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
-
#pragma include "projection"
-#pragma include "picking"
#pragma include "project"
+
void main() {
v_color = a_Color;
- // cal style mapping - 数据纹理映射部分的计算
-styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
-
- vec2 textrueOffsets = vec2(0.0, 0.0);
- if(hasOffsets()) {
- vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
-
- vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
- } else {
- textrueOffsets = u_offsets;
- }
-
- // cal style mapping
-
- // vec2 offset = project_pixel(u_offsets);
- vec2 offset = project_pixel(textrueOffsets);
- // vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
- // gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));\
- //
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
- // vec2 offset = project_pixel((u_offsets));
- gl_Position = u_Mvp * vec4(a_Position.xy + offset, a_Position.z, 1.0);
- } else { // else
- // vec2 offset = project_pixel(u_offsets);
+ gl_Position = u_Mvp * vec4(a_Position.xy, a_Position.z, 1.0);
+ } else {
vec4 project_pos = project_position(vec4(a_Position, 1.0)) + vec4(a_Size / 2.,-a_Size /2.,0.,0.);
- gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
+ gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy),project_pos.z,project_pos.w));
}
gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
- setPickingColor(a_PickingColor);
}
diff --git a/packages/layers/src/point/shaders/radar/radar_frag.glsl b/packages/layers/src/point/shaders/radar/radar_frag.glsl
index 5ab5e356b4..ff9c1c3617 100644
--- a/packages/layers/src/point/shaders/radar/radar_frag.glsl
+++ b/packages/layers/src/point/shaders/radar/radar_frag.glsl
@@ -1,26 +1,15 @@
uniform float u_additive;
-
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
+uniform float u_opacity: 1.0;
varying vec4 v_data;
varying vec4 v_color;
varying float v_radius;
-
+varying vec2 v_exteude;
#pragma include "sdf_2d"
#pragma include "picking"
void main() {
- int shape = int(floor(v_data.w + 0.5));
-
- vec4 textrueStroke = vec4(
- styleMappingMat[1][0],
- styleMappingMat[1][1],
- styleMappingMat[1][2],
- styleMappingMat[1][3]
- );
-
- float opacity = styleMappingMat[0][0];
lowp float antialiasblur = v_data.z;
float r = v_radius / (v_radius);
@@ -30,7 +19,7 @@ void main() {
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
- gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);
+ gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);
if(u_additive > 0.0) {
gl_FragColor *= opacity_t;
@@ -42,7 +31,7 @@ void main() {
gl_FragColor = filterColor(gl_FragColor);
}
- vec2 extrude = styleMappingMat[2].ba;
+ vec2 extrude = v_exteude;
vec2 dir = normalize(extrude);
vec2 baseDir = vec2(1.0, 0.0);
float pi = 3.14159265359;
diff --git a/packages/layers/src/point/shaders/radar/radar_vert.glsl b/packages/layers/src/point/shaders/radar/radar_vert.glsl
index c57889feb3..6c52d786bd 100644
--- a/packages/layers/src/point/shaders/radar/radar_vert.glsl
+++ b/packages/layers/src/point/shaders/radar/radar_vert.glsl
@@ -2,12 +2,9 @@ attribute vec4 a_Color;
attribute vec3 a_Position;
attribute vec3 a_Extrude;
attribute float a_Size;
-attribute float a_Shape;
uniform float u_speed: 1.0;
uniform float u_time;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
uniform float u_isMeter;
@@ -15,68 +12,21 @@ uniform float u_isMeter;
varying vec4 v_data;
varying vec4 v_color;
varying float v_radius;
-
-uniform float u_opacity : 1;
-uniform vec2 u_offsets;
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
+varying vec2 v_exteude;
#pragma include "projection"
#pragma include "picking"
void main() {
vec3 extrude = a_Extrude;
- float shape_type = a_Shape;
float newSize = setPickingSize(a_Size);
- // cal style mapping - 数据纹理映射部分的计算
- styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - empty - empty - empty
- 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1] - a_Extrude.x - a_Extrude.y
- 0.0, 0.0, 0.0, 0.0 //
- );
-
float time = u_time * u_speed;
mat2 rotateMatrix = mat2(
cos(time), sin(time),
-sin(time), cos(time)
);
- styleMappingMat[2].ba = rotateMatrix * a_Extrude.xy;
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> empty -> empty ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
-
-
- vec2 textrueOffsets = vec2(0.0, 0.0);
- if(hasOffsets()) {
- vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
-
- vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
- } else {
- textrueOffsets = u_offsets;
- }
-
- // cal style mapping
+ v_exteude = rotateMatrix * a_Extrude.xy;
// unpack color(vec2)
v_color = a_Color;
@@ -88,7 +38,7 @@ void main() {
float blur = 0.0;
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, blur);
- vec2 offset = (extrude.xy * (newSize) + textrueOffsets);
+ vec2 offset = (extrude.xy * (newSize));
vec3 aPosition = a_Position;
if(u_isMeter < 1.0) {
// 不以米为实际单位
@@ -106,7 +56,7 @@ void main() {
}
}
- v_data = vec4(extrude.x, extrude.y, antialiasblur,shape_type);
+ v_data = vec4(extrude.x, extrude.y, antialiasblur, -1.0);
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
diff --git a/packages/layers/src/point/shaders/tile/fill_tile_frag.glsl b/packages/layers/src/point/shaders/tile/fill_tile_frag.glsl
index 08ffd5685d..39038a2dfe 100644
--- a/packages/layers/src/point/shaders/tile/fill_tile_frag.glsl
+++ b/packages/layers/src/point/shaders/tile/fill_tile_frag.glsl
@@ -1,5 +1,9 @@
uniform float u_additive;
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
+
+uniform float u_opacity : 1;
+uniform float u_stroke_opacity : 1;
+uniform float u_stroke_width : 2;
+uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
varying vec4 v_data;
varying vec4 v_color;
@@ -11,20 +15,9 @@ varying float v_radius;
void main() {
int shape = int(floor(v_data.w + 0.5));
- vec4 textrueStroke = vec4(
- styleMappingMat[1][0],
- styleMappingMat[1][1],
- styleMappingMat[1][2],
- styleMappingMat[1][3]
- );
-
- float opacity = styleMappingMat[0][0];
- float stroke_opacity = styleMappingMat[0][1];
- float strokeWidth = styleMappingMat[0][2];
- vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;
lowp float antialiasblur = v_data.z;
- float r = v_radius / (v_radius + strokeWidth);
+ float r = v_radius / (v_radius + u_stroke_width);
float outer_df;
float inner_df;
@@ -61,16 +54,16 @@ void main() {
float opacity_t = smoothstep(0.0, antialiasblur, outer_df);
- float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(
+ float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(
antialiasblur,
0.0,
inner_df
);
- if(strokeWidth < 0.01) {
- gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);
+ if(u_stroke_width < 0.01) {
+ gl_FragColor = vec4(v_color.rgb, v_color.a * u_opacity);
} else {
- gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);
+ gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), u_stroke_color * u_stroke_opacity, color_t);
}
if(u_additive > 0.0) {
diff --git a/packages/layers/src/point/shaders/tile/fill_tile_vert.glsl b/packages/layers/src/point/shaders/tile/fill_tile_vert.glsl
index cff8357a22..246b9606d4 100644
--- a/packages/layers/src/point/shaders/tile/fill_tile_vert.glsl
+++ b/packages/layers/src/point/shaders/tile/fill_tile_vert.glsl
@@ -4,14 +4,11 @@ attribute vec3 a_Extrude;
attribute float a_Size;
attribute float a_Shape;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
-uniform float u_isMeter;
-uniform vec2 u_tileOrigin;
-uniform float u_coord;
+// uniform vec2 u_tileOrigin;
+// uniform float u_coord;
varying vec4 v_data;
varying vec4 v_color;
@@ -21,14 +18,6 @@ uniform float u_opacity : 1;
uniform float u_stroke_opacity : 1;
uniform float u_stroke_width : 2;
uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
-uniform vec2 u_offsets;
-
-uniform float u_blur : 0.0;
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
-#pragma include "styleMappingCalStrokeOpacity"
-#pragma include "styleMappingCalStrokeWidth"
#pragma include "projection"
#pragma include "picking"
@@ -38,83 +27,6 @@ void main() {
float shape_type = a_Shape;
float newSize = setPickingSize(a_Size);
- // cal style mapping - 数据纹理映射部分的计算
- styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
-
- vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][1] = strokeOpacityAndOffset.r;
- textureOffset = strokeOpacityAndOffset.g;
-
- vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][2] = strokeWidthAndOffset.r;
- textureOffset = strokeWidthAndOffset.g;
-
- vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);
- if(hasStroke()) {
- vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R
- textureOffset += 1.0;
-
- vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G
- textureOffset += 1.0;
-
- vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B
- textureOffset += 1.0;
-
- vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A
- textureOffset += 1.0;
- } else {
- if(u_stroke_color == vec4(0.0)) {
- styleMappingMat[1][0] = v_color.r;
- styleMappingMat[1][1] = v_color.g;
- styleMappingMat[1][2] = v_color.b;
- styleMappingMat[1][3] = v_color.a;
- } else {
- styleMappingMat[1][0] = u_stroke_color.r;
- styleMappingMat[1][1] = u_stroke_color.g;
- styleMappingMat[1][2] = u_stroke_color.b;
- styleMappingMat[1][3] = u_stroke_color.a;
- }
- }
-
- vec2 textrueOffsets = vec2(0.0, 0.0);
- if(hasOffsets()) {
- vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
-
- vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);
- textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x
- textureOffset += 1.0;
- } else {
- textrueOffsets = u_offsets;
- }
-
// cal style mapping
v_color = a_Color;
@@ -122,57 +34,42 @@ void main() {
// anti-alias
// float antialiased_blur = -max(u_blur, antialiasblur);
- float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, u_blur);
+ float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, 0.0);
- vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);
- vec3 aPosition = a_Position;
- if(u_isMeter < 1.0) {
- // 不以米为实际单位
- offset = project_pixel(offset);
- } else {
- // 以米为实际单位
- antialiasblur *= pow(19.0 - u_Zoom, 2.0);
- antialiasblur = max(antialiasblur, -0.01);
- // offset *= 0.5;
-
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- aPosition.xy += offset;
- offset.x = 0.0;
- offset.y = 0.0;
- }
- }
+ vec2 offset = (extrude.xy * (newSize + u_stroke_width));
+ offset = project_pixel(offset);
v_data = vec4(extrude.x, extrude.y, antialiasblur,shape_type);
- vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
+ vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
}
-if(u_coord > 0.0) {
+// if(u_coord > 0.0) {
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);
} else {
gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));
}
-} else {
- gl_PointSize = 24.0;
- vec2 pointPos = a_Position.xy;
- vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
+// } else {
- vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
+ // vec2 pointPos = a_Position.xy;
+ // vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
+
+ // vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
- world.xy += offset;
- world.xy += pointOffset;
+ // world.xy += offset;
+ // world.xy += pointOffset;
- if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- // Needs to be divided with project_uCommonUnitsPerMeter
- world.w *= u_PixelsPerMeter.z;
- }
+ // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
+ // // Needs to be divided with project_uCommonUnitsPerMeter
+ // world.w *= u_PixelsPerMeter.z;
+ // }
- gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
-}
+ // gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
+// }
setPickingColor(a_PickingColor);
diff --git a/packages/layers/src/point/shaders/tile/text_frag.glsl b/packages/layers/src/point/shaders/tile/text_frag.glsl
new file mode 100644
index 0000000000..c59f2b115b
--- /dev/null
+++ b/packages/layers/src/point/shaders/tile/text_frag.glsl
@@ -0,0 +1,33 @@
+#define SDF_PX 8.0
+#define EDGE_GAMMA 0.105
+#define FONT_SIZE 48.0
+uniform sampler2D u_sdf_map;
+uniform float u_gamma_scale : 0.5;
+// uniform float u_font_size : 24.0;
+uniform float u_opacity : 1.0;
+uniform vec4 u_stroke_color : [0, 0, 0, 1];
+uniform float u_stroke_width : 2.0;
+uniform float u_halo_blur : 0.5;
+uniform float u_DevicePixelRatio;
+
+varying vec4 v_color;
+varying vec2 v_uv;
+varying float v_gamma_scale;
+varying float v_fontScale;
+
+#pragma include "picking"
+void main() {
+ // get sdf from atlas
+ float dist = texture2D(u_sdf_map, v_uv).a;
+
+ lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
+ highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;
+
+ highp float gamma_scaled = gamma * v_gamma_scale;
+
+ highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
+
+ gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));
+ gl_FragColor.a= gl_FragColor.a * alpha;
+ gl_FragColor = filterColor(gl_FragColor);
+}
diff --git a/packages/layers/src/point/shaders/tile/text_map_frag.glsl b/packages/layers/src/point/shaders/tile/text_map_frag.glsl
new file mode 100644
index 0000000000..1631b2b2f5
--- /dev/null
+++ b/packages/layers/src/point/shaders/tile/text_map_frag.glsl
@@ -0,0 +1,31 @@
+#define SDF_PX 8.0
+#define EDGE_GAMMA 0.105
+#define FONT_SIZE 48.0
+uniform sampler2D u_sdf_map;
+uniform float u_gamma_scale : 0.5;
+
+uniform float u_opacity : 1.0;
+uniform vec4 u_stroke_color : [0, 0, 0, 1];
+uniform float u_stroke_width : 2.0;
+uniform float u_halo_blur : 0.5;
+uniform float u_DevicePixelRatio;
+
+varying vec2 v_uv;
+varying float v_gamma_scale;
+varying float v_fontScale;
+uniform vec4 u_color;
+
+void main() {
+ // get sdf from atlas
+ float dist = texture2D(u_sdf_map, v_uv).a;
+
+ lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;
+ highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;
+
+ highp float gamma_scaled = gamma * v_gamma_scale;
+
+ highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
+
+ gl_FragColor = mix(vec4(u_color.rgb, u_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));
+ gl_FragColor.a= gl_FragColor.a * alpha;
+}
diff --git a/packages/layers/src/point/shaders/tile/text_map_vert.glsl b/packages/layers/src/point/shaders/tile/text_map_vert.glsl
new file mode 100644
index 0000000000..13da272e8b
--- /dev/null
+++ b/packages/layers/src/point/shaders/tile/text_map_vert.glsl
@@ -0,0 +1,38 @@
+#define FONT_SIZE 24.0
+attribute vec3 a_Position;
+attribute vec2 a_tex;
+attribute vec2 a_textOffsets;
+
+uniform vec2 u_sdf_map_size;
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+
+uniform float u_size;
+
+varying vec2 v_uv;
+varying float v_gamma_scale;
+varying float v_fontScale;
+
+#pragma include "projection"
+
+void main() {
+ v_uv = a_tex / u_sdf_map_size;
+
+ // 文本缩放比例
+ float fontScale = u_size / FONT_SIZE;
+ v_fontScale = fontScale;
+
+ vec4 project_pos = project_position(vec4(a_Position, 1.0));
+
+ vec4 projected_position;
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));
+ } else { // else
+ projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
+ }
+
+ gl_Position = vec4(
+ projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
+ v_gamma_scale = gl_Position.w;
+
+}
diff --git a/packages/layers/src/point/shaders/tile/text_vert.glsl b/packages/layers/src/point/shaders/tile/text_vert.glsl
new file mode 100644
index 0000000000..077d2b3d1c
--- /dev/null
+++ b/packages/layers/src/point/shaders/tile/text_vert.glsl
@@ -0,0 +1,48 @@
+#define SDF_PX 8.0
+#define EDGE_GAMMA 0.105
+#define FONT_SIZE 24.0
+attribute vec3 a_Position;
+attribute vec2 a_tex;
+attribute vec2 a_textOffsets;
+attribute vec4 a_Color;
+attribute float a_Size;
+
+uniform vec2 u_sdf_map_size;
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+
+varying vec2 v_uv;
+varying float v_gamma_scale;
+varying vec4 v_color;
+varying float v_fontScale;
+
+uniform float u_opacity : 1;
+uniform float u_stroke_width : 2;
+uniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];
+
+#pragma include "projection"
+#pragma include "picking"
+
+void main() {
+ v_color = a_Color;
+ v_uv = a_tex / u_sdf_map_size;
+
+ // 文本缩放比例
+ float fontScale = a_Size / FONT_SIZE;
+ v_fontScale = fontScale;
+
+ vec4 project_pos = project_position(vec4(a_Position, 1.0));
+
+ vec4 projected_position;
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ projected_position = u_Mvp * (vec4(a_Position.xyz, 1.0));
+ } else { // else
+ projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
+ }
+
+ gl_Position = vec4(
+ projected_position.xy / projected_position.w + a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);
+ v_gamma_scale = gl_Position.w;
+ setPickingColor(a_PickingColor);
+
+}
diff --git a/packages/layers/src/polygon/index.ts b/packages/layers/src/polygon/index.ts
index 5bb4fbde47..2fcf327888 100644
--- a/packages/layers/src/polygon/index.ts
+++ b/packages/layers/src/polygon/index.ts
@@ -19,11 +19,15 @@ export default class PolygonLayer extends BaseLayer {
this.layerModel = new PolygonModels[shape](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
return {
diff --git a/packages/layers/src/polygon/models/extrude.ts b/packages/layers/src/polygon/models/extrude.ts
index 0dd1d710b7..b34b5cc97a 100644
--- a/packages/layers/src/polygon/models/extrude.ts
+++ b/packages/layers/src/polygon/models/extrude.ts
@@ -260,8 +260,7 @@ export default class ExtrudeModel extends BaseModel {
min: gl.LINEAR,
mag: gl.LINEAR,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
};
}
}
diff --git a/packages/layers/src/polygon/models/fill.ts b/packages/layers/src/polygon/models/fill.ts
index 5952591200..1bf204c794 100644
--- a/packages/layers/src/polygon/models/fill.ts
+++ b/packages/layers/src/polygon/models/fill.ts
@@ -135,10 +135,7 @@ export default class FillModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
- normal: number[],
) => {
- // center[0] center[1] radius
return [vertex[3], vertex[4], vertex[5]];
},
},
diff --git a/packages/layers/src/polygon/models/ocean.ts b/packages/layers/src/polygon/models/ocean.ts
index e8b883d88b..313882c73e 100644
--- a/packages/layers/src/polygon/models/ocean.ts
+++ b/packages/layers/src/polygon/models/ocean.ts
@@ -6,6 +6,7 @@ import {
IModelUniform,
ITexture2D,
} from '@antv/l7-core';
+import { Version } from '@antv/l7-maps';
import { getMask, rgb2arr } from '@antv/l7-utils';
import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
@@ -23,43 +24,13 @@ export default class OceanModel extends BaseModel {
watercolor = '#6D99A8',
watercolor2 = '#0F121C',
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
- this.judgeStyleAttributes({ opacity });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
+
return {
u_texture1: this.texture1,
u_texture2: this.texture2,
u_texture3: this.texture3,
u_watercolor: rgb2arr(watercolor),
u_watercolor2: rgb2arr(watercolor2),
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
u_opacity: isNumber(opacity) ? opacity : 1.0,
};
}
@@ -89,6 +60,7 @@ export default class OceanModel extends BaseModel {
primitive: gl.TRIANGLES,
depth: { enable: false },
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
@@ -103,7 +75,6 @@ export default class OceanModel extends BaseModel {
this.texture1?.destroy();
this.texture2?.destroy();
this.texture3?.destroy();
- this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
@@ -129,9 +100,9 @@ export default class OceanModel extends BaseModel {
featureIdx: number,
vertex: number[],
attributeIdx: number,
- normal: number[],
) => {
- const [lng, lat] = vertex;
+ const v = (feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex)
+ const [lng, lat] = v;
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
},
},
@@ -151,8 +122,7 @@ export default class OceanModel extends BaseModel {
this.texture1 = initTex(images[0]);
this.texture2 = initTex(images[1]);
this.texture3 = initTex(images[2]);
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
});
function initImage(callback: (loadedImages: HTMLImageElement[]) => void) {
diff --git a/packages/layers/src/polygon/models/tile.ts b/packages/layers/src/polygon/models/tile.ts
index 128007333f..f74b335a78 100644
--- a/packages/layers/src/polygon/models/tile.ts
+++ b/packages/layers/src/polygon/models/tile.ts
@@ -1,55 +1,28 @@
-import { gl, IModel } from '@antv/l7-core';
-import { getMask } from '@antv/l7-utils';
+import { IModel } from '@antv/l7-core';
+import { getMask, rgb2arr } from '@antv/l7-utils';
import BaseModel from '../../core/BaseModel';
import { IPolygonLayerStyleOptions } from '../../core/interface';
import { polygonTriangulation } from '../../core/triangulation';
-import polygon_tile_frag from '../shaders/tile/polygon_tile_frag.glsl';
+import polygon_tile_frag from '../../shader/minify_picking_frag.glsl';
import polygon_tile_vert from '../shaders/tile/polygon_tile_vert.glsl';
+import polygon_tile_map_frag from '../../shader/minify_frag.glsl';
+import polygon_tile_map_vert from '../shaders/tile/polygon_tile_map_vert.glsl';
export default class FillModel extends BaseModel {
public getUninforms() {
const {
opacity = 1,
- tileOrigin,
- coord = 'lnglat',
+ // tileOrigin,
+ // coord = 'lnglat',
+ usage,
+ color = '#fff'
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
- this.judgeStyleAttributes({ opacity });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
+
return {
- u_tileOrigin: tileOrigin || [0, 0],
- u_coord: coord === 'lnglat' ? 1.0 : 0.0,
-
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
-
+ // u_tileOrigin: tileOrigin || [0, 0],
+ // u_coord: coord === 'lnglat' ? 1.0 : 0.0,
u_opacity: opacity,
+ u_color: usage === 'basemap' ? rgb2arr(color): [0, 0, 0, 0]
};
}
@@ -61,18 +34,19 @@ export default class FillModel extends BaseModel {
const {
mask = false,
maskInside = true,
+ usage
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
this.layer.triangulation = polygonTriangulation;
this.layer
.buildLayerModel({
- moduleName: 'polygonTile',
- vertexShader: polygon_tile_vert,
- fragmentShader: polygon_tile_frag,
+ moduleName: 'polygonTile_' + usage,
+ vertexShader: usage === 'basemap' ? polygon_tile_map_vert : polygon_tile_vert,
+ fragmentShader: usage === 'basemap' ? polygon_tile_map_frag : polygon_tile_frag,
triangulation: polygonTriangulation,
- primitive: gl.TRIANGLES,
depth: { enable: false },
blend: this.getBlend(),
stencil: getMask(mask, maskInside),
+ pick: usage !== 'basemap'
})
.then((model) => {
callbackModel([model]);
@@ -84,7 +58,6 @@ export default class FillModel extends BaseModel {
}
public clearModels() {
- this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
diff --git a/packages/layers/src/polygon/models/water.ts b/packages/layers/src/polygon/models/water.ts
index 0a4c52e29c..88a500a9c1 100644
--- a/packages/layers/src/polygon/models/water.ts
+++ b/packages/layers/src/polygon/models/water.ts
@@ -6,6 +6,7 @@ import {
IModelUniform,
ITexture2D,
} from '@antv/l7-core';
+import { Version } from '@antv/l7-maps';
import { getMask } from '@antv/l7-utils';
import { isNumber } from 'lodash';
import BaseModel from '../../core/BaseModel';
@@ -20,39 +21,8 @@ export default class WaterModel extends BaseModel {
opacity = 1,
speed = 0.5,
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
- if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {
- this.judgeStyleAttributes({ opacity });
- const encodeData = this.layer.getEncodedData();
- const { data, width, height } = this.calDataFrame(
- this.cellLength,
- encodeData,
- this.cellProperties,
- );
- this.rowCount = height; // 当前数据纹理有多少行
-
- this.dataTexture =
- this.cellLength > 0 && data.length > 0
- ? this.createTexture2D({
- flipY: true,
- data,
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width,
- height,
- })
- : this.createTexture2D({
- flipY: true,
- data: [1],
- format: gl.LUMINANCE,
- type: gl.FLOAT,
- width: 1,
- height: 1,
- });
- }
return {
u_texture: this.texture,
- u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
- u_cellTypeLayout: this.getCellTypeLayout(),
u_speed: speed,
u_opacity: isNumber(opacity) ? opacity : 1.0,
};
@@ -83,6 +53,7 @@ export default class WaterModel extends BaseModel {
primitive: gl.TRIANGLES,
depth: { enable: false },
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
@@ -95,7 +66,6 @@ export default class WaterModel extends BaseModel {
public clearModels() {
this.texture?.destroy();
- this.dataTexture?.destroy();
}
protected registerBuiltinAttributes() {
@@ -120,10 +90,10 @@ export default class WaterModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
- normal: number[],
+ attributeIdx: number
) => {
- const [lng, lat] = vertex;
+ const v = (feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex)
+ const [lng, lat] = v;
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
},
},
@@ -164,8 +134,7 @@ export default class WaterModel extends BaseModel {
min: gl.LINEAR,
mag: gl.LINEAR,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
};
}
}
diff --git a/packages/layers/src/polygon/shaders/polygon_frag.glsl b/packages/layers/src/polygon/shaders/polygon_frag.glsl
index c907c08c8d..eef5872aef 100644
--- a/packages/layers/src/polygon/shaders/polygon_frag.glsl
+++ b/packages/layers/src/polygon/shaders/polygon_frag.glsl
@@ -1,12 +1,12 @@
uniform float u_opacity: 1.0;
-varying vec4 v_Color;
+varying vec4 v_color;
varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
#pragma include "picking"
void main() {
float opacity = styleMappingMat[0][0];
- gl_FragColor = v_Color;
+ gl_FragColor = v_color;
gl_FragColor.a *= opacity;
gl_FragColor = filterColor(gl_FragColor);
}
diff --git a/packages/layers/src/polygon/shaders/polygon_vert.glsl b/packages/layers/src/polygon/shaders/polygon_vert.glsl
index d8187accf8..88cb85c03b 100644
--- a/packages/layers/src/polygon/shaders/polygon_vert.glsl
+++ b/packages/layers/src/polygon/shaders/polygon_vert.glsl
@@ -7,7 +7,7 @@ uniform mat4 u_Mvp;
uniform float u_opacity: 1.0;
uniform float u_raisingHeight: 0.0;
-varying vec4 v_Color;
+varying vec4 v_color;
varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
#pragma include "styleMapping"
@@ -43,7 +43,7 @@ styleMappingMat = mat4(
textureOffset = opacityAndOffset.g;
// cal style mapping - 数据纹理映射部分的计算
- v_Color = a_Color;
+ v_color = a_Color;
vec4 project_pos = project_position(vec4(a_Position, 1.0));
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
diff --git a/packages/layers/src/polygon/shaders/tile/polygon_tile_frag.glsl b/packages/layers/src/polygon/shaders/tile/polygon_tile_frag.glsl
deleted file mode 100644
index c907c08c8d..0000000000
--- a/packages/layers/src/polygon/shaders/tile/polygon_tile_frag.glsl
+++ /dev/null
@@ -1,12 +0,0 @@
-uniform float u_opacity: 1.0;
-varying vec4 v_Color;
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
-
-#pragma include "picking"
-
-void main() {
- float opacity = styleMappingMat[0][0];
- gl_FragColor = v_Color;
- gl_FragColor.a *= opacity;
- gl_FragColor = filterColor(gl_FragColor);
-}
diff --git a/packages/layers/src/polygon/shaders/tile/polygon_tile_map_vert.glsl b/packages/layers/src/polygon/shaders/tile/polygon_tile_map_vert.glsl
new file mode 100644
index 0000000000..6660427a66
--- /dev/null
+++ b/packages/layers/src/polygon/shaders/tile/polygon_tile_map_vert.glsl
@@ -0,0 +1,16 @@
+attribute vec3 a_Position;
+
+uniform mat4 u_ModelMatrix;
+uniform mat4 u_Mvp;
+
+#pragma include "projection"
+
+void main() {
+ vec4 project_pos = project_position(vec4(a_Position, 1.0));
+
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
+ }
+}
\ No newline at end of file
diff --git a/packages/layers/src/polygon/shaders/tile/polygon_tile_vert.glsl b/packages/layers/src/polygon/shaders/tile/polygon_tile_vert.glsl
index c6e9c347ae..9a6a98de55 100644
--- a/packages/layers/src/polygon/shaders/tile/polygon_tile_vert.glsl
+++ b/packages/layers/src/polygon/shaders/tile/polygon_tile_vert.glsl
@@ -4,78 +4,38 @@ attribute vec3 a_Position;
uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
-uniform float u_opacity: 1.0;
+// uniform vec2 u_tileOrigin;
+// uniform float u_coord;
-uniform vec2 u_tileOrigin;
-uniform float u_coord;
-
-varying vec4 v_Color;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
+varying vec4 v_color;
#pragma include "projection"
#pragma include "picking"
void main() {
- // cal style mapping - 数据纹理映射部分的计算
-styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
- // cal style mapping - 数据纹理映射部分的计算
-
- v_Color = a_Color;
+ v_color = a_Color;
vec4 project_pos = project_position(vec4(a_Position, 1.0));
-
- if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);
- project_pos.z *= mapboxZoomScale;
- }
-
-if(u_coord > 0.0) {
- if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
- gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
- } else {
- gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
- }
-} else {
- vec2 pointPos = a_Position.xy;
- vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
-
- vec2 pointOffset = pointPos * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
-
- world.xy += pointOffset;
-
- if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
- // Needs to be divided with project_uCommonUnitsPerMeter
- world.w *= u_PixelsPerMeter.z;
+ // if(u_coord > 0.0) {
+ if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
+ gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
+ } else {
+ gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
}
+ // } else {
+ // vec4 world = vec4(project_mvt_offset_position(vec4(u_tileOrigin, 0.0, 1.0)).xyz, 1.0); // 瓦片起始点的世界坐标
- gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
-}
+ // vec2 pointOffset = a_Position.xy * pow(2.0, u_Zoom); // 瓦片内的点的偏移坐标
+
+ // world.xy += pointOffset;
+ // if (u_CoordinateSystem == COORDINATE_SYSTEM_METER_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
+ // // Needs to be divided with project_uCommonUnitsPerMeter
+ // world.w *= u_PixelsPerMeter.z;
+ // }
+
+ // gl_Position = u_ViewProjectionMatrix * world + u_ViewportCenterProjection;
+ // }
setPickingColor(a_PickingColor);
}
diff --git a/packages/layers/src/polygon/shaders/water/polygon_ocean_frag.glsl b/packages/layers/src/polygon/shaders/water/polygon_ocean_frag.glsl
index 37e4ebdf93..9ce1f3573f 100644
--- a/packages/layers/src/polygon/shaders/water/polygon_ocean_frag.glsl
+++ b/packages/layers/src/polygon/shaders/water/polygon_ocean_frag.glsl
@@ -3,7 +3,6 @@ uniform float u_time: 0.0;
uniform float u_opacity: 1.0;
varying vec2 v_uv;
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
float coast2water_fadedepth = 0.10;
float large_waveheight = .750; // change to adjust the "heavy" waves
@@ -243,6 +242,6 @@ void main() {
}
- float opacity = styleMappingMat[0][0];
+ float opacity = u_opacity;
gl_FragColor = vec4(col, opacity);
}
diff --git a/packages/layers/src/polygon/shaders/water/polygon_ocean_vert.glsl b/packages/layers/src/polygon/shaders/water/polygon_ocean_vert.glsl
index 89152ace61..ff1638b916 100644
--- a/packages/layers/src/polygon/shaders/water/polygon_ocean_vert.glsl
+++ b/packages/layers/src/polygon/shaders/water/polygon_ocean_vert.glsl
@@ -4,44 +4,13 @@ uniform mat4 u_ModelMatrix;
uniform mat4 u_Mvp;
varying vec2 v_uv;
-uniform float u_opacity: 1.0;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
#pragma include "projection"
void main() {
v_uv = a_uv;
- // cal style mapping - 数据纹理映射部分的计算
-styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
- // cal style mapping - 数据纹理映射部分的计算
vec4 project_pos = project_position(vec4(a_Position, 1.0));
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
diff --git a/packages/layers/src/polygon/shaders/water/polygon_water_frag.glsl b/packages/layers/src/polygon/shaders/water/polygon_water_frag.glsl
index 03663c64d5..7f3996c05b 100644
--- a/packages/layers/src/polygon/shaders/water/polygon_water_frag.glsl
+++ b/packages/layers/src/polygon/shaders/water/polygon_water_frag.glsl
@@ -5,8 +5,6 @@ uniform float u_opacity: 1.0;
varying vec4 v_Color;
varying vec2 v_uv;
-varying mat4 styleMappingMat; // 传递从片元中传递的映射数据
-
float rand(vec2 n) { return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453); }
@@ -64,7 +62,7 @@ float calSpc() {
}
void main() {
- float opacity = styleMappingMat[0][0];
+ float opacity = u_opacity;
gl_FragColor = v_Color;
gl_FragColor.a *= opacity;
diff --git a/packages/layers/src/polygon/shaders/water/polygon_water_vert.glsl b/packages/layers/src/polygon/shaders/water/polygon_water_vert.glsl
index 356d232ddc..12d8cda80a 100644
--- a/packages/layers/src/polygon/shaders/water/polygon_water_vert.glsl
+++ b/packages/layers/src/polygon/shaders/water/polygon_water_vert.glsl
@@ -7,44 +7,15 @@ uniform mat4 u_Mvp;
varying vec4 v_Color;
varying vec2 v_uv;
uniform float u_opacity: 1.0;
-varying mat4 styleMappingMat; // 用于将在顶点着色器中计算好的样式值传递给片元
-#pragma include "styleMapping"
-#pragma include "styleMappingCalOpacity"
#pragma include "projection"
void main() {
v_uv = a_uv;
- // cal style mapping - 数据纹理映射部分的计算
-styleMappingMat = mat4(
- 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty
- 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA
- 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]
- 0.0, 0.0, 0.0, 0.0
- );
-
- float rowCount = u_cellTypeLayout[0][0]; // 当前的数据纹理有几行
- float columnCount = u_cellTypeLayout[0][1]; // 当看到数据纹理有几列
- float columnWidth = 1.0/columnCount; // 列宽
- float rowHeight = 1.0/rowCount; // 行高
- float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets
- float id = a_vertexId; // 第n个顶点
- float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // 起始点在第几行
- float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // 起始点在第几列
-
- // cell 固定顺序 opacity -> strokeOpacity -> strokeWidth -> stroke ...
- // 按顺序从 cell 中取值、若没有则自动往下取值
- float textureOffset = 0.0; // 在 cell 中取值的偏移量
-
- vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);
- styleMappingMat[0][0] = opacityAndOffset.r;
- textureOffset = opacityAndOffset.g;
- // cal style mapping - 数据纹理映射部分的计算
v_Color = a_Color;
vec4 project_pos = project_position(vec4(a_Position, 1.0));
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));
diff --git a/packages/layers/src/raster/index.ts b/packages/layers/src/raster/index.ts
index 95bfa02ede..ce5b1bad72 100644
--- a/packages/layers/src/raster/index.ts
+++ b/packages/layers/src/raster/index.ts
@@ -8,11 +8,15 @@ export default class RaterLayer extends BaseLayer {
this.layerModel = new RasterModels[modelType](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getConfigSchema() {
return {
diff --git a/packages/layers/src/raster/models/raster.ts b/packages/layers/src/raster/models/raster.ts
index f840bead13..a7e76f3f6b 100644
--- a/packages/layers/src/raster/models/raster.ts
+++ b/packages/layers/src/raster/models/raster.ts
@@ -78,6 +78,7 @@ export default class RasterModel extends BaseModel {
primitive: gl.TRIANGLES,
depth: { enable: false },
stencil: getMask(mask, maskInside),
+ pick: false,
})
.then((model) => {
callbackModel([model]);
@@ -115,7 +116,6 @@ export default class RasterModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[3], vertex[4]];
},
diff --git a/packages/layers/src/shader/minify_frag.glsl b/packages/layers/src/shader/minify_frag.glsl
new file mode 100644
index 0000000000..6fb20cb940
--- /dev/null
+++ b/packages/layers/src/shader/minify_frag.glsl
@@ -0,0 +1,7 @@
+uniform float u_opacity : 1.0;
+uniform vec4 u_color;
+
+void main() {
+ gl_FragColor = u_color;
+ gl_FragColor.a *= u_opacity;
+}
diff --git a/packages/layers/src/shader/minify_picking_frag.glsl b/packages/layers/src/shader/minify_picking_frag.glsl
new file mode 100644
index 0000000000..763e78eecd
--- /dev/null
+++ b/packages/layers/src/shader/minify_picking_frag.glsl
@@ -0,0 +1,10 @@
+uniform float u_opacity : 1.0;
+varying vec4 v_color;
+
+#pragma include "picking"
+
+void main() {
+ gl_FragColor = v_color;
+ gl_FragColor.a *= u_opacity;
+ gl_FragColor = filterColor(gl_FragColor);
+}
diff --git a/packages/layers/src/tile/manager/baseMapTileLayerManager.ts b/packages/layers/src/tile/manager/baseMapTileLayerManager.ts
new file mode 100644
index 0000000000..9d6163509c
--- /dev/null
+++ b/packages/layers/src/tile/manager/baseMapTileLayerManager.ts
@@ -0,0 +1,191 @@
+import {
+ ILayer,
+ IMapService,
+ IRendererService,
+ ISubLayerInitOptions,
+ IBaseTileLayerManager,
+} from '@antv/l7-core';
+import { Tile } from '@antv/l7-utils';
+import { getTileFactory, ITileFactory, TileType } from '../tileFactory';
+import { getLayerShape, getMaskValue } from '../utils';
+export class BaseMapTileLayerManager implements IBaseTileLayerManager {
+ // only support vector layer
+ public sourceLayer: string;
+ public parent: ILayer;
+ public children: ILayer[];
+ public mapService: IMapService;
+ public rendererService: IRendererService;
+ private tileFactory: ITileFactory;
+ private initOptions: ISubLayerInitOptions;
+ constructor(
+ parent: ILayer,
+ mapService: IMapService,
+ rendererService: IRendererService,
+ ) {
+ this.parent = parent;
+ this.children = parent.layerChildren;
+ this.mapService = mapService;
+ this.rendererService = rendererService;
+
+
+ this.setSubLayerInitOptipn();
+ this.initTileFactory();
+ }
+
+ public createTile(tile: Tile) {
+ return this.tileFactory.createTile(tile, this.initOptions);
+ }
+
+ public updateLayersConfig(layers: ILayer[], key: string, value: any) {
+ layers.map((layer) => {
+ if (key === 'mask') {
+ // Tip: 栅格瓦片生效、设置全局的 mask、瓦片被全局的 mask 影响
+ layer.style({
+ mask: value,
+ });
+ } else {
+ layer.updateLayerConfig({
+ [key]: value,
+ });
+ }
+ });
+ }
+
+ public addChild(layer: ILayer) {
+ this.children.push(layer);
+ }
+
+ public addChilds(layers: ILayer[]) {
+ this.children.push(...layers);
+ }
+
+ public removeChilds(layerIDList: string[], refresh = true) {
+ const remveLayerList: ILayer[] = [];
+ const cacheLayerList: ILayer[] = [];
+ this.children.filter((child) => {
+ layerIDList.includes(child.id)
+ ? remveLayerList.push(child)
+ : cacheLayerList.push(child);
+ });
+ remveLayerList.map((layer) => layer.destroy(refresh));
+ this.children = cacheLayerList;
+ }
+
+ public removeChild(layer: ILayer) {
+ const layerIndex = this.children.indexOf(layer);
+ if (layerIndex > -1) {
+ this.children.splice(layerIndex, 1);
+ }
+ layer.destroy();
+ }
+
+ public getChilds(layerIDList: string[]) {
+ return this.children.filter((child) => layerIDList.includes(child.id));
+ }
+
+ public getChild(layerID: string) {
+ return this.children.filter((child) => child.id === layerID)[0];
+ }
+
+ public clearChild() {
+ this.children.forEach((layer: any) => {
+ layer.destroy();
+ });
+
+ this.children.slice(0, this.children.length);
+ }
+
+ public hasChild(layer: ILayer) {
+ return this.children.includes(layer);
+ }
+
+ public render(): void {
+ this.children
+ .filter((layer) => layer.inited)
+ .filter((layer) => layer.isVisible())
+ .map((layer) => {
+ layer.hooks.beforeRenderData.call();
+ layer.hooks.beforeRender.call();
+ if (layer.masks.length > 0) {
+ // 清除上一次的模版缓存
+ this.rendererService.clear({
+ stencil: 0,
+ depth: 1,
+ framebuffer: null,
+ });
+ layer.masks.map((m: ILayer) => {
+ m.hooks.beforeRenderData.call();
+ m.hooks.beforeRender.call();
+ m.render();
+ m.hooks.afterRender.call();
+ });
+ }
+ layer.render();
+ layer.hooks.afterRender.call();
+ });
+ }
+
+ private setSubLayerInitOptipn() {
+ const {
+ zIndex = 0,
+ opacity = 1,
+ mask = false,
+ stroke = '#fff',
+ strokeWidth = 0,
+ strokeOpacity = 1,
+
+ workerEnabled = false,
+ sourceLayer,
+ } = this.parent.getLayerConfig() as ISubLayerInitOptions;
+
+ const source = this.parent.getSource();
+ const parentParserType = source.getParserType();
+
+ const colorAttribute = this.parent.getAttribute('color');
+ const basemapColor = (colorAttribute?.scale?.field || '#fff') as string;
+ const sizeAttribute = this.parent.getAttribute('size');
+ const basemapSize = (sizeAttribute?.scale?.field || 1) as number;
+
+ const layerShape = getLayerShape(this.parent.type, this.parent);
+
+ this.initOptions = {
+ usage: 'basemap',
+ layerType: this.parent.type,
+ shape: layerShape,
+ zIndex,
+ opacity,
+ sourceLayer: this.getSourceLayer(parentParserType, sourceLayer),
+ basemapColor,
+ basemapSize,
+ mask: getMaskValue(this.parent.type, mask),
+ stroke,
+ strokeWidth,
+ strokeOpacity,
+ // worker
+ workerEnabled,
+ };
+ }
+
+ private getSourceLayer(parentParserType: string, sourceLayer: string|undefined) {
+ if(parentParserType === 'geojsonvt') {
+ return 'geojsonvt';
+ } else if(parentParserType === 'testTile') {
+ return 'testTile';
+ } else {
+ return sourceLayer;
+ }
+ }
+
+ private initTileFactory() {
+ const source = this.parent.getSource();
+ const TileFactory = getTileFactory(
+ this.parent.type as TileType,
+ source.parser,
+ );
+ this.tileFactory = new TileFactory({
+ parent: this.parent,
+ mapService: this.mapService,
+ rendererService: this.rendererService,
+ });
+ }
+}
diff --git a/packages/layers/src/tile/manager/tileLayerManager.ts b/packages/layers/src/tile/manager/tileLayerManager.ts
index 922d88b10b..3103e53e28 100644
--- a/packages/layers/src/tile/manager/tileLayerManager.ts
+++ b/packages/layers/src/tile/manager/tileLayerManager.ts
@@ -1,7 +1,6 @@
import {
IInteractionTarget,
ILayer,
- ILayerService,
IMapService,
IPickingService,
IRendererService,
@@ -33,7 +32,6 @@ export class TileLayerManager implements ITileLayerManager {
mapService: IMapService,
rendererService: IRendererService,
pickingService: IPickingService,
- layerService: ILayerService,
transforms: ITransform[]
) {
this.parent = parent;
@@ -47,7 +45,6 @@ export class TileLayerManager implements ITileLayerManager {
rendererService,
pickingService,
this.children,
- layerService,
);
this.tileConfigManager = new TileConfigManager();
@@ -178,10 +175,18 @@ export class TileLayerManager implements ITileLayerManager {
const parentParserType = source.getParserType();
const layerShape = getLayerShape(this.parent.type, this.parent);
-
+ let colorTexture = undefined;
if (rampColors) {
// 构建统一的色带贴图
+ const { createTexture2D } = this.rendererService;
this.rampColorsData = generateColorRamp(rampColors as IColorRamp);
+ const imageData = generateColorRamp(rampColors as IColorRamp);
+ colorTexture = createTexture2D({
+ data: this.rampColorsData.data,
+ width: imageData.width,
+ height: imageData.height,
+ flipY: false,
+ });
}
@@ -206,6 +211,7 @@ export class TileLayerManager implements ITileLayerManager {
domain,
rampColors,
rampColorsData: this.rampColorsData,
+ colorTexture,
// worker
workerEnabled,
diff --git a/packages/layers/src/tile/manager/tilePickerManager.ts b/packages/layers/src/tile/manager/tilePickerManager.ts
index aaa8cb0fff..f81ac90819 100644
--- a/packages/layers/src/tile/manager/tilePickerManager.ts
+++ b/packages/layers/src/tile/manager/tilePickerManager.ts
@@ -1,7 +1,6 @@
import {
IInteractionTarget,
ILayer,
- ILayerService,
IPickingService,
IRendererService,
ITilePickManager,
@@ -12,7 +11,6 @@ export default class TilePickManager extends EventEmitter
public isLastPicked: boolean = false;
private rendererService: IRendererService;
private pickingService: IPickingService;
- private layerService: ILayerService;
private children: ILayer[];
private parent: ILayer;
@@ -21,13 +19,11 @@ export default class TilePickManager extends EventEmitter
rendererService: IRendererService,
pickingService: IPickingService,
children: ILayer[],
- layerService: ILayerService,
) {
super();
this.parent = parent;
this.rendererService = rendererService;
this.pickingService = pickingService;
- this.layerService = layerService;
this.children = children;
}
diff --git a/packages/layers/src/tile/models/tileModel.ts b/packages/layers/src/tile/models/tileModel.ts
index 4d02e86366..43334cdf9e 100644
--- a/packages/layers/src/tile/models/tileModel.ts
+++ b/packages/layers/src/tile/models/tileModel.ts
@@ -1,15 +1,27 @@
import { IModelUniform } from '@antv/l7-core';
import BaseModel from '../../core/BaseModel';
import { TMSTileLayer } from '../tmsTileLayer';
+import { TMSBaseMapTileLayer } from '../tmsMapTileLayer';
export default class TileModel extends BaseModel {
public getUninforms(): IModelUniform {
return {};
}
+ private getTileLayer(usage?: string) {
+ switch(usage) {
+ case 'basemap':
+ return TMSBaseMapTileLayer;
+ default:
+ return TMSTileLayer;
+ }
+ }
+
public initModels() {
const source = this.layer.getSource();
- if (source?.data.isTile) {
- this.layer.tileLayer = new TMSTileLayer({
+ const { usage } = this.layer.getLayerConfig();
+ if (source?.data.isTile && !this.layer.tileLayer) {
+ const tileLayer = this.getTileLayer(usage);
+ this.layer.tileLayer = new tileLayer({
parent: this.layer,
rendererService: this.rendererService,
mapService: this.mapService,
diff --git a/packages/layers/src/tile/tileFactory/base.ts b/packages/layers/src/tile/tileFactory/base.ts
index d1cc700c5e..bdb484d964 100644
--- a/packages/layers/src/tile/tileFactory/base.ts
+++ b/packages/layers/src/tile/tileFactory/base.ts
@@ -19,6 +19,7 @@ import VectorLayer from './vectorLayer';
import * as turf from '@turf/helpers';
import union from '@turf/union';
+import clone from '@turf/clone';
import polygonToLineString from '@turf/polygon-to-line';
import {
CacheEvent,
@@ -29,6 +30,12 @@ import {
Timeout,
} from '../interface';
+const EMPTY_FEATURE_DATA = {
+ features: [],
+ featureId: null,
+ vectorTileLayer: null,
+ source: null,
+};
export default class TileFactory implements ITileFactory {
public type: string;
public parentLayer: ILayer;
@@ -56,6 +63,7 @@ export default class TileFactory implements ITileFactory {
this.tilesetManager = source.tileset as TilesetManager;
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public createTile(tile: Tile, initOptions: ISubLayerInitOptions) {
return {
layers: [] as ILayer[],
@@ -64,33 +72,28 @@ export default class TileFactory implements ITileFactory {
}
public getFeatureData(tile: Tile, initOptions: ISubLayerInitOptions) {
- const emptyData = {
- features: [],
- featureId: null,
- vectorTileLayer: null,
- source: null,
- };
- const { sourceLayer, featureId, transforms, layerType, shape } = initOptions;
+ const { sourceLayer, featureId, transforms = [], layerType, shape } = initOptions;
if (!sourceLayer) {
- return emptyData;
+ return EMPTY_FEATURE_DATA;
}
const vectorTileLayer = tile.data.layers[sourceLayer];
const features = vectorTileLayer?.features;
if (!(Array.isArray(features) && features.length > 0)) {
- return emptyData;
+ return EMPTY_FEATURE_DATA;
} else {
let geofeatures = [];
if(layerType === 'LineLayer' && shape === 'simple') {
features.map(feature => {
- if(feature.geometry.type === 'MultiPolygon') {
+ const cloneFeature = clone(feature);
+ if(cloneFeature.geometry.type === 'MultiPolygon') {
// @ts-ignore
- const linefeatures = polygonToLineString(feature).features
+ const linefeatures = polygonToLineString(cloneFeature).features
geofeatures.push(...linefeatures)
- } else if(feature.geometry.type === 'Polygon') {
- feature.geometry.type = 'MultiLineString'
- geofeatures.push(feature);
+ } else if(cloneFeature.geometry.type === 'Polygon') {
+ cloneFeature.geometry.type = 'MultiLineString'
+ geofeatures.push(cloneFeature);
} else {
- geofeatures.push(feature);
+ geofeatures.push(cloneFeature);
}
})
} else {
@@ -106,6 +109,7 @@ export default class TileFactory implements ITileFactory {
parser: {
type: 'geojson',
featureId,
+ cancelExtent: true
},
transforms
},
@@ -128,7 +132,7 @@ export default class TileFactory implements ITileFactory {
vectorTileLayer,
source,
} = tileLayerOption;
- const { mask, color, layerType, size, shape } = initOptions;
+ const { mask, color, layerType, size, shape, usage, basemapColor, basemapSize } = initOptions;
const FactoryTileLayer = L7Layer ? L7Layer : VectorLayer;
const layer = new FactoryTileLayer({
visible: tile.isVisible,
@@ -136,23 +140,35 @@ export default class TileFactory implements ITileFactory {
coord: vectorTileLayer?.l7TileCoord,
...this.getLayerInitOption(initOptions),
});
- // vector layer set config
- if (layer.isVector) {
+
+ if(layerType) layer.type = layerType;
+
+ // Tip: sign tile layer
+ layer.isTileLayer = true; // vector 、raster
+
+ // vector layer set event
+ if (layer.isVector && usage !== 'basemap') {
this.emitEvent([layer]);
- layer.type = layerType;
layer.select(true);
}
// set source
layer.source(source);
- // set scale
- this.setScale(layer);
-
// set scale attribute field
this.setStyleAttributeField(layer, 'shape', shape);
- this.setStyleAttributeField(layer, 'color', color);
- this.setStyleAttributeField(layer, 'size', size);
+ if(usage !== 'basemap') {
+ // set scale
+ this.setScale(layer);
+
+ this.setStyleAttributeField(layer, 'color', color);
+ this.setStyleAttributeField(layer, 'size', size);
+ } else {
+ layer.style({
+ color: basemapColor,
+ size: basemapSize
+ })
+ }
// set mask
const layers = [layer];
@@ -161,8 +177,12 @@ export default class TileFactory implements ITileFactory {
.source({
type: 'FeatureCollection',
features: [tile.bboxPolygon],
- })
- .shape('fill');
+ }, {
+ parser: {
+ type: 'geojson',
+ cancelExtent: true
+ }
+ });
layers.push(masklayer as VectorLayer);
@@ -183,7 +203,7 @@ export default class TileFactory implements ITileFactory {
public getDefautStyleAttributeField(layer: ILayer, type: string) {
switch (type) {
case 'size':
- return 2;
+ return 1;
case 'color':
return '#fff';
case 'shape':
@@ -250,8 +270,7 @@ export default class TileFactory implements ITileFactory {
const tiles = this.tilesetManager.tiles.filter(
(t) => t.key === `${xy[0]},${xy[1]},${z}`,
);
- const tile = tiles[0];
- return tile;
+ return tiles[0];
}
protected emitEvent(layers: ILayer[], isVector?: boolean) {
@@ -262,7 +281,7 @@ export default class TileFactory implements ITileFactory {
if (this.parentLayer.type === 'RasterLayer') {
const { lng, lat } = e.lngLat;
const tile = this.getTile(lng, lat);
- this.getFeatureAndEmitEvent(
+ tile && this.getFeatureAndEmitEvent(
layer,
'subLayerClick',
e,
@@ -279,7 +298,7 @@ export default class TileFactory implements ITileFactory {
if (this.parentLayer.type === 'RasterLayer') {
const { lng, lat } = e.lngLat;
const tile = this.getTile(lng, lat);
- this.getFeatureAndEmitEvent(
+ tile && this.getFeatureAndEmitEvent(
layer,
'subLayerMouseMove',
e,
@@ -298,7 +317,7 @@ export default class TileFactory implements ITileFactory {
if (this.parentLayer.type === 'RasterLayer') {
const { lng, lat } = e.lngLat;
const tile = this.getTile(lng, lat);
- this.getFeatureAndEmitEvent(
+ tile && this.getFeatureAndEmitEvent(
layer,
'subLayerMouseMove',
e,
diff --git a/packages/layers/src/tile/tileFactory/line.ts b/packages/layers/src/tile/tileFactory/line.ts
index 64070c5420..389a5763de 100644
--- a/packages/layers/src/tile/tileFactory/line.ts
+++ b/packages/layers/src/tile/tileFactory/line.ts
@@ -29,7 +29,9 @@ export default class VectorPolygonTile extends TileFactory {
vectorTileLayer,
source: source as Source,
});
-
+ layer.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [layer],
layerIDList: [layer.id],
diff --git a/packages/layers/src/tile/tileFactory/point.ts b/packages/layers/src/tile/tileFactory/point.ts
index 63d71e187c..d0e249b822 100644
--- a/packages/layers/src/tile/tileFactory/point.ts
+++ b/packages/layers/src/tile/tileFactory/point.ts
@@ -29,6 +29,9 @@ export default class VectorPolygonTile extends TileFactory {
vectorTileLayer,
source: source as Source,
});
+ layer.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [layer],
layerIDList: [layer.id],
diff --git a/packages/layers/src/tile/tileFactory/polygon.ts b/packages/layers/src/tile/tileFactory/polygon.ts
index 64070c5420..389a5763de 100644
--- a/packages/layers/src/tile/tileFactory/polygon.ts
+++ b/packages/layers/src/tile/tileFactory/polygon.ts
@@ -29,7 +29,9 @@ export default class VectorPolygonTile extends TileFactory {
vectorTileLayer,
source: source as Source,
});
-
+ layer.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [layer],
layerIDList: [layer.id],
diff --git a/packages/layers/src/tile/tileFactory/raster.ts b/packages/layers/src/tile/tileFactory/raster.ts
index 72b3e22098..413dcb7bfa 100644
--- a/packages/layers/src/tile/tileFactory/raster.ts
+++ b/packages/layers/src/tile/tileFactory/raster.ts
@@ -26,7 +26,9 @@ export default class RasterTile extends TileFactory {
initOptions,
source,
});
-
+ layer.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [layer],
layerIDList: [layer.id],
diff --git a/packages/layers/src/tile/tileFactory/rasterData.ts b/packages/layers/src/tile/tileFactory/rasterData.ts
index 11371c3b02..b0493917f0 100644
--- a/packages/layers/src/tile/tileFactory/rasterData.ts
+++ b/packages/layers/src/tile/tileFactory/rasterData.ts
@@ -55,7 +55,9 @@ export default class RasterTiffTile extends TileFactory {
this.emitEvent([layer], false);
registerLayers(this.parentLayer, [layer]);
-
+ layer.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [layer],
layerIDList: [layer.id],
diff --git a/packages/layers/src/tile/tileFactory/rasterDataLayer.ts b/packages/layers/src/tile/tileFactory/rasterDataLayer.ts
index 36bebcd234..b017af8eaf 100644
--- a/packages/layers/src/tile/tileFactory/rasterDataLayer.ts
+++ b/packages/layers/src/tile/tileFactory/rasterDataLayer.ts
@@ -11,12 +11,16 @@ export default class RasterTiffLayer extends BaseLayer<
this.layerModel = new model(this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getModelType() {
diff --git a/packages/layers/src/tile/tileFactory/test.ts b/packages/layers/src/tile/tileFactory/test.ts
index b94c4de25f..c7b626aaca 100644
--- a/packages/layers/src/tile/tileFactory/test.ts
+++ b/packages/layers/src/tile/tileFactory/test.ts
@@ -35,32 +35,49 @@ export default class TestTile extends TileFactory {
const properties = features[0].properties;
- const text = new VectorLayer({ layerType: 'PointLayer' })
+ const text = new VectorLayer({ layerType: 'PointLayer', usage: 'basemap' })
.source([properties], {
parser: {
type: 'json',
x: 'textLng',
- y: 'textLat'
+ y: 'textLat',
+ cancelExtent: true,
}
})
.shape('key', 'text')
- .size(20)
- .color('#000')
.style({
+ size: 20,
+ color: '#000',
stroke: '#fff',
strokeWidth: 2
- })
+ });
- const line = new VectorLayer({ layerType: 'LineLayer' })
+ const line = new VectorLayer({ layerType: 'LineLayer', usage: 'basemap' })
.source({
type: 'FeatureCollection',
features: features,
+ }, {
+ parser: {
+ type: 'geojson',
+ cancelExtent: true,
+ }
})
.shape('simple')
- .color('#000')
+ .style({
+ color: '#000'
+ });
+
+ // Tip: sign tile layer
+ text.isTileLayer = true;
+ line.isTileLayer = true;
registerLayers(this.parentLayer, [line, text]);
-
+ text.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
+ line.once('modelLoaded', () => {
+ tile.layerLoad();
+ })
return {
layers: [line, text],
layerIDList: [line.id, text.id],
diff --git a/packages/layers/src/tile/tileFactory/vectorLayer.ts b/packages/layers/src/tile/tileFactory/vectorLayer.ts
index d01d1bb694..d603b2815d 100644
--- a/packages/layers/src/tile/tileFactory/vectorLayer.ts
+++ b/packages/layers/src/tile/tileFactory/vectorLayer.ts
@@ -1,4 +1,17 @@
-import { IEncodeFeature } from '@antv/l7-core';
+import {
+ TYPES,
+ ICameraService,
+ ICoordinateSystemService,
+ IEncodeFeature,
+ IFontService,
+ IIconService,
+ ILayerPlugin,
+ ILayerService,
+ IMapService,
+ IRendererService,
+ IShaderModuleService,
+ IStyleAttributeService,
+} from '@antv/l7-core';
import BaseLayer from '../../core/BaseLayer';
import {
ILineLayerStyleOptions,
@@ -6,7 +19,7 @@ import {
IPolygonLayerStyleOptions,
} from '../../core/interface';
import lineFillModel from '../../line/models/tile';
-import lineSimpleModel from '../../line/models/simpleLine';
+import lineSimpleModel from '../../line/models/simpleTileLine';
import pointTextModel from '../../point/models/tileText';
import pointFillModel from '../../point/models/tile';
@@ -18,10 +31,111 @@ export default class VectorLayer extends BaseLayer<
>
> {
public isVector: boolean = true;
- public type: string = this.layerType as string;
+ public type: string = this.layerType as string || 'vectorLayer';
// Tip: 单独被 tile 瓦片的渲染链路使用(用于优化性能)
private pickedID: number | null = null;
+
+ public init() {
+ // 设置配置项
+ const sceneId = this.container.get(TYPES.SceneID);
+ this.configService.setLayerConfig(sceneId, this.id, this.rawConfig);
+ this.layerType = this.rawConfig.layerType;
+
+ if(this.type === 'PointLayer') {
+ // Tip: iconService 和 fontService 只有在矢量点图层中才会被使用
+ this.iconService = this.container.get(TYPES.IIconService);
+ this.fontService = this.container.get(TYPES.IFontService);
+ }
+
+ this.rendererService = this.container.get(
+ TYPES.IRendererService,
+ );
+ this.layerService = this.container.get(TYPES.ILayerService);
+
+ this.mapService = this.container.get(TYPES.IMapService);
+
+ this.cameraService = this.container.get(
+ TYPES.ICameraService,
+ );
+ this.coordinateService = this.container.get(
+ TYPES.ICoordinateSystemService,
+ );
+ this.shaderModuleService = this.container.get(
+ TYPES.IShaderModuleService,
+ );
+ this.postProcessingPassFactory = this.container.get(
+ TYPES.IFactoryPostProcessingPass,
+ );
+ this.normalPassFactory = this.container.get(TYPES.IFactoryNormalPass);
+
+ // 图层容器服务
+ this.styleAttributeService = this.container.get(
+ TYPES.IStyleAttributeService,
+ );
+
+ // 完成样式服务注册完成前添加的属性
+ this.pendingStyleAttributes.forEach(
+ ({ attributeName, attributeField, attributeValues, updateOptions }) => {
+ this.styleAttributeService.updateStyleAttribute(
+ attributeName,
+ {
+ // @ts-ignore
+ scale: {
+ field: attributeField,
+ ...this.splitValuesAndCallbackInAttribute(
+ // @ts-ignore
+ attributeValues,
+ // @ts-ignore
+ this.getLayerConfig()[attributeName],
+ ),
+ },
+ },
+ // @ts-ignore
+ updateOptions,
+ );
+ },
+ );
+ this.pendingStyleAttributes = [];
+
+ // 获取插件集
+ this.plugins = this.container.getAll(TYPES.ILayerPlugin);
+ // 完成插件注册,传入场景和图层容器内的服务
+ for (const plugin of this.plugins) {
+ plugin.apply(this, {
+ rendererService: this.rendererService,
+ mapService: this.mapService,
+ styleAttributeService: this.styleAttributeService,
+ normalPassFactory: this.normalPassFactory,
+ postProcessingPassFactory: this.postProcessingPassFactory,
+ });
+ }
+
+ // 触发 init 生命周期插件
+ this.hooks.init.call();
+ this.hooks.afterInit.call();
+
+ return this;
+ }
+
+ public renderModels(isPicking?: boolean) {
+ this.models.forEach((model) => {
+ model.draw(
+ {
+ uniforms: this.layerModel.getUninforms(),
+ },
+ isPicking,
+ );
+ });
+ return this;
+ }
+
+ protected sourceEvent = () => {
+ // Tip: vector 不支持 autoFit
+ this.dataState.dataSourceNeedUpdate = true;
+ this.reRender();
+ };
+
public getPickID() {
return this.pickedID;
}
@@ -35,12 +149,16 @@ export default class VectorLayer extends BaseLayer<
this.layerModel = new model(this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
protected getModelType() {
diff --git a/packages/layers/src/tile/tileLayer/baseMapTileLayer.ts b/packages/layers/src/tile/tileLayer/baseMapTileLayer.ts
new file mode 100644
index 0000000000..cac402a014
--- /dev/null
+++ b/packages/layers/src/tile/tileLayer/baseMapTileLayer.ts
@@ -0,0 +1,179 @@
+import {
+ ILayer,
+ ILayerService,
+ IMapService,
+ ISource,
+ IBaseTileLayer,
+ IBaseTileLayerManager,
+ ITileLayerOPtions,
+} from '@antv/l7-core';
+import { Tile, TilesetManager } from '@antv/l7-utils';
+import { BaseMapTileLayerManager } from '../manager/baseMapTileLayerManager';
+import { debounce } from 'lodash';
+
+export default class BaseTileLayer implements IBaseTileLayer {
+ public get children() {
+ return this.tileLayerManager.children;
+ }
+ public type: string = 'baseTile';
+ public sourceLayer: string;
+ public parent: ILayer;
+ // 瓦片是否加载成功
+ public initedTileset: boolean = false;
+ // 瓦片数据管理器
+ public tilesetManager: TilesetManager | undefined;
+ public tileLayerManager: IBaseTileLayerManager;
+ public scaleField: any;
+
+ private lastViewStates: {
+ zoom: number;
+ latLonBounds: [number, number, number, number];
+ };
+
+ protected mapService: IMapService;
+ protected layerService: ILayerService;
+
+ constructor({
+ parent,
+ rendererService,
+ mapService,
+ layerService,
+ }: ITileLayerOPtions) {
+ const parentSource = parent.getSource();
+ const { sourceLayer } =
+ parentSource?.data?.tilesetOptions || {};
+ this.sourceLayer = sourceLayer;
+ this.parent = parent;
+ this.mapService = mapService;
+ this.layerService = layerService;
+
+ this.tileLayerManager = new BaseMapTileLayerManager(
+ parent,
+ mapService,
+ rendererService,
+ );
+
+ this.initTileSetManager();
+ }
+
+ /**
+ * 渲染瓦片的图层
+ */
+ public render() {
+ if (this.tileLayerManager) {
+ this.tileLayerManager.render();
+ }
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ public tileLoaded(tile: Tile) {
+ //
+ }
+
+ public tileError(error: Error) {
+ console.warn('error:', error);
+ }
+
+ public tileUnLoad(tile: Tile) {
+ this.tileLayerManager.removeChilds(tile.layerIDList, false);
+ }
+
+ public tileUpdate() {
+ // Base Function
+ if (!this.tilesetManager) {
+ return;
+ }
+
+ if (this.tilesetManager.isLoaded) {
+ // 将事件抛出,图层上可以使用瓦片
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
+ }
+ }
+
+ private initTileSetManager() {
+ const source: ISource = this.parent.getSource();
+ this.tilesetManager = source.tileset as TilesetManager;
+
+ if (!this.initedTileset) {
+ this.bindTilesetEvent();
+ this.initedTileset = true;
+ }
+
+ const { latLonBounds, zoom } = this.getCurrentView();
+ this.tilesetManager?.update(zoom, latLonBounds);
+ }
+
+ private mapchange() {
+ const { latLonBounds, zoom } = this.getCurrentView();
+
+ if (this.mapService.version === 'GAODE1.x') {
+ const { visible } = this.parent.getLayerConfig();
+ if (zoom < 3 && visible) {
+ this.parent.updateLayerConfig({ visible: false });
+ this.layerService.reRender();
+ } else if (zoom >= 3 && !visible) {
+ this.parent.updateLayerConfig({ visible: true });
+ this.layerService.reRender();
+ }
+ }
+
+ if (
+ this.lastViewStates &&
+ this.lastViewStates.zoom === zoom &&
+ this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()
+ ) {
+ return;
+ }
+ this.lastViewStates = { zoom, latLonBounds };
+
+ this.tilesetManager?.update(zoom, latLonBounds);
+ }
+
+ private bindTilesetEvent() {
+ if (!this.tilesetManager) {
+ return;
+ }
+ // 瓦片数据加载成功
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ this.tilesetManager.on('tile-loaded', (tile: Tile) => {
+ // 将事件抛出,图层上可以监听使用
+ });
+
+ // 瓦片数据从缓存删除或被执行重新加载
+ this.tilesetManager.on('tile-unload', (tile: Tile) => {
+ // 将事件抛出,图层上可以监听使用
+ this.tileUnLoad(tile);
+ });
+
+ // 瓦片数据加载失败
+ this.tilesetManager.on('tile-error', (error, tile: Tile) => {
+ // 将事件抛出,图层上可以监听使用
+ this.tileError(error);
+ });
+
+ // 瓦片显隐状态更新
+ this.tilesetManager.on('tile-update', () => {
+ this.tileUpdate();
+ });
+
+ // 地图视野发生改变
+ this.mapService.on('zoomend', () => this.viewchange());
+ this.mapService.on('moveend', () => this.viewchange());
+ }
+
+ // 防抖操作
+ viewchange = debounce(this.mapchange, 200)
+
+ private getCurrentView() {
+ const bounds = this.mapService.getBounds();
+ const latLonBounds: [number, number, number, number] = [
+ bounds[0][0],
+ bounds[0][1],
+ bounds[1][0],
+ bounds[1][1],
+ ];
+ const zoom = this.mapService.getZoom();
+
+ return { latLonBounds, zoom };
+ }
+}
diff --git a/packages/layers/src/tile/tileLayer/baseTileLayer.ts b/packages/layers/src/tile/tileLayer/baseTileLayer.ts
index eb116b0cba..3fa5085e86 100644
--- a/packages/layers/src/tile/tileLayer/baseTileLayer.ts
+++ b/packages/layers/src/tile/tileLayer/baseTileLayer.ts
@@ -10,6 +10,7 @@ import {
} from '@antv/l7-core';
import { decodePickingColor, Tile, TilesetManager } from '@antv/l7-utils';
import { TileLayerManager } from '../manager/tileLayerManager';
+import { debounce } from 'lodash';
export default class BaseTileLayer implements ITileLayer {
public get children() {
@@ -30,9 +31,8 @@ export default class BaseTileLayer implements ITileLayer {
latLonBounds: [number, number, number, number];
};
- private timer: any;
- private mapService: IMapService;
- private layerService: ILayerService;
+ protected mapService: IMapService;
+ protected layerService: ILayerService;
private pickColors: {
select: any;
active: any;
@@ -50,7 +50,7 @@ export default class BaseTileLayer implements ITileLayer {
transforms
}: ITileLayerOPtions) {
const parentSource = parent.getSource();
- const { sourceLayer, coords, featureId } =
+ const { sourceLayer } =
parentSource?.data?.tilesetOptions || {};
this.sourceLayer = sourceLayer;
this.parent = parent;
@@ -62,7 +62,6 @@ export default class BaseTileLayer implements ITileLayer {
mapService,
rendererService,
pickingService,
- layerService,
transforms
);
@@ -128,28 +127,6 @@ export default class BaseTileLayer implements ITileLayer {
return;
}
- this.tilesetManager.tiles
- .filter((tile) => tile.isLoaded)
- .map((tile) => {
- if (tile.layerIDList.length === 0) {
- const { layers, layerIDList } = this.tileLayerManager.createTile(
- tile,
- );
- tile.layerIDList = layerIDList;
- this.tileLayerManager.addChilds(layers);
- } else {
- if (!tile.isVisibleChange) {
- return;
- }
- const layers = this.tileLayerManager.getChilds(tile.layerIDList);
- this.tileLayerManager.updateLayersConfig(
- layers,
- 'visible',
- tile.isVisible,
- );
- }
- });
-
if (this.tilesetManager.isLoaded) {
// 将事件抛出,图层上可以使用瓦片
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
@@ -330,10 +307,10 @@ export default class BaseTileLayer implements ITileLayer {
const { visible } = this.parent.getLayerConfig();
if (zoom < 3 && visible) {
this.parent.updateLayerConfig({ visible: false });
- this.layerService.updateLayerRenderList();
+ this.layerService.reRender();
} else if (zoom >= 3 && !visible) {
this.parent.updateLayerConfig({ visible: true });
- this.layerService.updateLayerRenderList();
+ this.layerService.reRender();
}
}
@@ -346,14 +323,7 @@ export default class BaseTileLayer implements ITileLayer {
}
this.lastViewStates = { zoom, latLonBounds };
- if (this.timer) {
- clearTimeout(this.timer);
- this.timer = null;
- }
-
- // this.timer = setTimeout(() => {
this.tilesetManager?.update(zoom, latLonBounds);
- // }, 250);
}
private bindTilesetEvent() {
@@ -362,18 +332,18 @@ export default class BaseTileLayer implements ITileLayer {
}
// 瓦片数据加载成功
this.tilesetManager.on('tile-loaded', (tile: Tile) => {
- // todo: 将事件抛出,图层上可以监听使用
+ // 将事件抛出,图层上可以监听使用
});
// 瓦片数据从缓存删除或被执行重新加载
this.tilesetManager.on('tile-unload', (tile: Tile) => {
- // todo: 将事件抛出,图层上可以监听使用
+ // 将事件抛出,图层上可以监听使用
this.tileUnLoad(tile);
});
// 瓦片数据加载失败
this.tilesetManager.on('tile-error', (error, tile: Tile) => {
- // todo: 将事件抛出,图层上可以监听使用
+ // 将事件抛出,图层上可以监听使用
this.tileError(error);
});
@@ -383,10 +353,13 @@ export default class BaseTileLayer implements ITileLayer {
});
// 地图视野发生改变
- this.mapService.on('zoomend', () => this.mapchange());
- this.mapService.on('moveend', () => this.mapchange());
+ this.mapService.on('zoomend', () => this.viewchange());
+ this.mapService.on('moveend', () => this.viewchange());
}
+ // 防抖操作
+ viewchange = debounce(this.mapchange, 200)
+
private getCurrentView() {
const bounds = this.mapService.getBounds();
const latLonBounds: [number, number, number, number] = [
diff --git a/packages/layers/src/tile/tileTest.ts b/packages/layers/src/tile/tileTest.ts
index bc51b6f933..3d946ac4d8 100644
--- a/packages/layers/src/tile/tileTest.ts
+++ b/packages/layers/src/tile/tileTest.ts
@@ -9,6 +9,7 @@ export default class TileDebugLayer extends BaseLayer {
options: {
parser: {
type: 'testTile',
+ cancelExtent: true,
},
},
};
@@ -16,7 +17,7 @@ export default class TileDebugLayer extends BaseLayer {
this.layerModel = new TileModel(this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
});
}
}
diff --git a/packages/layers/src/tile/tmsMapTileLayer.ts b/packages/layers/src/tile/tmsMapTileLayer.ts
new file mode 100644
index 0000000000..53a6a83b13
--- /dev/null
+++ b/packages/layers/src/tile/tmsMapTileLayer.ts
@@ -0,0 +1,69 @@
+import { ILayer } from '@antv/l7-core';
+import { Tile } from '@antv/l7-utils';
+import BaseTileLayer from './tileLayer/baseMapTileLayer';
+import { tileAllLoad } from './utils';
+
+export class TMSBaseMapTileLayer extends BaseTileLayer {
+ public type: string = 'BaseMapTMS';
+ public tileUnLoad(tile: Tile) {
+ this.tileLayerManager.removeChilds(tile.layerIDList, false);
+ }
+ public tileUpdate() {
+ if (!this.tilesetManager) {
+ return;
+ }
+ this.tilesetManager.tiles
+ .filter((tile: Tile) => tile.isLoaded)
+ .map((tile: Tile) => {
+ if (tile.data?.layers && this.sourceLayer) {
+ // vector
+ const vectorTileLayer = tile.data.layers[this.sourceLayer];
+ const features = vectorTileLayer?.features;
+ if (!(Array.isArray(features) && features.length > 0)) {
+ return;
+ }
+ }
+ if (!tile.parentLayerIDList.includes(this.parent.id)) {
+ const { layers, layerIDList } = this.tileLayerManager.createTile(
+ tile,
+ );
+ tile.parentLayerIDList.push(this.parent.id);
+ tile.layerIDList.push(...layerIDList);
+
+ this.tileLayerManager.addChilds(layers);
+ } else {
+ if (!tile.isVisibleChange) {
+ return;
+ }
+ const layers = this.tileLayerManager.getChilds(tile.layerIDList);
+ this.updateTileVisible(tile, layers);
+ }
+ });
+
+ if (this.tilesetManager.isLoaded) {
+ // 将事件抛出,图层上可以使用瓦片
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
+ }
+ }
+
+ private emitTileVisibleEvent(tile: Tile, callback: () => void) {
+ if (tile.isVisible) {
+ callback();
+ } else {
+ tileAllLoad(tile, () => {
+ callback();
+ });
+ }
+ }
+
+ private updateTileVisible(tile: Tile, layers: ILayer[]) {
+ this.emitTileVisibleEvent(tile, () => {
+ this.tileLayerManager.updateLayersConfig(
+ layers,
+ 'visible',
+ tile.isVisible,
+ );
+ this.layerService.reRender();
+ });
+ }
+}
diff --git a/packages/layers/src/tile/tmsTileLayer.ts b/packages/layers/src/tile/tmsTileLayer.ts
index f60f8dc4b9..865232863d 100644
--- a/packages/layers/src/tile/tmsTileLayer.ts
+++ b/packages/layers/src/tile/tmsTileLayer.ts
@@ -1,5 +1,7 @@
+import { ILayer } from '@antv/l7-core';
import { Tile } from '@antv/l7-utils';
import BaseTileLayer from './tileLayer/baseTileLayer';
+import { tileAllLoad } from './utils';
export class TMSTileLayer extends BaseTileLayer {
public type: string = 'TMS';
@@ -35,20 +37,35 @@ export class TMSTileLayer extends BaseTileLayer {
return;
}
const layers = this.tileLayerManager.getChilds(tile.layerIDList);
- this.tileLayerManager.updateLayersConfig(
- layers,
- 'visible',
- tile.isVisible,
- );
+ this.updateTileVisible(tile, layers);
this.setPickState(layers);
}
});
- this.parent.renderLayers();
-
if (this.tilesetManager.isLoaded) {
// 将事件抛出,图层上可以使用瓦片
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
}
}
+
+ private emitTileVisibleEvent(tile: Tile, callback: () => void) {
+ if (tile.isVisible) {
+ callback();
+ } else {
+ tileAllLoad(tile, () => {
+ callback();
+ });
+ }
+ }
+
+ private updateTileVisible(tile: Tile, layers: ILayer[]) {
+ this.emitTileVisibleEvent(tile, () => {
+ this.tileLayerManager.updateLayersConfig(
+ layers,
+ 'visible',
+ tile.isVisible,
+ );
+ this.layerService.reRender();
+ });
+ }
}
diff --git a/packages/layers/src/tile/utils.ts b/packages/layers/src/tile/utils.ts
index ab7c8e5fb6..051fa3f0c8 100644
--- a/packages/layers/src/tile/utils.ts
+++ b/packages/layers/src/tile/utils.ts
@@ -135,3 +135,33 @@ export function readPixel(
});
return pickedColors;
}
+
+export function isTileLoaded(tile: Tile) {
+ return tile.layerIDList.length === tile.loadedLayers;
+}
+
+export function isTileChildLoaded(tile: Tile) {
+ const childs = tile.children;
+ return childs.filter((child) => isTileLoaded(child)).length === childs.length;
+}
+
+export function isTileParentLoaded(tile: Tile) {
+ const parent = tile.parent;
+ if (!parent) {
+ return true;
+ } else {
+ return isTileLoaded(parent);
+ }
+}
+
+export function tileAllLoad(tile: Tile, callback: () => void) {
+ const timer = window.setInterval(() => {
+ const tileLoaded = isTileLoaded(tile);
+ const tileChildLoaded = isTileChildLoaded(tile);
+ const tileParentLoaded = isTileParentLoaded(tile);
+ if (tileLoaded && tileChildLoaded && tileParentLoaded) {
+ callback();
+ window.clearInterval(timer);
+ }
+ }, 36);
+}
diff --git a/packages/layers/src/utils/dataMappingStyle.ts b/packages/layers/src/utils/dataMappingStyle.ts
index 67a6add5a9..eee5c2f2c0 100644
--- a/packages/layers/src/utils/dataMappingStyle.ts
+++ b/packages/layers/src/utils/dataMappingStyle.ts
@@ -44,6 +44,9 @@ function registerStyleAttribute(
* @param layer
*/
function handleStyleDataMapping(configToUpdate: IConfigToUpdate, layer: any) {
+ // 瓦片图层不需要进行样式数据映射
+ if (layer.tileLayer || layer.isTileLayer) return;
+
if (configToUpdate.opacity) {
// 处理 style 中 opacity 属性的数据映射
handleStyleFloat('opacity', layer, configToUpdate.opacity);
diff --git a/packages/layers/src/utils/layerData.ts b/packages/layers/src/utils/layerData.ts
index 15a2cc2a47..bf4559db26 100644
--- a/packages/layers/src/utils/layerData.ts
+++ b/packages/layers/src/utils/layerData.ts
@@ -34,7 +34,7 @@ function adjustData2Amap2Coordinates(
// 单个的点数据
// @ts-ignore
mappedData
- // TODO: 避免经纬度被重复计算导致坐标位置偏移
+ // 避免经纬度被重复计算导致坐标位置偏移
.filter((d) => !d.originCoordinates)
.map((d) => {
d.version = Version['GAODE2.x'];
@@ -47,7 +47,7 @@ function adjustData2Amap2Coordinates(
// 连续的线、面数据
// @ts-ignore
mappedData
- // TODO: 避免经纬度被重复计算导致坐标位置偏移
+ // 避免经纬度被重复计算导致坐标位置偏移
.filter((d) => !d.originCoordinates)
.map((d) => {
d.version = Version['GAODE2.x'];
diff --git a/packages/layers/src/utils/updateShape.ts b/packages/layers/src/utils/updateShape.ts
index 15dda8c13c..249f76ea08 100644
--- a/packages/layers/src/utils/updateShape.ts
+++ b/packages/layers/src/utils/updateShape.ts
@@ -1,5 +1,5 @@
import { ILayer, StyleAttributeField } from '@antv/l7-core';
-// TODO: shapeUpdateList 存储一系列的 shape 类型
+// shapeUpdateList 存储一系列的 shape 类型
// 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)
const shapeUpdateList = [
// PointLayer
@@ -30,7 +30,7 @@ export function updateShape(
shapeUpdateList.map((shapes) => {
if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
- // TODO: dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
+ // dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
layer.dataState.dataSourceNeedUpdate = true;
return;
}
diff --git a/packages/layers/src/wind/index.ts b/packages/layers/src/wind/index.ts
index 4ccab5b618..e715b38558 100644
--- a/packages/layers/src/wind/index.ts
+++ b/packages/layers/src/wind/index.ts
@@ -8,11 +8,15 @@ export default class WindLayer extends BaseLayer {
this.layerModel = new WindModels[modelType](this);
this.layerModel.initModels((models) => {
this.models = models;
- this.renderLayers();
+ this.emit('modelLoaded', null);
+ this.layerService.throttleRenderLayers();
});
}
public rebuildModels() {
- this.layerModel.buildModels((models) => (this.models = models));
+ this.layerModel.buildModels((models) => {
+ this.models = models;
+ this.emit('modelLoaded', null);
+ });
}
public renderModels() {
diff --git a/packages/layers/src/wind/models/wind.ts b/packages/layers/src/wind/models/wind.ts
index 5e829f69d7..e1a9522b2f 100644
--- a/packages/layers/src/wind/models/wind.ts
+++ b/packages/layers/src/wind/models/wind.ts
@@ -7,7 +7,7 @@ import {
ITexture2D,
Point,
} from '@antv/l7-core';
-import { FrequencyController } from '@antv/l7-utils';
+import { FrequencyController, getMask } from '@antv/l7-utils';
import BaseModel from '../../core/BaseModel';
import { IWindLayerStyleOptions } from '../../core/interface';
import { RasterImageTriangulation } from '../../core/triangulation';
@@ -110,8 +110,7 @@ export default class WindModel extends BaseModel {
height: imageHeight,
});
- this.layerService.updateLayerRenderList();
- this.layerService.renderLayers();
+ this.layerService.reRender();
});
this.layer
@@ -122,7 +121,9 @@ export default class WindModel extends BaseModel {
triangulation: RasterImageTriangulation,
primitive: gl.TRIANGLES,
depth: { enable: false },
+ stencil: getMask(mask, maskInside),
blend: this.getBlend(),
+ pick: false,
})
.then((model) => {
this.colorModel = model;
@@ -188,7 +189,6 @@ export default class WindModel extends BaseModel {
feature: IEncodeFeature,
featureIdx: number,
vertex: number[],
- attributeIdx: number,
) => {
return [vertex[3], vertex[4]];
},
@@ -241,7 +241,7 @@ export default class WindModel extends BaseModel {
this.wind.dropRateBump = dropRateBump;
const { d, w, h } = this.wind.draw();
- // TODO: 恢复 L7 渲染流程中 gl 状态
+ // 恢复 L7 渲染流程中 gl 状态
this.rendererService.setBaseState();
this.texture.update({
data: d,
diff --git a/packages/layers/src/wind/shaders/wind_vert.glsl b/packages/layers/src/wind/shaders/wind_vert.glsl
index fd96cd725c..46822f69ef 100644
--- a/packages/layers/src/wind/shaders/wind_vert.glsl
+++ b/packages/layers/src/wind/shaders/wind_vert.glsl
@@ -8,7 +8,7 @@ varying vec2 v_texCoord;
void main() {
v_texCoord = a_Uv;
vec4 project_pos = project_position(vec4(a_Position, 1.0));
- // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy,0., 1.0));
+
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x
gl_Position = u_Mvp * (vec4(project_pos.xy,0., 1.0));
} else {
diff --git a/packages/map/src/geo/transform.ts b/packages/map/src/geo/transform.ts
index 3211b5e3c2..4e9f805e67 100644
--- a/packages/map/src/geo/transform.ts
+++ b/packages/map/src/geo/transform.ts
@@ -944,7 +944,7 @@ export default class Transform {
const nearZ = this.height / 50;
// matrix for conversion from location to GL coordinates (-1 .. 1)
- // TODO: 使用 Float64Array 的原因是为了避免计算精度问题、 mat4.create() 默认使用 Float32Array
+ // 使用 Float64Array 的原因是为了避免计算精度问题、 mat4.create() 默认使用 Float32Array
let m = new Float64Array(16);
// @ts-ignore
mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);
diff --git a/packages/map/src/map.ts b/packages/map/src/map.ts
index f2547ae455..b9454b1d3c 100644
--- a/packages/map/src/map.ts
+++ b/packages/map/src/map.ts
@@ -121,7 +121,7 @@ export class Map extends Camera {
public resize(eventData?: any) {
const [width, height] = this.containerDimensions();
this.transform.resize(width, height);
- // TODO: 小程序环境不需要执行后续动作
+ // 小程序环境不需要执行后续动作
if (isMini) {
return this;
}
diff --git a/packages/maps/src/amap/map.ts b/packages/maps/src/amap/map.ts
index 7d81f40055..d97f91a719 100644
--- a/packages/maps/src/amap/map.ts
+++ b/packages/maps/src/amap/map.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* AMapService
*/
@@ -102,7 +103,7 @@ export default class AMapService extends AMapBaseService
...rest,
};
if (mapConstructorOptions.zoom) {
- // TODO: 高德地图在相同大小下需要比 MapBox 多一个 zoom 层级
+ // 高德地图在相同大小下需要比 MapBox 多一个 zoom 层级
mapConstructorOptions.zoom += 1;
}
// @ts-ignore
diff --git a/packages/maps/src/amap2/map.ts b/packages/maps/src/amap2/map.ts
index 8185101af2..85f6962dcd 100644
--- a/packages/maps/src/amap2/map.ts
+++ b/packages/maps/src/amap2/map.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* AMapService
*/
@@ -136,12 +137,13 @@ export default class AMapService extends AMapBaseService {
const amap = mapContainer.getElementsByClassName(
'amap-maps',
)[0] as HTMLElement;
- // TODO: amap2 的 amap-maps 新增 z-index=0; 样式,让 marker 中 zIndex 失效
+ // amap2 的 amap-maps 新增 z-index=0; 样式,让 marker 中 zIndex 失效
amap.style.zIndex = 'auto';
this.markerContainer = DOM.create('div', 'l7-marker-container2', amap);
}
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public updateView(_viewOption: Partial): void {}
public getOverlayContainer(): HTMLElement | undefined {
@@ -274,7 +276,7 @@ export default class AMapService extends AMapBaseService {
...rest,
};
if (mapConstructorOptions.zoom) {
- // TODO: 高德地图在相同大小下需要比 MapBox 多一个 zoom 层级
+ // 高德地图在相同大小下需要比 MapBox 多一个 zoom 层级
mapConstructorOptions.zoom += 1;
}
// @ts-ignore
diff --git a/packages/maps/src/earth/Viewport.ts b/packages/maps/src/earth/Viewport.ts
index 8d4cff7e42..7a92bf9f1d 100644
--- a/packages/maps/src/earth/Viewport.ts
+++ b/packages/maps/src/earth/Viewport.ts
@@ -8,7 +8,7 @@ export interface IEarthCamera {
}
export default class Viewport implements IViewport {
- // TODO: 初始化相机的姿态 看向地球
+ // 初始化相机的姿态 看向地球
private xzReg: number = -Math.PI * 0.6;
private yReg: number = Math.PI * 0.2;
// 默认的地球相机半径、地球相机缩放层级
diff --git a/packages/maps/src/earth/map.ts b/packages/maps/src/earth/map.ts
index 2797b201f2..dd4e15d878 100644
--- a/packages/maps/src/earth/map.ts
+++ b/packages/maps/src/earth/map.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* MapboxService
*/
@@ -105,7 +106,7 @@ export default class L7EarthService extends BaseMapService