@deck.gl/extensions 9.4.0-beta.1 → 9.4.0-beta.3
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/dist.dev.js +1281 -120
- package/dist/fill-style/fill-style-extension.d.ts +38 -6
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +88 -10
- package/dist/fill-style/fill-style-extension.js.map +1 -1
- package/dist/fill-style/procedural-pattern.d.ts +65 -0
- package/dist/fill-style/procedural-pattern.d.ts.map +1 -0
- package/dist/fill-style/procedural-pattern.js +135 -0
- package/dist/fill-style/procedural-pattern.js.map +1 -0
- package/dist/fill-style/shader-module.d.ts +13 -4
- package/dist/fill-style/shader-module.d.ts.map +1 -1
- package/dist/fill-style/shader-module.js +212 -21
- package/dist/fill-style/shader-module.js.map +1 -1
- package/dist/index.cjs +946 -172
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mask/shader-module.d.ts +1 -0
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.d.ts +49 -6
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +237 -37
- package/dist/path-style/path-style-extension.js.map +1 -1
- package/dist/path-style/shaders.glsl.d.ts +30 -1
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +136 -21
- package/dist/path-style/shaders.glsl.js.map +1 -1
- package/dist/terrain/shader-module.d.ts +1 -0
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist.min.js +377 -98
- package/package.json +6 -6
- package/src/fill-style/fill-style-extension.ts +135 -13
- package/src/fill-style/procedural-pattern.ts +203 -0
- package/src/fill-style/shader-module.ts +233 -23
- package/src/index.ts +10 -1
- package/src/path-style/path-style-extension.ts +350 -44
- package/src/path-style/shaders.glsl.ts +268 -27
|
@@ -6,26 +6,68 @@ export const dashShaders = {
|
|
|
6
6
|
'vs:#decl': `
|
|
7
7
|
in vec2 instanceDashArrays;
|
|
8
8
|
#ifdef HIGH_PRECISION_DASH
|
|
9
|
-
in
|
|
9
|
+
in vec2 instanceDashOffsets;
|
|
10
10
|
#endif
|
|
11
11
|
out vec2 vDashArray;
|
|
12
12
|
out float vDashOffset;
|
|
13
|
+
out float vDashPathLength;
|
|
14
|
+
layout(std140) uniform pathStyleUniforms {
|
|
15
|
+
float dashAlignMode;
|
|
16
|
+
bool dashGapPickable;
|
|
17
|
+
highp int dashUnits;
|
|
18
|
+
} pathStyle;
|
|
13
19
|
`,
|
|
14
20
|
'vs:#main-end': `
|
|
15
|
-
|
|
21
|
+
float dashWidthPixels = path.billboard
|
|
22
|
+
? width.x * project.focalDistance
|
|
23
|
+
: width.x * project.scale;
|
|
24
|
+
float strokeHalfWidthPixels = path.billboard ? width.x : width.x * project.scale;
|
|
25
|
+
float dashUnitPixels = strokeHalfWidthPixels;
|
|
26
|
+
if (pathStyle.dashUnits == 1) {
|
|
27
|
+
dashUnitPixels = 1.0;
|
|
28
|
+
} else if (pathStyle.dashUnits == 2) {
|
|
29
|
+
dashUnitPixels = project_size_to_pixel(1.0);
|
|
30
|
+
} else if (pathStyle.dashUnits == 3) {
|
|
31
|
+
dashUnitPixels = project.scale;
|
|
32
|
+
}
|
|
33
|
+
vDashArray = instanceDashArrays * (dashUnitPixels / dashWidthPixels);
|
|
16
34
|
#ifdef HIGH_PRECISION_DASH
|
|
17
|
-
|
|
35
|
+
vec2 dashOffsetAndLength = (instanceDashOffsets * project.scale) / dashWidthPixels;
|
|
36
|
+
vDashPathLength = dashOffsetAndLength.y;
|
|
37
|
+
float dashUnitLength = vDashArray.x + vDashArray.y;
|
|
38
|
+
float dashPeriod = pathStyle.dashAlignMode == 0.0
|
|
39
|
+
? dashUnitLength
|
|
40
|
+
: vDashPathLength / max(round(vDashPathLength / max(dashUnitLength, 0.0001)), 1.0);
|
|
41
|
+
vDashOffset = dashPeriod > 0.0 ? mod(dashOffsetAndLength.x, dashPeriod) : 0.0;
|
|
18
42
|
#else
|
|
19
43
|
vDashOffset = 0.0;
|
|
44
|
+
vDashPathLength = 0.0;
|
|
20
45
|
#endif
|
|
21
46
|
`,
|
|
22
47
|
'fs:#decl': `
|
|
23
48
|
layout(std140) uniform pathStyleUniforms {
|
|
24
49
|
float dashAlignMode;
|
|
25
50
|
bool dashGapPickable;
|
|
51
|
+
highp int dashUnits;
|
|
26
52
|
} pathStyle;
|
|
27
53
|
in vec2 vDashArray;
|
|
28
54
|
in float vDashOffset;
|
|
55
|
+
in float vDashPathLength;
|
|
56
|
+
float dashPatternIntegral(float position, float solidLength, float unitLength) {
|
|
57
|
+
return floor(position / unitLength) * solidLength +
|
|
58
|
+
min(mod(position, unitLength), solidLength);
|
|
59
|
+
}
|
|
60
|
+
float dashPatternCoverage(
|
|
61
|
+
float position,
|
|
62
|
+
float solidLength,
|
|
63
|
+
float unitLength,
|
|
64
|
+
float filterWidth
|
|
65
|
+
) {
|
|
66
|
+
float halfFilter = 0.5 * filterWidth;
|
|
67
|
+
float reducedPosition = mod(position, unitLength);
|
|
68
|
+
return (dashPatternIntegral(reducedPosition + halfFilter, solidLength, unitLength) -
|
|
69
|
+
dashPatternIntegral(reducedPosition - halfFilter, solidLength, unitLength)) / filterWidth;
|
|
70
|
+
}
|
|
29
71
|
`,
|
|
30
72
|
// if given position is in the gap part of the dashed line
|
|
31
73
|
// dashArray.x: solid stroke length, relative to width
|
|
@@ -36,36 +78,90 @@ in float vDashOffset;
|
|
|
36
78
|
// 1 - stretch to fit, draw half dash at each end for nicer joints
|
|
37
79
|
// o-- ---- ---- ---- --o-- --o-- ---- --o
|
|
38
80
|
'fs:#main-start': `
|
|
81
|
+
float dashCoverage = 1.0;
|
|
82
|
+
bool shouldDiscardDash = false;
|
|
83
|
+
bool inRoundedDashGap = false;
|
|
84
|
+
float roundedDashResolvedCoverage = 1.0;
|
|
85
|
+
float roundedDashSubPixelBlend = 0.0;
|
|
86
|
+
float roundedDashDutyCycle = 1.0;
|
|
39
87
|
float solidLength = vDashArray.x;
|
|
40
88
|
float gapLength = vDashArray.y;
|
|
41
89
|
float unitLength = solidLength + gapLength;
|
|
90
|
+
if (unitLength > 0.0 && gapLength > 0.0) {
|
|
42
91
|
float offset;
|
|
43
|
-
if (unitLength > 0.0) {
|
|
44
92
|
if (pathStyle.dashAlignMode == 0.0) {
|
|
45
93
|
offset = vDashOffset;
|
|
46
94
|
} else {
|
|
47
|
-
|
|
95
|
+
#ifdef HIGH_PRECISION_DASH
|
|
96
|
+
unitLength = vDashPathLength / max(round(vDashPathLength / unitLength), 1.0);
|
|
97
|
+
#else
|
|
98
|
+
unitLength = vPathLength / max(round(vPathLength / unitLength), 1.0);
|
|
99
|
+
#endif
|
|
100
|
+
solidLength = min(solidLength, unitLength);
|
|
48
101
|
offset = solidLength / 2.0;
|
|
102
|
+
#ifdef HIGH_PRECISION_DASH
|
|
103
|
+
offset += vDashOffset;
|
|
104
|
+
#endif
|
|
49
105
|
}
|
|
50
|
-
float
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
float distToEnd = length(vec2(
|
|
106
|
+
float alongPath = vPathPosition.y + offset;
|
|
107
|
+
float unitOffset = mod(alongPath, unitLength);
|
|
108
|
+
float filterWidth = max(fwidth(alongPath), 0.0001);
|
|
109
|
+
if (bool(picking.isActive)) {
|
|
110
|
+
bool inGap = unitOffset > solidLength;
|
|
111
|
+
if (inGap && path.capType > 0.5) {
|
|
112
|
+
inGap = length(vec2(
|
|
58
113
|
min(unitOffset - solidLength, unitLength - unitOffset),
|
|
59
114
|
vPathPosition.x
|
|
60
|
-
));
|
|
61
|
-
if (distToEnd > 1.0) {
|
|
62
|
-
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
|
|
63
|
-
discard;
|
|
115
|
+
)) > 1.0;
|
|
64
116
|
}
|
|
117
|
+
if (inGap && !pathStyle.dashGapPickable) {
|
|
118
|
+
shouldDiscardDash = true;
|
|
65
119
|
}
|
|
120
|
+
} else if (path.capType <= 0.5) {
|
|
121
|
+
dashCoverage = dashPatternCoverage(alongPath, solidLength, unitLength, filterWidth);
|
|
122
|
+
} else {
|
|
123
|
+
float distanceAlongGap = min(unitOffset - solidLength, unitLength - unitOffset);
|
|
124
|
+
float distanceToEnd = length(vec2(max(distanceAlongGap, 0.0), vPathPosition.x));
|
|
125
|
+
float capEdgePixels = (1.0 - distanceToEnd) / max(fwidth(distanceToEnd), 1e-6);
|
|
126
|
+
if (distanceAlongGap > 0.0) {
|
|
127
|
+
inRoundedDashGap = true;
|
|
128
|
+
roundedDashResolvedCoverage = smoothedge(0.0, capEdgePixels);
|
|
129
|
+
dashCoverage = roundedDashResolvedCoverage;
|
|
66
130
|
}
|
|
131
|
+
float subPixelBlend = smoothstep(unitLength, 2.0 * unitLength, filterWidth);
|
|
132
|
+
roundedDashSubPixelBlend = subPixelBlend;
|
|
133
|
+
float boundedSolidLength = min(solidLength, unitLength);
|
|
134
|
+
float effectiveGap = max(unitLength - boundedSolidLength, 0.0);
|
|
135
|
+
float capSpan = 2.0 * sqrt(max(1.0 - vPathPosition.x * vPathPosition.x, 0.0));
|
|
136
|
+
float roundedDutyCycle = clamp(
|
|
137
|
+
(boundedSolidLength + min(effectiveGap, capSpan)) / unitLength,
|
|
138
|
+
0.0,
|
|
139
|
+
1.0
|
|
140
|
+
);
|
|
141
|
+
roundedDashDutyCycle = roundedDutyCycle;
|
|
142
|
+
dashCoverage = mix(dashCoverage, roundedDutyCycle, subPixelBlend);
|
|
67
143
|
}
|
|
144
|
+
dashCoverage = clamp(dashCoverage, 0.0, 1.0);
|
|
145
|
+
shouldDiscardDash = shouldDiscardDash || dashCoverage <= 0.0;
|
|
146
|
+
}
|
|
147
|
+
`,
|
|
148
|
+
'fs:#main-end': `
|
|
149
|
+
#ifdef ANTIALIASING
|
|
150
|
+
if (inRoundedDashGap) {
|
|
151
|
+
float pathCoverage = smoothedge(0.0, edgePixels);
|
|
152
|
+
float resolvedCapMultiplier =
|
|
153
|
+
min(pathCoverage, roundedDashResolvedCoverage) / max(pathCoverage, 1e-6);
|
|
154
|
+
dashCoverage = mix(
|
|
155
|
+
resolvedCapMultiplier,
|
|
156
|
+
roundedDashDutyCycle,
|
|
157
|
+
roundedDashSubPixelBlend
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
#endif
|
|
161
|
+
if (shouldDiscardDash) {
|
|
162
|
+
discard;
|
|
68
163
|
}
|
|
164
|
+
fragColor.a *= dashCoverage;
|
|
69
165
|
`
|
|
70
166
|
}
|
|
71
167
|
};
|
|
@@ -266,13 +362,32 @@ float offsetDir = sign(instanceOffsets);
|
|
|
266
362
|
vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
|
|
267
363
|
vPathPosition.y *= offsetWidth;
|
|
268
364
|
vPathLength *= offsetWidth;
|
|
365
|
+
#ifdef DASH_ENABLED
|
|
366
|
+
if (pathStyle.dashUnits != 0) {
|
|
367
|
+
vDashArray *= offsetWidth;
|
|
368
|
+
}
|
|
369
|
+
vPathBounds *= offsetWidth;
|
|
370
|
+
#ifdef HIGH_PRECISION_DASH
|
|
371
|
+
vDashPathLength *= offsetWidth;
|
|
372
|
+
float restoredDashUnitLength = vDashArray.x + vDashArray.y;
|
|
373
|
+
float restoredDashPeriod = pathStyle.dashAlignMode == 0.0
|
|
374
|
+
? restoredDashUnitLength
|
|
375
|
+
: vDashPathLength /
|
|
376
|
+
max(round(vDashPathLength / max(restoredDashUnitLength, 0.0001)), 1.0);
|
|
377
|
+
vDashOffset = restoredDashPeriod > 0.0
|
|
378
|
+
? mod(dashOffsetAndLength.x * offsetWidth, restoredDashPeriod)
|
|
379
|
+
: 0.0;
|
|
380
|
+
#else
|
|
381
|
+
vDashOffset *= offsetWidth;
|
|
382
|
+
#endif
|
|
383
|
+
#endif
|
|
269
384
|
`,
|
|
270
|
-
'fs:#main-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (isInside == 0.0) {
|
|
385
|
+
'fs:#main-end': `
|
|
386
|
+
#ifndef ANTIALIASING
|
|
387
|
+
if (abs(vPathPosition.x) > 1.0) {
|
|
274
388
|
discard;
|
|
275
389
|
}
|
|
390
|
+
#endif
|
|
276
391
|
`
|
|
277
392
|
}
|
|
278
393
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaders.glsl.js","sourceRoot":"","sources":["../../src/path-style/shaders.glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;
|
|
1
|
+
{"version":3,"file":"shaders.glsl.js","sourceRoot":"","sources":["../../src/path-style/shaders.glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAsCpC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE;QACN,UAAU;;;;;;;;;;;;;CAkBb;QAEG,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDjB;QAEG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CA0Cb;QAEG,0DAA0D;QAC1D,sDAAsD;QACtD,6CAA6C;QAC7C,aAAa;QACb,oBAAoB;QACpB,mEAAmE;QACnE,kEAAkE;QAClE,mEAAmE;QACnE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGnB;QAEG,cAAc;;;;;;;;;;;;;;;;;CAwBjB;KACE;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM,EAAE;QACN,UAAU,EAAE;;;CAGf;QAEG,cAAc,EAAE;;CAEnB;QAEG,UAAU;;;;;;CAQb;QAEG,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CAwBnB;QAEG,cAAc;;;;;;;CAOjB;KACE;CACF,CAAC;AAEF,MAAM,C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