This commit is contained in:
2912401452 2022-02-17 18:00:43 +08:00
commit 8570259f72
5 changed files with 40 additions and 33 deletions

View File

@ -1,7 +1,7 @@
import { $window, isMini } from '@antv/l7-utils';
import EventEmitter from 'eventemitter3';
import { inject, injectable } from 'inversify';
import Hammer from 'l7hammerjs'; // l7 - mini
import Hammer from 'l7hammerjs';
import 'reflect-metadata';
// @ts-ignore
import { TYPES } from '../../types';

View File

@ -18,14 +18,16 @@ uniform float u_activeMix: 0;
* Returns highlight color if this item is selected.
*/
vec4 filterHighlightColor(vec4 color, float weight) {
float selected = v_PickingResult.a;
// float selected = v_PickingResult.a;
bool selected = bool(v_PickingResult.a);
if (selected == SELECT) {
// 点击选中状态
vec4 selectColor = u_SelectColor * COLOR_SCALE;
return selectColor;
} else if (selected == HIGHLIGHT) {
// hover 高亮状态
// if (selected == SELECT) {
if (selected) {
// // 点击选中状态
// vec4 selectColor = u_SelectColor * COLOR_SCALE;
// return selectColor;
// } else if (selected == HIGHLIGHT) {
// // hover 高亮状态
vec4 highLightColor = u_HighlightColor * COLOR_SCALE;
float highLightAlpha = highLightColor.a;

View File

@ -40,15 +40,18 @@ void setPickingColor(vec3 pickingColor) {
return;
}
// compares only in highlight stage
if (u_EnableSelect == 1.0 && u_PickingStage == PICKING_HIGHLIGHT && isVertexSelected(pickingColor)) {
// 选中态
v_PickingResult.a = SELECT;
} else if (u_PickingStage == PICKING_HIGHLIGHT && isVertexPicked(pickingColor)) {
// 高亮态
v_PickingResult.a = HIGHLIGHT;
} else {
v_PickingResult.a = NORMAL;
}
v_PickingResult.a = float((u_PickingStage == PICKING_HIGHLIGHT) && isVertexPicked(pickingColor));
// if (u_EnableSelect == 1.0 && u_PickingStage == PICKING_HIGHLIGHT && isVertexSelected(pickingColor)) {
// // 选中态
// v_PickingResult.a = SELECT;
// } else if (u_PickingStage == PICKING_HIGHLIGHT && isVertexPicked(pickingColor)) {
// // 高亮态
// v_PickingResult.a = HIGHLIGHT;
// } else {
// v_PickingResult.a = NORMAL;
// }
// Stores the picking color so that the fragment shader can render it during picking
v_PickingResult.rgb = pickingColor * COLOR_SCALE;

View File

@ -84,36 +84,37 @@ export default class PixelPickingPlugin implements ILayerPlugin {
layer.hooks.beforeHighlight.tap(
'PixelPickingPlugin',
(pickedColor: number[]) => {
const {
highlightColor,
activeMix = 0,
enableSelect,
} = layer.getLayerConfig();
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];
// 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();
// 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),
// u_CurrentSelectedId: currentSelectedId
// ? encodePickingColor(layer.getCurrentSelectedId()!)
// : [0, 0, 0],
// u_SelectColor: selectColorInArray.map((c) => c * 255),
// u_EnableSelect: +(enableSelect || false),
}),
);
},

View File

@ -122,6 +122,7 @@ export default class GaodeMapComponent extends React.Component {
// // type: 'www'
// })
// .animate(true)
.select(true)
.active({ color: '#00f' })
.style({
heightfixed: true,