antv-l7/stories/layerbuild/components/Plane.tsx

109 lines
2.8 KiB
TypeScript
Raw Normal View History

feat: 渲染流程异步改造、部分支持 worker (#1224) * feat: 去处事件节流 * feat: 创建图层流程改造 + worker 功能验证 * style: lint style * feat: 修改 worker 引入 * feat: 调整 worker 的拼接 * style: lint style * feat: 修改 source 构建流程为异步 * style: lint style * feat: 在点图层中去除 global 的耦合 * style: lint style * fix: 修复更新 style 的同时更新了 option 带来的问题 * style: lint style * feat: 拆除 arc3d 地球模式和普通模式的耦合 * style: lint style * feat: 修改 worker * style: lint style * feat: 优化图层创建渲染流程 * style: lint style * Merge branch 'workspace' into tileDemo * style: style lint * feat: 改在点图层的创建流程 * style: lint style * style: lint style * chore: worker helper (#1241) * chore: worker helper * chore: 修改注册流程 * chore: 修改打包方式 * chore: 集成打包环境 * style: lint style * feat: add worker pool failed * style: lint style * style: lint style * feat: 更新 worker 的使用 * chore: 更新 scripts 标签 (#1242) * feat: remove utils triangulation * feat: 完成 pointLayer/earthLayer 的异步改造 * style: lint style * style: lint style * style: lint style * chore: 修改 worker 执行函数 (#1246) * chore: 修改 worker 执行函数 * chore: remove console * feat: 完成线图层和线图层的异步创建流程改造 * style: lint style * style: lint style * feat: 完成 polygon 创建流程的异步改造 * style: lint style * feat: 完成 heatmap 创建流程的异步改造 * style: lint style * feat: 完成 citybuildingLayer 图层创建的异步改造 * style: lint style * feat: 完成 imageLayer 创建异步改造 * style: lint style * feat: 完成 ImageLayer/RasterLayer 创建的异步改造 * style: lint style * feat: 完成 geometryLayer 创建的异步改造 * style: lint style * feat: 完成 WindLayer 创建的异步改造 * style: lint style * feat: 完成 tileLayer 瓦片图层创建图层的异步改造 * style: lint style * feat: 调整 worker 调用的参数和 worker 代码的位置 * style: lint style * chore: 调整 worker 代码结构 * style: lint style * feat: 梳理完善 layer 的 modelName * style: lint style * chore: 调整部分 modeName 的命名 * feat: 线图层的 lineModel 支持 worker 计算 * style: lint style * feat: 完善 source 异步改造,增加测试 * style: lint style * feat: 支持 polygonFill 的 worker 计算 * style: lint style * feat: tile point/line/polygon 支持 worker 计算 * style: lint style * chore: 调整 worker 目录结构 * style: lint style * chore: 修改 worker 打包路径 * feat: 增加 ISrource 时间的类型定义 * chore: change function getPureDescriptors -> getDescriptorsWithOutFunc * feat: 完善类型定义,去除额外 worker 代码 * chore: worker 注册放到 utils 里面 (#1253) * chore: 代码清理 * style: lint style * fix: 修复 encodeData 可能的空值 * feat: 地球模式的点、线图层兼容写法 * style: lint style * feat: 完成对 dataImage 的异步改造 * fix: 修复 demo 中对时序数据的使用 * style: lint style * fix: 修复点图层文字重新布局未重绘问题 * fix: 修复 pointLayer fillImage 失效 * style: lint style * chore: 在官网 demo 中去除 multipass * chore: 调整官网 demo 效果 * style: lint style * chore: 调整官网 demo * style: lint style * fix: 修复 layerModel 使用的报错 * chore: update l7plot version Co-authored-by: lvisei <yunji.me@outlook.com>
2022-08-02 19:05:27 +08:00
// @ts-nocheck
// @ts-ignore
import { Scene, Source } from '@antv/l7';
import { GeometryLayer } 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() {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [120.1025, 30.2594],
style: 'dark',
pitch: 65,
rotation: 180,
zoom: 14,
}),
});
let currentZoom = 14,
currentModelData = '100x100';
scene.on('loaded', () => {
const layer = new GeometryLayer().shape('plane').style({
width: 0.074,
height: 0.061,
center: [120.1025, 30.2594],
widthSegments: 100,
heightSegments: 100,
terrainClipHeight: 1,
mapTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*gA0NRbuOF5cAAAAAAAAAAAAAARQnAQ',
terrainTexture:
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*eYFaRYlnnOUAAAAAAAAAAAAAARQnAQ',
rgb2height: (r, g, b) => {
let h =
-10000.0 +
(r * 255.0 * 256.0 * 256.0 + g * 255.0 * 256.0 + b * 255.0) * 0.1;
h = h / 20 - 127600;
h = Math.max(0, h);
return h;
},
});
scene.addLayer(layer);
let modelData10,
modelData20 = null,
modelData100;
layer.on('terrainImageLoaded', () => {
modelData10 = layer.createModelData([], {
widthSegments: 10,
heightSegments: 10,
});
modelData20 = layer.createModelData([], {
widthSegments: 20,
heightSegments: 20,
});
modelData100 = layer.createModelData([], {
widthSegments: 100,
heightSegments: 100,
});
});
scene.on('zoom', ({ value }) => {
const zoom = Math.floor(value);
if (currentZoom !== zoom) {
if (zoom > 13) {
if (currentModelData !== '100x100') {
layer.updateModelData(modelData100);
currentModelData = '100x100';
}
} else if (zoom > 12) {
if (currentModelData !== '20x20') {
layer.updateModelData(modelData20);
currentModelData = '20x20';
}
} else {
if (currentModelData !== '10x10') {
layer.updateModelData(modelData10);
currentModelData = '10x10';
}
}
currentZoom = zoom;
}
return '';
});
});
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
></div>
);
}
}