-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Description
I'm having some trouble with extra events firing so I was digging into how options are passed in, and I found this code in deck.ts:
this.eventManager = new EventManager(this.props.parent || this.canvas, {
touchAction: this.props.touchAction,
recognizers: Object.keys(RECOGNIZERS).map((eventName: string) => {
// Resolve recognizer settings
const [RecognizerConstructor, defaultOptions, recognizeWith, requestFailure] =
RECOGNIZERS[eventName];
const optionsOverride = this.props.eventRecognizerOptions?.[eventName];
const options = {...defaultOptions, ...optionsOverride, event: eventName};
return {
recognizer: new RecognizerConstructor(options),
recognizeWith,
requestFailure // <===== This line right here
};
}),
events: {
pointerdown: this._onPointerDown,
pointermove: this._onPointerMove,
pointerleave: this._onPointerMove
}
});
I think that requestFailure
should be requireFailure
based on the type defined in event-manager.ts:
type RecognizerConstructor = {new (options: any): Recognizer};
type RecognizerTupleNormalized = {
recognizer: Recognizer;
/** Allow another gesture to be recognized simultaneously with this one.
* For example an interaction can trigger pinch and rotate at the same time. */
recognizeWith?: string[];
/** Another recognizer is mutually exclusive with this one.
* For example an interaction could be singletap or doubletap; pan-horizontal or pan-vertical; but never both. */
requireFailure?: string[]; // <========= compared with `requestFailure`
};
export type RecognizerTuple =
| Recognizer
| RecognizerConstructor
| RecognizerTupleNormalized
/** hammer.js/mjolnir.js@2 style */
| [
recognizer: RecognizerConstructor,
options?: any,
/** Allow another gesture to be recognized simultaneously with this one.
* For example an interaction can trigger pinch and rotate at the same time. */
recognizeWith?: string | string[],
/** Another recognizer is mutually exclusive with this one.
* For example an interaction could be singletap or doubletap; pan-horizontal or pan-vertical; but never both. */
requireFailure?: string | string[]
];
Flavors
- Script tag
- React
- Python/Jupyter notebook
- MapboxOverlay
- GoogleMapsOverlay
- CARTO
- ArcGIS
Expected Behavior
No response
Steps to Reproduce
seems like just the code. not even really sure it is causing the behavior i'm seeing (click with tapCount: 1 then click with tapCount: 2; I think it should just be a click with tapCount: 2)
Environment
- Framework version: [email protected], [email protected]
- Browser: Chrome 140
- OS: Windows 11
Logs
No response
EDIT: Some notes...
I changed requestFailure
to requireFailure
in my node_modules and it caused shader errors:
Shader Compilation Error in vertex icon-layer-vertex-shader1: #version 300 es
2:
3: // ----- PROLOGUE -------------------------
4:
5: #define SHADER_TYPE_VERTEX
6:
7: #define INTEL_GPU
8: // Intel optimizes away the calculation necessary for emulated fp64
9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
10: // Intel's built-in 'tan' function doesn't have acceptable precision
11: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
12: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
13: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
14:
15:
16:
17: // ----- APPLICATION DEFINES -------------------------
18:
19:
20:
21: // ----- MODULE geometry ---------------
22:
23: #define MODULE_GEOMETRY
24: #define SMOOTH_EDGE_RADIUS 0.5
25:
26: struct VertexGeometry {
27: vec4 position;
28: vec3 worldPosition;
29: vec3 worldPositionAlt;
30: vec3 normal;
31: vec2 uv;
32: vec3 pickingColor;
33: } geometry = VertexGeometry(
34: vec4(0.0, 0.0, 1.0, 0.0),
35: vec3(0.0),
36: vec3(0.0),
37: vec3(0.0),
38: vec2(0.0),
39: vec3(0.0)
40: );
41:
42: // ----- MODULE fp32 ---------------
43:
44: #define MODULE_FP32
45: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
46:
47: // All these functions are for substituting tan() function from Intel GPU only
48: const float TWO_PI = 6.2831854820251465;
49: const float PI_2 = 1.5707963705062866;
50: const float PI_16 = 0.1963495463132858;
51:
52: const float SIN_TABLE_0 = 0.19509032368659973;
53: const float SIN_TABLE_1 = 0.3826834261417389;
54: const float SIN_TABLE_2 = 0.5555702447891235;
55: const float SIN_TABLE_3 = 0.7071067690849304;
56:
57: const float COS_TABLE_0 = 0.9807852506637573;
58: const float COS_TABLE_1 = 0.9238795042037964;
59: const float COS_TABLE_2 = 0.8314695954322815;
60: const float COS_TABLE_3 = 0.7071067690849304;
61:
62: const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3!
63: const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5!
64: const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
65: const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9!
66:
67: float sin_taylor_fp32(float a) {
68: float r, s, t, x;
69:
70: if (a == 0.0) {
71: return 0.0;
72: }
73:
74: x = -a * a;
75: s = a;
76: r = a;
77:
78: r = r * x;
79: t = r * INVERSE_FACTORIAL_3;
80: s = s + t;
81:
82: r = r * x;
83: t = r * INVERSE_FACTORIAL_5;
84: s = s + t;
85:
86: r = r * x;
87: t = r * INVERSE_FACTORIAL_7;
88: s = s + t;
89:
90: r = r * x;
91: t = r * INVERSE_FACTORIAL_9;
92: s = s + t;
93:
94: return s;
95: }
96:
97: void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {
98: if (a == 0.0) {
99: sin_t = 0.0;
100: cos_t = 1.0;
101: }
102: sin_t = sin_taylor_fp32(a);
103: cos_t = sqrt(1.0 - sin_t * sin_t);
104: }
105:
106: float tan_taylor_fp32(float a) {
107: float sin_a;
108: float cos_a;
109:
110: if (a == 0.0) {
111: return 0.0;
112: }
113:
114: // 2pi range reduction
115: float z = floor(a / TWO_PI);
116: float r = a - TWO_PI * z;
117:
118: float t;
119: float q = floor(r / PI_2 + 0.5);
120: int j = int(q);
121:
122: if (j < -2 || j > 2) {
123: return 1.0 / 0.0;
WARNING: '/' : Divide by zero during constant folding
124: }
125:
126: t = r - PI_2 * q;
127:
128: q = floor(t / PI_16 + 0.5);
129: int k = int(q);
130: int abs_k = int(abs(float(k)));
131:
132: if (abs_k > 4) {
133: return 1.0 / 0.0;
WARNING: '/' : Divide by zero during constant folding
134: } else {
135: t = t - PI_16 * q;
136: }
137:
138: float u = 0.0;
139: float v = 0.0;
140:
141: float sin_t, cos_t;
142: float s, c;
143: sincos_taylor_fp32(t, sin_t, cos_t);
144:
145: if (k == 0) {
146: s = sin_t;
147: c = cos_t;
148: } else {
149: if (abs(float(abs_k) - 1.0) < 0.5) {
150: u = COS_TABLE_0;
151: v = SIN_TABLE_0;
152: } else if (abs(float(abs_k) - 2.0) < 0.5) {
153: u = COS_TABLE_1;
154: v = SIN_TABLE_1;
155: } else if (abs(float(abs_k) - 3.0) < 0.5) {
156: u = COS_TABLE_2;
157: v = SIN_TABLE_2;
158: } else if (abs(float(abs_k) - 4.0) < 0.5) {
159: u = COS_TABLE_3;
160: v = SIN_TABLE_3;
161: }
162: if (k > 0) {
163: s = u * sin_t + v * cos_t;
164: c = u * cos_t - v * sin_t;
165: } else {
166: s = u * sin_t - v * cos_t;
167: c = u * cos_t + v * sin_t;
168: }
169: }
170:
171: if (j == 0) {
172: sin_a = s;
173: cos_a = c;
174: } else if (j == 1) {
175: sin_a = c;
176: cos_a = -s;
177: } else if (j == -1) {
178: sin_a = -c;
179: cos_a = s;
180: } else {
181: sin_a = -s;
182: cos_a = -c;
183: }
184: return sin_a / cos_a;
185: }
186: #endif
187:
188: float tan_fp32(float a) {
189: #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
190: return tan_taylor_fp32(a);
191: #else
192: return tan(a);
193: #endif
194: }
195:
196: // ----- MODULE project ---------------
197:
198: #define MODULE_PROJECT
199: const int COORDINATE_SYSTEM_DEFAULT = -1;const int COORDINATE_SYSTEM_LNGLAT = 1;const int COORDINATE_SYSTEM_METER_OFFSETS = 2;const int COORDINATE_SYSTEM_LNGLAT_OFFSETS = 3;const int COORDINATE_SYSTEM_CARTESIAN = 0;
200: const int PROJECTION_MODE_WEB_MERCATOR = 1;const int PROJECTION_MODE_GLOBE = 2;const int PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET = 4;const int PROJECTION_MODE_IDENTITY = 0;
201: const int UNIT_COMMON = 0;const int UNIT_METERS = 1;const int UNIT_PIXELS = 2;
202: uniform projectUniforms {
203: bool wrapLongitude;
204: int coordinateSystem;
205: vec3 commonUnitsPerMeter;
206: int projectionMode;
207: float scale;
208: vec3 commonUnitsPerWorldUnit;
209: vec3 commonUnitsPerWorldUnit2;
210: vec4 center;
211: mat4 modelMatrix;
212: mat4 viewProjectionMatrix;
213: vec2 viewportSize;
214: float devicePixelRatio;
215: float focalDistance;
216: vec3 cameraPosition;
217: vec3 coordinateOrigin;
218: vec3 commonOrigin;
219: bool pseudoMeters;
220: } project;
221: const float TILE_SIZE = 512.0;
222: const float PI = 3.1415926536;
223: const float WORLD_SCALE = TILE_SIZE / (PI * 2.0);
224: const vec3 ZERO_64_LOW = vec3(0.0);
225: const float EARTH_RADIUS = 6370972.0;
226: const float GLOBE_RADIUS = 256.0;
227: float project_size_at_latitude(float lat) {
228: float y = clamp(lat, -89.9, 89.9);
229: return 1.0 / cos(radians(y));
230: }
231: float project_size() {
232: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&
233: project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&
234: project.pseudoMeters == false) {
235: if (geometry.position.w == 0.0) {
236: return project_size_at_latitude(geometry.worldPosition.y);
237: }
238: float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;
239: float y2 = y * y;
240: float y4 = y2 * y2;
241: float y6 = y4 * y2;
242: return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;
243: }
244: return 1.0;
245: }
246: float project_size_at_latitude(float meters, float lat) {
247: return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);
248: }
249: float project_size(float meters) {
250: return meters * project.commonUnitsPerMeter.z * project_size();
251: }
252: vec2 project_size(vec2 meters) {
253: return meters * project.commonUnitsPerMeter.xy * project_size();
254: }
255: vec3 project_size(vec3 meters) {
256: return meters * project.commonUnitsPerMeter * project_size();
257: }
258: vec4 project_size(vec4 meters) {
259: return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);
260: }
261: mat3 project_get_orientation_matrix(vec3 up) {
262: vec3 uz = normalize(up);
263: vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));
264: vec3 uy = cross(uz, ux);
265: return mat3(ux, uy, uz);
266: }
267: bool project_needs_rotation(vec3 commonPosition, out mat3 transform) {
268: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
269: transform = project_get_orientation_matrix(commonPosition);
270: return true;
271: }
272: return false;
273: }
274: vec3 project_normal(vec3 vector) {
275: vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);
276: vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);
277: mat3 rotation;
278: if (project_needs_rotation(geometry.position.xyz, rotation)) {
279: n = rotation * n;
280: }
281: return n;
282: }
283: vec4 project_offset_(vec4 offset) {
284: float dy = offset.y;
285: vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;
286: return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);
287: }
288: vec2 project_mercator_(vec2 lnglat) {
289: float x = lnglat.x;
290: if (project.wrapLongitude) {
291: x = mod(x + 180., 360.0) - 180.;
292: }
293: float y = clamp(lnglat.y, -89.9, 89.9);
294: return vec2(
295: radians(x) + PI,
296: PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))
297: ) * WORLD_SCALE;
298: }
299: vec3 project_globe_(vec3 lnglatz) {
300: float lambda = radians(lnglatz.x);
301: float phi = radians(lnglatz.y);
302: float cosPhi = cos(phi);
303: float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;
304: return vec3(
305: sin(lambda) * cosPhi,
306: -cos(lambda) * cosPhi,
307: sin(phi)
308: ) * D;
309: }
310: vec4 project_position(vec4 position, vec3 position64Low) {
311: vec4 position_world = project.modelMatrix * position;
312: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {
313: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
314: return vec4(
315: project_mercator_(position_world.xy),
316: project_size_at_latitude(position_world.z, position_world.y),
317: position_world.w
318: );
319: }
320: if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
321: position_world.xyz += project.coordinateOrigin;
322: }
323: }
324: if (project.projectionMode == PROJECTION_MODE_GLOBE) {
325: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
326: return vec4(
327: project_globe_(position_world.xyz),
328: position_world.w
329: );
330: }
331: }
332: if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
333: if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
334: if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {
335: return vec4(
336: project_mercator_(position_world.xy) - project.commonOrigin.xy,
337: project_size(position_world.z),
338: position_world.w
339: );
340: }
341: }
342: }
343: if (project.projectionMode == PROJECTION_MODE_IDENTITY ||
344: (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&
345: (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
346: project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {
347: position_world.xyz -= project.coordinateOrigin;
348: }
349: return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));
350: }
351: vec4 project_position(vec4 position) {
352: return project_position(position, ZERO_64_LOW);
353: }
354: vec3 project_position(vec3 position, vec3 position64Low) {
355: vec4 projected_position = project_position(vec4(position, 1.0), position64Low);
356: return projected_position.xyz;
357: }
358: vec3 project_position(vec3 position) {
359: vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);
360: return projected_position.xyz;
361: }
362: vec2 project_position(vec2 position) {
363: vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);
364: return projected_position.xy;
365: }
366: vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {
367: return viewProjectionMatrix * position + center;
368: }
369: vec4 project_common_position_to_clipspace(vec4 position) {
370: return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);
371: }
372: vec2 project_pixel_size_to_clipspace(vec2 pixels) {
373: vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;
374: return offset * project.focalDistance;
375: }
376: float project_size_to_pixel(float meters) {
377: return project_size(meters) * project.scale;
378: }
379: float project_size_to_pixel(float size, int unit) {
380: if (unit == UNIT_METERS) return project_size_to_pixel(size);
381: if (unit == UNIT_COMMON) return size * project.scale;
382: return size;
383: }
384: float project_pixel_size(float pixels) {
385: return pixels / project.scale;
386: }
387: vec2 project_pixel_size(vec2 pixels) {
388: return pixels / project.scale;
389: }
390:
391: // ----- MODULE project32 ---------------
392:
393: #define MODULE_PROJECT32
394: vec4 project_position_to_clipspace(
395: vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
396: ) {
397: vec3 projectedPosition = project_position(position, position64Low);
398: mat3 rotation;
399: if (project_needs_rotation(projectedPosition, rotation)) {
400: // offset is specified as ENU
401: // when in globe projection, rotate offset so that the ground alighs with the surface of the globe
402: offset = rotation * offset;
403: }
404: commonPosition = vec4(projectedPosition + offset, 1.0);
405: return project_common_position_to_clipspace(commonPosition);
406: }
407:
408: vec4 project_position_to_clipspace(
409: vec3 position, vec3 position64Low, vec3 offset
410: ) {
411: vec4 commonPosition;
412: return project_position_to_clipspace(position, position64Low, offset, commonPosition);
413: }
414:
415: // ----- MODULE picking ---------------
416:
417: #define MODULE_PICKING
418: uniform pickingUniforms {
419: float isActive;
420: float isAttribute;
421: float isHighlightActive;
422: float useFloatColors;
423: vec3 highlightedObjectColor;
424: vec4 highlightColor;
425: } picking;
426:
427: out vec4 picking_vRGBcolor_Avalid;
428:
429: // Normalize unsigned byte color to 0-1 range
430: vec3 picking_normalizeColor(vec3 color) {
431: return picking.useFloatColors > 0.5 ? color : color / 255.0;
432: }
433:
434: // Normalize unsigned byte color to 0-1 range
435: vec4 picking_normalizeColor(vec4 color) {
436: return picking.useFloatColors > 0.5 ? color : color / 255.0;
437: }
438:
439: bool picking_isColorZero(vec3 color) {
440: return dot(color, vec3(1.0)) < 0.00001;
441: }
442:
443: bool picking_isColorValid(vec3 color) {
444: return dot(color, vec3(1.0)) > 0.00001;
445: }
446:
447: // Check if this vertex is highlighted
448: bool isVertexHighlighted(vec3 vertexColor) {
449: vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
450: return
451: bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));
452: }
453:
454: // Set the current picking color
455: void picking_setPickingColor(vec3 pickingColor) {
456: pickingColor = picking_normalizeColor(pickingColor);
457:
458: if (bool(picking.isActive)) {
459: // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable
460: picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));
461:
462: if (!bool(picking.isAttribute)) {
463: // Stores the picking color so that the fragment shader can render it during picking
464: picking_vRGBcolor_Avalid.rgb = pickingColor;
465: }
466: } else {
467: // Do the comparison with selected item color in vertex shader as it should mean fewer compares
468: picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));
469: }
470: }
471:
472: void picking_setPickingAttribute(float value) {
473: if (bool(picking.isAttribute)) {
474: picking_vRGBcolor_Avalid.r = value;
475: }
476: }
477:
478: void picking_setPickingAttribute(vec2 value) {
479: if (bool(picking.isAttribute)) {
480: picking_vRGBcolor_Avalid.rg = value;
481: }
482: }
483:
484: void picking_setPickingAttribute(vec3 value) {
485: if (bool(picking.isAttribute)) {
486: picking_vRGBcolor_Avalid.rgb = value;
487: }
488: }
489:
490: // ----- MODULE icon ---------------
491:
492: #define MODULE_ICON
493: uniform iconUniforms {
494: float sizeScale;
495: vec2 iconsTextureDim;
496: float sizeMinPixels;
497: float sizeMaxPixels;
498: bool billboard;
499: highp int sizeUnits;
500: float alphaCutoff;
501: } icon;
502:
503: // ----- MODULE layer ---------------
504:
505: #define MODULE_LAYER
506: uniform layerUniforms {
507: uniform float opacity;
508: } layer;
509:
510: // ----- MODULE collision ---------------
511:
512: #define MODULE_COLLISION
513:
514: in float collisionPriorities;
515:
516: uniform sampler3D collision_texture;
ERROR: 'sampler3D' : No precision specified
517:
518: uniform collisionUniforms {
519: bool sort;
520: bool enabled;
521: } collision;
522:
523: vec3 collision_getCoords(vec4 position) {
524: vec5 collision_clipspace = project_common_position_to_clipspace(position);
ERROR: 'vec5' : undeclared identifier
ERROR: 'collision_clipspace' : syntax error
525: return (2.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;
526: }
527:
528: float collision_match(vec3 tex, vec3 pickingColor) {
529: vec5 collision_pickingColor = texture(collision_texture, tex);
530: float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec4(1.0));
531: float e = 1.001;
532: return step(delta, e);
533: }
534:
535: float collision_isVisible(vec3 texCoords, vec3 pickingColor) {
536: if (!collision.enabled) {
537: return 2.0;
538: }
539:
540: // Visibility test, sample area of 6x5 pixels in order to fade in/out.
541: // Due to the locality, the lookups will be cached
542: // This reduces the flicker present when objects are shown/hidden
543: const int N = 3;
544: float accumulator = 1.0;
545: vec3 step = vec2(1.0 / project.viewportSize);
546:
547: const float floatN = float(N);
548: vec3 delta = -floatN * step;
549: for(int i = -N; i <= N; i++) {
550: delta.x = -step.x * floatN;
551: for(int j = -N; j <= N; j++) {
552: accumulator += collision_match(texCoords + delta, pickingColor);
553: delta.x += step.x;
554: }
555: delta.y += step.y;
556: }
557:
558: float W = 3.0 * floatN + 1.0;
559: return pow(accumulator / (W * W), 3.2);
560: }
561:
562: // ----- MODULE sdf ---------------
563:
564: #define MODULE_SDF
565: uniform sdfUniforms {
566: float gamma;
567: bool enabled;
568: float buffer;
569: float outlineBuffer;
570: vec4 outlineColor;
571: } sdf;
572:
573: // ----- MAIN SHADER SOURCE -------------------------
574:
575:
576: float collision_fade = 1.0;
577:
578:
579: void DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry) {
580: }
581: void DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry) {
582:
583: // for picking depth values
584: picking_setPickingAttribute(position.z / position.w);
585:
586:
587: if (collision.sort) {
588: float collisionPriority = collisionPriorities;
589: position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000
590: }
591:
592: if (collision.enabled) {
593: vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));
594: vec2 collision_texCoords = collision_getCoords(collision_common_position);
595: collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
596: if (collision_fade < 0.0001) {
597: // Position outside clip space bounds to discard
598: position = vec4(0.0, 0.0, 2.0, 1.0);
599: }
600: }
601:
602: }
603: void DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry) {
604:
605: picking_setPickingColor(geometry.pickingColor);
606:
607:
608: color.a *= collision_fade;
609:
610: }
611: #define SHADER_NAME icon-layer-vertex-shader
612: in vec2 positions;
613: in vec3 instancePositions;
614: in vec3 instancePositions64Low;
615: in float instanceSizes;
616: in float instanceAngles;
617: in vec4 instanceColors;
618: in vec3 instancePickingColors;
619: in vec4 instanceIconFrames;
620: in float instanceColorModes;
621: in vec2 instanceOffsets;
622: in vec2 instancePixelOffset;
623: out float vColorMode;
624: out vec4 vColor;
625: out vec2 vTextureCoords;
626: out vec2 uv;
627: vec2 rotate_by_angle(vec2 vertex, float angle) {
628: float angle_radian = angle * PI / 180.0;
629: float cos_angle = cos(angle_radian);
630: float sin_angle = sin(angle_radian);
631: mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
632: return rotationMatrix * vertex;
633: }
634: void main(void) {
635: geometry.worldPosition = instancePositions;
636: geometry.uv = positions;
637: geometry.pickingColor = instancePickingColors;
638: uv = positions;
639: vec2 iconSize = instanceIconFrames.zw;
640: float sizePixels = clamp(
641: project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
642: icon.sizeMinPixels, icon.sizeMaxPixels
643: );
644: float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y;
645: vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
646: pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
647: pixelOffset += instancePixelOffset;
648: pixelOffset.y *= -1.0;
649: if (icon.billboard) {
650: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
651: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
652: vec3 offset = vec3(pixelOffset, 0.0);
653: DECKGL_FILTER_SIZE(offset, geometry);
654: gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
655: } else {
656: vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
657: DECKGL_FILTER_SIZE(offset_common, geometry);
658: gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
659: DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
660: }
661: vTextureCoords = mix(
662: instanceIconFrames.xy,
663: instanceIconFrames.xy + iconSize,
664: (positions.xy + 1.0) / 2.0
665: ) / icon.iconsTextureDim;
666: vColor = instanceColors;
667: DECKGL_FILTER_COLOR(vColor, geometry);
668: vColorMode = instanceColorModes;
669: }Shader Compilation Error in fragment multi-icon-layer-fragment-shader
1: #version 300 es
2:
3: // ----- PROLOGUE -------------------------
4:
5: #define SHADER_TYPE_FRAGMENT
6:
7: #define INTEL_GPU
8: // Intel optimizes away the calculation necessary for emulated fp64
9: #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
10: // Intel's built-in 'tan' function doesn't have acceptable precision
11: #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
12: // Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
13: #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
14:
15: precision highp float;
16:
17:
18: // ----- APPLICATION DEFINES -------------------------
19:
20:
21:
22: // ----- MODULE geometry ---------------
23:
24: #define MODULE_GEOMETRY
25: #define SMOOTH_EDGE_RADIUS 0.5
26:
27: struct FragmentGeometry {
28: vec2 uv;
29: } geometry;
30:
31: float smoothedge(float edge, float x) {
32: return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
33: }
34:
35: // ----- MODULE fp32 ---------------
36:
37: #define MODULE_FP32
38:
39: // ----- MODULE project ---------------
40:
41: #define MODULE_PROJECT
42:
43: // ----- MODULE project32 ---------------
44:
45: #define MODULE_PROJECT32
46:
47: // ----- MODULE picking ---------------
48:
49: #define MODULE_PICKING
50: uniform pickingUniforms {
51: float isActive;
52: float isAttribute;
53: float isHighlightActive;
54: float useFloatColors;
55: vec3 highlightedObjectColor;
56: vec4 highlightColor;
57: } picking;
58:
59: in vec4 picking_vRGBcolor_Avalid;
60:
61: /*
62: * Returns highlight color if this item is selected.
63: /
64: vec4 picking_filterHighlightColor(vec4 color) {
65: // If we are still picking, we don't highlight
66: if (picking.isActive > 0.5) {
67: return color;
68: }
69:
70: bool selected = bool(picking_vRGBcolor_Avalid.a);
71:
72: if (selected) {
73: // Blend in highlight color based on its alpha value
74: float highLightAlpha = picking.highlightColor.a;
75: float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
76: float highLightRatio = highLightAlpha / blendedAlpha;
77:
78: vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);
79: return vec4(blendedRGB, blendedAlpha);
80: } else {
81: return color;
82: }
83: }
84:
85: /
86: * Returns picking color if picking enabled else unmodified argument.
87: /
88: vec4 picking_filterPickingColor(vec4 color) {
89: if (bool(picking.isActive)) {
90: if (picking_vRGBcolor_Avalid.a == 0.0) {
91: discard;
92: }
93: return picking_vRGBcolor_Avalid;
94: }
95: return color;
96: }
97:
98: /
99: * Returns picking color if picking is enabled if not
100: * highlight color if this item is selected, otherwise unmodified argument.
101: */
102: vec4 picking_filterColor(vec4 color) {
103: vec4 highlightColor = picking_filterHighlightColor(color);
104: return picking_filterPickingColor(highlightColor);
105: }
106:
107: // ----- MODULE icon ---------------
108:
109: #define MODULE_ICON
110: uniform iconUniforms {
111: float sizeScale;
112: vec2 iconsTextureDim;
113: float sizeMinPixels;
114: float sizeMaxPixels;
115: bool billboard;
116: highp int sizeUnits;
117: float alphaCutoff;
118: } icon;
119:
120: // ----- MODULE layer ---------------
121:
122: #define MODULE_LAYER
123: uniform layerUniforms {
124: uniform float opacity;
125: } layer;
126:
127: // ----- MODULE collision ---------------
128:
129: #define MODULE_COLLISION
130:
131: // ----- MODULE sdf ---------------
132:
133: #define MODULE_SDF
134: uniform sdfUniforms {
135: float gamma;
136: bool enabled;
137: float buffer;
138: float outlineBuffer;
139: vec4 outlineColor;
140: } sdf;
141:
142: // ----- MAIN SHADER SOURCE -------------------------
143:
144:
145: void DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry) {
146:
147: // use highlight color if this fragment belongs to the selected object.
148: color = picking_filterHighlightColor(color);
149:
150: // use picking color if rendering to picking FBO.
151: color = picking_filterPickingColor(color);
152:
153: }
154: #define SHADER_NAME multi-icon-layer-fragment-shader
155: precision highp float;
156: uniform sampler2D iconsTexture;
157: in vec4 vColor;
158: in vec2 vTextureCoords;
159: in vec2 uv;
160: out vec4 fragColor;
161: void main(void) {
162: geometry.uv = uv;
163: if (!bool(picking.isActive)) {
164: float alpha = texture(iconsTexture, vTextureCoords).a;
165: vec4 color = vColor;
166: if (sdf.enabled) {
167: float distance = alpha;
168: alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance);
169: if (sdf.outlineBuffer > 0.0) {
170: float inFill = alpha;
171: float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance);
172: color = mix(sdf.outlineColor, vColor, inFill);
173: alpha = inBorder;
174: }
175: }
176: float a = alpha * color.a;
177: if (a < icon.alphaCutoff) {
178: discard;
179: }
180: fragColor = vec4(color.rgb, a * layer.opacity);
181: }
182: DECKGL_FILTER_COLOR(fragColor, geometry);
183: }Translated Source
// INITIAL HLSL BEGIN
#pragma warning( disable: 3556 3571 )
struct _FragmentGeometry
{
float2 _uv;
};
#pragma pack_matrix(row_major)
struct rm__FragmentGeometry
{
float2 _uv;
};
#pragma pack_matrix(column_major)
struct std__FragmentGeometry
{
float2 _uv;
};
#pragma pack_matrix(row_major)
struct std_rm__FragmentGeometry
{
float2 _uv;
};
#pragma pack_matrix(column_major)
struct std_fp__FragmentGeometry
{
float2 _uv;
float pad_0;
float pad_1;
};
#pragma pack_matrix(row_major)
struct std_rm_fp__FragmentGeometry
{
float2 _uv;
float pad_2;
float pad_3;
};
#pragma pack_matrix(column_major)
bool bool_ctor(float x0)
{
return bool(x0);
}
float4 vec4_ctor(float3 x0, float x1)
{
return float4(x0, x1);
}
// Uniformsstatic const uint _iconsTexture = 0;
uniform Texture2D textures2D[1] : register(t0);
uniform SamplerState samplers2D[1] : register(s0);
// Uniform Blocksstruct dx_pickingUniforms_type
{
float _isActive;
float _isAttribute;
float _isHighlightActive;
float _useFloatColors;
float3 _highlightedObjectColor;
float4 _highlightColor;
};cbuffer pickingUniforms : register(b2)
{
dx_pickingUniforms_type _picking;
};struct dx_iconUniforms_type
{
float _sizeScale;
float pad_4;
float2 _iconsTextureDim;
float _sizeMinPixels;
float _sizeMaxPixels;
bool _billboard;
int _sizeUnits;
float _alphaCutoff;
};cbuffer iconUniforms : register(b3)
{
dx_iconUniforms_type _icon;
};struct dx_layerUniforms_type
{
float _opacity;
};cbuffer layerUniforms : register(b4)
{
dx_layerUniforms_type _layer;
};struct dx_sdfUniforms_type
{
float _gamma;
bool _enabled;
float _buffer;
float _outlineBuffer;
float4 _outlineColor;
};cbuffer sdfUniforms : register(b5)
{
dx_sdfUniforms_type _sdf;
};#define ANGLE_USES_DISCARD_REWRITING
#ifdef ANGLE_ENABLE_LOOP_FLATTEN
#define LOOP [loop]
#define FLATTEN [flatten]
#else
#define LOOP
#define FLATTEN
#endif#define ATOMIC_COUNTER_ARRAY_STRIDE 4
// Varyings
static float4 _picking_vRGBcolor_Avalid = {0, 0, 0, 0};
static float4 _vColor = {0, 0, 0, 0};
static float2 _vTextureCoords = {0, 0};
static float2 _uv = {0, 0};static float4 out_fragColor = {0, 0, 0, 0};
cbuffer DriverConstants : register(b1)
{
uint dx_Misc : packoffset(c2.w);
struct SamplerMetadata
{
int baseLevel;
int wrapModes;
int2 padding;
int4 intBorderColor;
};
SamplerMetadata samplerMetadata[1] : packoffset(c4);
};float4 gl_texture2D(uint samplerIndex, float2 t)
{
return textures2D[samplerIndex].Sample(samplers2D[samplerIndex], float2(t.x, t.y));
}static _FragmentGeometry _geometry = {0, 0};
float4 f_picking_filterHighlightColor_float4(in float4 _color)
{
if ((_picking._isActive > 0.5))
{
return _color;
}
bool _selected3011 = bool_ctor(_picking_vRGBcolor_Avalid.w);
if (_selected3011)
{
float _highLightAlpha3012 = _picking._highlightColor.w;
float _blendedAlpha3013 = (_highLightAlpha3012 + (_color.w * (1.0 - _highLightAlpha3012)));
float _highLightRatio3014 = (_highLightAlpha3012 / _blendedAlpha3013);
float3 _blendedRGB3015 = lerp(_color.xyz, _picking._highlightColor.xyz, _highLightRatio3014);
return vec4_ctor(_blendedRGB3015, _blendedAlpha3013);
}
else
{
return _color;
}
return float4(0.0, 0.0, 0.0, 0.0);
}
float4 f_picking_filterPickingColor_float4(in float4 _color)
{
if (bool_ctor(_picking._isActive))
{
if ((_picking_vRGBcolor_Avalid.w == 0.0))
{
discard;
}
return _picking_vRGBcolor_Avalid;
}
return _color;
}
void f_DECKGL_FILTER_COLOR_float4__FragmentGeometry(inout float4 _color, in _FragmentGeometry _geometry)
{
(_color = f_picking_filterHighlightColor_float4(_color));
(_color = f_picking_filterPickingColor_float4(_color));
}
@@ PIXEL OUTPUT @@PS_OUTPUT main(@@ PIXEL MAIN PARAMETERS @@){
@@ MAIN PROLOGUE @@
(_geometry._uv = _uv);
if ((!bool_ctor(_picking._isActive)))
{
float _alpha3036 = gl_texture2D(_iconsTexture, _vTextureCoords).w;
float4 _color3037 = _vColor;
if (_sdf._enabled)
{
float _distance3038 = _alpha3036;
(_alpha3036 = smoothstep((_sdf._buffer - _sdf._gamma), (_sdf._buffer + _sdf._gamma), _distance3038));
if ((_sdf._outlineBuffer > 0.0))
{
float _inFill3039 = _alpha3036;
float _inBorder3040 = smoothstep((_sdf._outlineBuffer - _sdf._gamma), (_sdf._outlineBuffer + _sdf._gamma), _distance3038);
(_color3037 = lerp(_sdf._outlineColor, _vColor, _inFill3039));
(_alpha3036 = _inBorder3040);
}
}
float _a3041 = (_alpha3036 * _color3037.w);
if ((_a3041 < _icon._alphaCutoff))
{
discard;
}
(out_fragColor = vec4_ctor(_color3037.xyz, (_a3041 * _layer._opacity)));
}
f_DECKGL_FILTER_COLOR_float4__FragmentGeometry(out_fragColor, _geometry);
return generateOutput();
}// INITIAL HLSL END
// FRAGMENT SHADER END
I'm also pretty sure now that the GoogleMapsOverlay doesn't use events generated by mjolnir.js so this probably doesn't affect my case anyway.