@deck.gl/extensions 8.8.15 → 8.8.17

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.
@@ -0,0 +1,93 @@
1
+ export const dashShaders = {
2
+ inject: {
3
+ 'vs:#decl': `
4
+ attribute vec2 instanceDashArrays;
5
+ attribute float instanceDashOffsets;
6
+ varying vec2 vDashArray;
7
+ varying float vDashOffset;
8
+ `,
9
+ 'vs:#main-end': `
10
+ vDashArray = instanceDashArrays;
11
+ vDashOffset = instanceDashOffsets / width.x;
12
+ `,
13
+ 'fs:#decl': `
14
+ uniform float dashAlignMode;
15
+ uniform float capType;
16
+ uniform bool dashGapPickable;
17
+ varying vec2 vDashArray;
18
+ varying float vDashOffset;
19
+
20
+ float round(float x) {
21
+ return floor(x + 0.5);
22
+ }
23
+ `,
24
+ // if given position is in the gap part of the dashed line
25
+ // dashArray.x: solid stroke length, relative to width
26
+ // dashArray.y: gap length, relative to width
27
+ // alignMode:
28
+ // 0 - no adjustment
29
+ // o---- ---- ---- ---- o---- -o---- ---- o
30
+ // 1 - stretch to fit, draw half dash at each end for nicer joints
31
+ // o-- ---- ---- ---- --o-- --o-- ---- --o
32
+ 'fs:#main-start': `
33
+ float solidLength = vDashArray.x;
34
+ float gapLength = vDashArray.y;
35
+ float unitLength = solidLength + gapLength;
36
+
37
+ float offset;
38
+
39
+ if (unitLength > 0.0) {
40
+ if (dashAlignMode == 0.0) {
41
+ offset = vDashOffset;
42
+ } else {
43
+ unitLength = vPathLength / round(vPathLength / unitLength);
44
+ offset = solidLength / 2.0;
45
+ }
46
+
47
+ float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);
48
+
49
+ if (gapLength > 0.0 && unitOffset > solidLength) {
50
+ if (capType <= 0.5) {
51
+ if (!(dashGapPickable && picking_uActive)) {
52
+ discard;
53
+ }
54
+ } else {
55
+ // caps are rounded, test the distance to solid ends
56
+ float distToEnd = length(vec2(
57
+ min(unitOffset - solidLength, unitLength - unitOffset),
58
+ vPathPosition.x
59
+ ));
60
+ if (distToEnd > 1.0) {
61
+ if (!(dashGapPickable && picking_uActive)) {
62
+ discard;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ `
69
+ }
70
+ };
71
+ export const offsetShaders = {
72
+ inject: {
73
+ 'vs:#decl': `
74
+ attribute float instanceOffsets;
75
+ `,
76
+ 'vs:DECKGL_FILTER_SIZE': `
77
+ float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
78
+ size *= offsetWidth;
79
+ `,
80
+ 'vCornerOffset = offsetVec;': `
81
+ float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
82
+ vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;
83
+ vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;
84
+ `,
85
+ 'fs:#main-start': `
86
+ float isInside;
87
+ isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
88
+ if (isInside == 0.0) {
89
+ discard;
90
+ }
91
+ `
92
+ }
93
+ };