ol 10.6.2-dev.1754987594258 → 10.6.2-dev.1755096180018
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ol.d.ts +4 -2
- package/dist/ol.d.ts.map +1 -1
- package/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/package.json +1 -1
- package/render/webgl/ShaderBuilder.d.ts +1 -1
- package/render/webgl/ShaderBuilder.d.ts.map +1 -1
- package/render/webgl/ShaderBuilder.js +9 -6
- package/render/webgl/VectorStyleRenderer.js +3 -3
- package/render/webgl/compileUtil.d.ts +12 -1
- package/render/webgl/compileUtil.d.ts.map +1 -1
- package/render/webgl/compileUtil.js +23 -5
- package/render/webgl/encodeUtil.d.ts +4 -4
- package/render/webgl/encodeUtil.d.ts.map +1 -1
- package/render/webgl/encodeUtil.js +10 -8
- package/renderer/webgl/PointsLayer.d.ts.map +1 -1
- package/renderer/webgl/PointsLayer.js +7 -6
- package/util.js +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n";
|
|
1
|
+
export const COMMON_HEADER: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n\nvec4 unpackColor(vec2 packedColor) {\n return vec4(\n min(floor(packedColor[0] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[0], 256.0) / 255.0, 1.0),\n min(floor(packedColor[1] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[1], 256.0) / 255.0, 1.0)\n );\n}\n";
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} AttributeDescription
|
|
4
4
|
* @property {string} name Attribute name, as will be declared in the header of the vertex shader (including a_)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShaderBuilder.d.ts","sourceRoot":"","sources":["ShaderBuilder.js"],"names":[],"mappings":"AASA,s7BAwBE;AAIF;;;;;;;GAOG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH;IAEI;;;;OAIG;IACH,kBAAmB;IAEnB;;;;OAIG;IACH,oBAAqB;IAErB;;;OAGG;IACH,mBAAuB;IAEvB;;;OAGG;IACH,8BAEkE;IAElE;;;OAGG;IACH,kCAAsC;IAEtC;;;OAGG;IACH,gCAA0C;IAE1C;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,4BAAqD;IAErD;;;OAGG;IACH,2BAAiC;IAEjC;;;OAGG;IACH,8BAAkC;IAElC;;;OAGG;IACH,mBAAuB;IAEvB;;;OAGG;IACH,+BAAyE;IAEzE;;;OAGG;IACH,+BAEC;IAED;;OAEG;I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M,GACL,aAAa,CAKxB;IAED;;;OAGG;IACH,mCAHW,MAAM,GACL,aAAa,CAKxB;IAED;;;OAGG;IACH,oCAHW,MAAM,GACL,aAAa,CAKxB;IAED;;;OAGG;IACH,0CAHW,MAAM,GACL,aAAa,CAKxB;IAED;;;;OAIG;IACH,6CAJW,MAAM,GAEL,aAAa,CAKxB;IAED;;;;;;;;OAQG;IACH,6CAJW,MAAM,GAEL,aAAa,CAKxB;IAED;;OAEG;IACH,oCAFY,MAAM,CAIjB;IAED;;;OAGG;IACH,mCAHW,MAAM,GACL,aAAa,CAMxB;IAED;;OAEG;IACH,0BAFY,MAAM,CAIjB;IAED,yCAMC;IACD,2CAMC;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CAgEtB;IAED;;;OAGG;IACH,2BAFY,MAAM,GAAC,IAAI,CAwCtB;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CA8HtB;IAED;;;;OAIG;IACH,2BAFY,MAAM,GAAC,IAAI,CA4KtB;IAED;;;;OAIG;IACH,uBAFY,MAAM,GAAC,IAAI,CA+BtB;IAED;;;OAGG;IACH,yBAFY,MAAM,GAAC,IAAI,CAyDtB;CACF;;;;;UA38Ba,MAAM;;;;UACN,MAAM;;;;iBACN,MAAM;;;;iBACN,MAAM;;;;uBACN,MAAM;;;;;;UAKN,MAAM;;;;UACN,MAAM"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import {colorToGlsl, numberToGlsl, stringToGlsl} from '../../expr/gpu.js';
|
|
6
6
|
import {createDefaultStyle} from '../../style/flat.js';
|
|
7
7
|
import {LINESTRING_ANGLE_COSINE_CUTOFF} from './bufferUtil.js';
|
|
8
|
+
import {UNPACK_COLOR_FN} from './compileUtil.js';
|
|
8
9
|
|
|
9
10
|
export const COMMON_HEADER = `#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
10
11
|
precision highp float;
|
|
@@ -28,6 +29,8 @@ uniform mediump int u_hitDetection;
|
|
|
28
29
|
const float PI = 3.141592653589793238;
|
|
29
30
|
const float TWO_PI = 2.0 * PI;
|
|
30
31
|
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
|
32
|
+
|
|
33
|
+
${UNPACK_COLOR_FN}
|
|
31
34
|
`;
|
|
32
35
|
|
|
33
36
|
const DEFAULT_STYLE = createDefaultStyle();
|
|
@@ -503,7 +506,7 @@ export class ShaderBuilder {
|
|
|
503
506
|
${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
|
|
504
507
|
attribute vec2 a_position;
|
|
505
508
|
attribute vec2 a_localPosition;
|
|
506
|
-
attribute
|
|
509
|
+
attribute vec2 a_hitColor;
|
|
507
510
|
|
|
508
511
|
varying vec2 v_texCoord;
|
|
509
512
|
varying vec2 v_quadCoord;
|
|
@@ -543,7 +546,7 @@ void main(void) {
|
|
|
543
546
|
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
|
|
544
547
|
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
|
|
545
548
|
v_texCoord = vec2(u, v);
|
|
546
|
-
v_hitColor = a_hitColor;
|
|
549
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
547
550
|
v_angle = angle;
|
|
548
551
|
c = cos(-v_angle);
|
|
549
552
|
s = sin(-v_angle);
|
|
@@ -622,7 +625,7 @@ attribute float a_angleTangentSum;
|
|
|
622
625
|
attribute float a_distanceLow;
|
|
623
626
|
attribute float a_distanceHigh;
|
|
624
627
|
attribute vec2 a_joinAngles;
|
|
625
|
-
attribute
|
|
628
|
+
attribute vec2 a_hitColor;
|
|
626
629
|
|
|
627
630
|
varying vec2 v_segmentStartPx;
|
|
628
631
|
varying vec2 v_segmentEndPx;
|
|
@@ -709,7 +712,7 @@ void main(void) {
|
|
|
709
712
|
v_segmentStartPx = segmentStartPx;
|
|
710
713
|
v_segmentEndPx = segmentEndPx;
|
|
711
714
|
v_width = lineWidth;
|
|
712
|
-
v_hitColor = a_hitColor;
|
|
715
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
713
716
|
|
|
714
717
|
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
|
|
715
718
|
float distanceHighPx = a_distanceHigh / u_resolution;
|
|
@@ -922,7 +925,7 @@ ${this.attributes_
|
|
|
922
925
|
return `${COMMON_HEADER}
|
|
923
926
|
${this.uniforms_.map((uniform) => `uniform ${uniform.type} ${uniform.name};`).join('\n')}
|
|
924
927
|
attribute vec2 a_position;
|
|
925
|
-
attribute
|
|
928
|
+
attribute vec2 a_hitColor;
|
|
926
929
|
|
|
927
930
|
varying vec4 v_hitColor;
|
|
928
931
|
|
|
@@ -935,7 +938,7 @@ varying ${attribute.varyingType} ${attribute.varyingName};`,
|
|
|
935
938
|
${this.vertexShaderFunctions_.join('\n')}
|
|
936
939
|
void main(void) {
|
|
937
940
|
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
|
|
938
|
-
v_hitColor = a_hitColor;
|
|
941
|
+
v_hitColor = unpackColor(a_hitColor);
|
|
939
942
|
${this.attributes_
|
|
940
943
|
.map(
|
|
941
944
|
(attribute) =>
|
|
@@ -10,7 +10,7 @@ import {AttributeType} from '../../webgl/Helper.js';
|
|
|
10
10
|
import {ARRAY_BUFFER, DYNAMIC_DRAW, ELEMENT_ARRAY_BUFFER} from '../../webgl.js';
|
|
11
11
|
import {create as createWebGLWorker} from '../../worker/webgl.js';
|
|
12
12
|
import {WebGLWorkerMessageType} from './constants.js';
|
|
13
|
-
import {
|
|
13
|
+
import {colorEncodeIdAndPack} from './encodeUtil.js';
|
|
14
14
|
import {
|
|
15
15
|
generateLineStringRenderInstructions,
|
|
16
16
|
generatePointRenderInstructions,
|
|
@@ -170,9 +170,9 @@ class VectorStyleRenderer {
|
|
|
170
170
|
if (this.hitDetectionEnabled_) {
|
|
171
171
|
this.customAttributes_['hitColor'] = {
|
|
172
172
|
callback() {
|
|
173
|
-
return
|
|
173
|
+
return colorEncodeIdAndPack(this.ref, tmpColor);
|
|
174
174
|
},
|
|
175
|
-
size:
|
|
175
|
+
size: 2,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
|
|
@@ -13,6 +13,13 @@ export function expressionToGlsl(compilationContext: import("../../expr/gpu.js")
|
|
|
13
13
|
* @return {Array<number>} Vec2 array containing the color in compressed form
|
|
14
14
|
*/
|
|
15
15
|
export function packColor(color: import("../../color.js").Color | string): Array<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Unpacks a color from a packed color in two-floats array form
|
|
18
|
+
* NOTE: this is only used for testing purposes
|
|
19
|
+
* @param {Array<number>} packedColor Packed color generated by the `packColor` function
|
|
20
|
+
* @return {Array<number>} Resulting unpacked color in array form with components in the range [0, 1]
|
|
21
|
+
*/
|
|
22
|
+
export function unpackColor(packedColor: Array<number>): Array<number>;
|
|
16
23
|
/**
|
|
17
24
|
* @param {number} type Value type
|
|
18
25
|
* @return {1|2|3|4} The amount of components for this value
|
|
@@ -47,5 +54,9 @@ export function generateUniformsFromContext(context: import("../../expr/gpu.js")
|
|
|
47
54
|
* @return {import('./VectorStyleRenderer.js').AttributeDefinitions} Attributes
|
|
48
55
|
*/
|
|
49
56
|
export function generateAttributesFromContext(context: import("../../expr/gpu.js").CompilationContext): import("./VectorStyleRenderer.js").AttributeDefinitions;
|
|
50
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Equivalent of `unpackColor()` in GLSL
|
|
59
|
+
* @type {string}
|
|
60
|
+
*/
|
|
61
|
+
export const UNPACK_COLOR_FN: string;
|
|
51
62
|
//# sourceMappingURL=compileUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileUtil.d.ts","sourceRoot":"","sources":["compileUtil.js"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,qDALW,OAAO,mBAAmB,EAAE,kBAAkB,SAC9C,OAAO,0BAA0B,EAAE,iBAAiB,iBACpD,MAAM,GACL,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,KAAK,CAAC,MAAM,CAAC,CASxB;
|
|
1
|
+
{"version":3,"file":"compileUtil.d.ts","sourceRoot":"","sources":["compileUtil.js"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,qDALW,OAAO,mBAAmB,EAAE,kBAAkB,SAC9C,OAAO,0BAA0B,EAAE,iBAAiB,iBACpD,MAAM,GACL,MAAM,CAUjB;AAED;;;;GAIG;AACH,iCAHW,OAAO,gBAAgB,EAAE,KAAK,GAAC,MAAM,GACpC,KAAK,CAAC,MAAM,CAAC,CASxB;AAED;;;;;GAKG;AACH,yCAHW,KAAK,CAAC,MAAM,CAAC,GACZ,KAAK,CAAC,MAAM,CAAC,CASxB;AAeD;;;GAGG;AACH,0CAHW,MAAM,GACL,CAAC,GAAC,CAAC,GAAC,CAAC,GAAC,CAAC,CAUlB;AAED;;;GAGG;AACH,0CAHW,MAAM,GACL,OAAO,GAAC,MAAM,GAAC,MAAM,GAAC,MAAM,CAQvC;AAED;;;;;GAKG;AACH,+CAHW,OAAO,oBAAoB,EAAE,aAAa,WAC1C,OAAO,mBAAmB,EAAE,kBAAkB,QAsCxD;AAED;;;;;;GAMG;AACH,qDAJW,OAAO,mBAAmB,EAAE,kBAAkB,cAC9C,OAAO,qBAAqB,EAAE,cAAc;;EAoCtD;AAED;;;;;GAKG;AACH,uDAHW,OAAO,mBAAmB,EAAE,kBAAkB,GAC7C,OAAO,0BAA0B,EAAE,oBAAoB,CA+BlE;AAhKD;;;GAGG;AACH,8BAFU,MAAM,CASb"}
|
|
@@ -48,12 +48,31 @@ export function packColor(color) {
|
|
|
48
48
|
return [r + g, b + a];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Unpacks a color from a packed color in two-floats array form
|
|
53
|
+
* NOTE: this is only used for testing purposes
|
|
54
|
+
* @param {Array<number>} packedColor Packed color generated by the `packColor` function
|
|
55
|
+
* @return {Array<number>} Resulting unpacked color in array form with components in the range [0, 1]
|
|
56
|
+
*/
|
|
57
|
+
export function unpackColor(packedColor) {
|
|
58
|
+
return [
|
|
59
|
+
Math.min(Math.floor(packedColor[0] / 256.0) / 255.0, 1),
|
|
60
|
+
Math.min((packedColor[0] % 256.0) / 255.0, 1),
|
|
61
|
+
Math.min(Math.floor(packedColor[1] / 256.0) / 255.0, 1),
|
|
62
|
+
Math.min((packedColor[1] % 256.0) / 255.0, 1),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Equivalent of `unpackColor()` in GLSL
|
|
68
|
+
* @type {string}
|
|
69
|
+
*/
|
|
51
70
|
export const UNPACK_COLOR_FN = `vec4 unpackColor(vec2 packedColor) {
|
|
52
71
|
return vec4(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
|
73
|
+
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
|
74
|
+
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
|
75
|
+
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
|
57
76
|
);
|
|
58
77
|
}`;
|
|
59
78
|
|
|
@@ -115,7 +134,6 @@ export function applyContextToBuilder(builder, context) {
|
|
|
115
134
|
`unpackColor(${attributeName})`,
|
|
116
135
|
'vec4',
|
|
117
136
|
);
|
|
118
|
-
builder.addVertexShaderFunction(UNPACK_COLOR_FN);
|
|
119
137
|
} else {
|
|
120
138
|
builder.addAttribute(attributeName, glslType);
|
|
121
139
|
}
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* @module ol/render/webgl/encodeUtil
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Generates a color array based on a numerical id
|
|
6
|
+
* Generates a color array based on a numerical id, and pack it just like the `packColor` function of 'ol/render/webgl/compileUtil.js'.
|
|
7
7
|
* Note: the range for each component is 0 to 1 with 256 steps
|
|
8
8
|
* @param {number} id Id
|
|
9
9
|
* @param {Array<number>} [array] Reusable array
|
|
10
|
-
* @return {Array<number>}
|
|
10
|
+
* @return {Array<number>} Packed color array with two components
|
|
11
11
|
*/
|
|
12
|
-
export function
|
|
12
|
+
export function colorEncodeIdAndPack(id: number, array?: Array<number>): Array<number>;
|
|
13
13
|
/**
|
|
14
14
|
* Reads an id from a color-encoded array
|
|
15
15
|
* Note: the expected range for each component is 0 to 1 with 256 steps.
|
|
16
|
-
* @param {Array<number>} color Color array containing the encoded id
|
|
16
|
+
* @param {Array<number>} color Color array containing the encoded id; color components are in the range 0 to 1
|
|
17
17
|
* @return {number} Decoded id
|
|
18
18
|
*/
|
|
19
19
|
export function colorDecodeId(color: Array<number>): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encodeUtil.d.ts","sourceRoot":"","sources":["encodeUtil.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"encodeUtil.d.ts","sourceRoot":"","sources":["encodeUtil.js"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,yCAJW,MAAM,UACN,KAAK,CAAC,MAAM,CAAC,GACZ,KAAK,CAAC,MAAM,CAAC,CAaxB;AAED;;;;;GAKG;AACH,qCAHW,KAAK,CAAC,MAAM,CAAC,GACZ,MAAM,CAWjB"}
|
|
@@ -4,27 +4,29 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Generates a color array based on a numerical id
|
|
7
|
+
* Generates a color array based on a numerical id, and pack it just like the `packColor` function of 'ol/render/webgl/compileUtil.js'.
|
|
8
8
|
* Note: the range for each component is 0 to 1 with 256 steps
|
|
9
9
|
* @param {number} id Id
|
|
10
10
|
* @param {Array<number>} [array] Reusable array
|
|
11
|
-
* @return {Array<number>}
|
|
11
|
+
* @return {Array<number>} Packed color array with two components
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function colorEncodeIdAndPack(id, array) {
|
|
14
14
|
array = array || [];
|
|
15
15
|
const radix = 256;
|
|
16
16
|
const divide = radix - 1;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const r = Math.floor(id / radix / radix / radix) / divide;
|
|
18
|
+
const g = (Math.floor(id / radix / radix) % radix) / divide;
|
|
19
|
+
const b = (Math.floor(id / radix) % radix) / divide;
|
|
20
|
+
const a = (id % radix) / divide;
|
|
21
|
+
array[0] = r * 256 * 255 + g * 255;
|
|
22
|
+
array[1] = b * 256 * 255 + a * 255;
|
|
21
23
|
return array;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Reads an id from a color-encoded array
|
|
26
28
|
* Note: the expected range for each component is 0 to 1 with 256 steps.
|
|
27
|
-
* @param {Array<number>} color Color array containing the encoded id
|
|
29
|
+
* @param {Array<number>} color Color array containing the encoded id; color components are in the range 0 to 1
|
|
28
30
|
* @return {number} Decoded id
|
|
29
31
|
*/
|
|
30
32
|
export function colorDecodeId(color) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PointsLayer.d.ts","sourceRoot":"","sources":["PointsLayer.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PointsLayer.d.ts","sourceRoot":"","sources":["PointsLayer.js"],"names":[],"mappings":";oBA+Bc,OAAO,qBAAqB,EAAE,OAAO;2BACrC,OAAO,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC;;;;;;;;;UAKtC,MAAM;;;;;cACN,CAAS,IAAY,EAAZ,YAAY,EAAE,IAAiB,EAAjB;YAAO,MAAM,GAAE,GAAC;KAAC,KAAE,MAAM;;;;;;;;;;aAOhD,YAAY;;;;;;;;;;qBAEZ,OAAO,qBAAqB,EAAE,UAAU;;;;;;;;;;;;;;;;;;kBAWxC,MAAM;;;;oBACN,MAAM;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Ac,EAAE,UAAU,mBACjC,OAAO,cACP,MAAM,YACN,MAAM,cACN,MAAM,QAyChB;IAeD,wBAAoB;CACrB;+BA/rB8B,YAAY"}
|
|
@@ -8,7 +8,10 @@ import {buffer, createEmpty, equals} from '../../extent.js';
|
|
|
8
8
|
import BaseVector from '../../layer/BaseVector.js';
|
|
9
9
|
import {fromUserCoordinate, getUserProjection} from '../../proj.js';
|
|
10
10
|
import {WebGLWorkerMessageType} from '../../render/webgl/constants.js';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
colorDecodeId,
|
|
13
|
+
colorEncodeIdAndPack,
|
|
14
|
+
} from '../../render/webgl/encodeUtil.js';
|
|
12
15
|
import VectorEventType from '../../source/VectorEventType.js';
|
|
13
16
|
import {
|
|
14
17
|
apply as applyTransform,
|
|
@@ -221,7 +224,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
221
224
|
if (this.hitDetectionEnabled_) {
|
|
222
225
|
this.instanceAttributes.push({
|
|
223
226
|
name: 'a_hitColor',
|
|
224
|
-
size:
|
|
227
|
+
size: 2,
|
|
225
228
|
type: AttributeType.FLOAT,
|
|
226
229
|
});
|
|
227
230
|
this.instanceAttributes.push({
|
|
@@ -554,7 +557,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
554
557
|
|
|
555
558
|
const userProjection = getUserProjection();
|
|
556
559
|
|
|
557
|
-
const baseInstructionLength = this.hitDetectionEnabled_ ?
|
|
560
|
+
const baseInstructionLength = this.hitDetectionEnabled_ ? 5 : 2; // see below
|
|
558
561
|
const singleInstructionLength =
|
|
559
562
|
baseInstructionLength + this.customAttributes.length;
|
|
560
563
|
const totalSize = singleInstructionLength * this.featureCount_;
|
|
@@ -590,11 +593,9 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|
|
590
593
|
// for hit detection, the feature uid is saved in the opacity value
|
|
591
594
|
// and the index of the opacity value is encoded in the color values
|
|
592
595
|
if (this.hitDetectionEnabled_) {
|
|
593
|
-
const hitColor =
|
|
596
|
+
const hitColor = colorEncodeIdAndPack(idx + 3, tmpColor);
|
|
594
597
|
renderInstructions[++idx] = hitColor[0];
|
|
595
598
|
renderInstructions[++idx] = hitColor[1];
|
|
596
|
-
renderInstructions[++idx] = hitColor[2];
|
|
597
|
-
renderInstructions[++idx] = hitColor[3];
|
|
598
599
|
renderInstructions[++idx] = Number(featureUid);
|
|
599
600
|
}
|
|
600
601
|
|
package/util.js
CHANGED