@cosmos.gl/graph 2.6.0 → 2.6.2-rc.0
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/config.d.ts +3 -0
- package/dist/index.d.ts +48 -6
- package/dist/index.js +1346 -1289
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +15 -15
- package/dist/index.min.js.map +1 -1
- package/package.json +5 -1
- package/.eslintrc +0 -147
- package/.github/SECURITY.md +0 -19
- package/.github/dco.yml +0 -4
- package/.github/workflows/github_pages.yml +0 -54
- package/.storybook/main.ts +0 -26
- package/.storybook/manager-head.html +0 -1
- package/.storybook/manager.ts +0 -14
- package/.storybook/preview.ts +0 -29
- package/.storybook/style.css +0 -3
- package/CHARTER.md +0 -69
- package/CODE_OF_CONDUCT.md +0 -178
- package/CONTRIBUTING.md +0 -22
- package/GOVERNANCE.md +0 -21
- package/cosmos-2-0-migration-notes.md +0 -98
- package/cosmos_awesome.md +0 -96
- package/dist/stories/beginners/basic-set-up/data-gen.d.ts +0 -4
- package/dist/stories/beginners/basic-set-up/index.d.ts +0 -5
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +0 -19
- package/dist/stories/beginners/link-hovering/index.d.ts +0 -5
- package/dist/stories/beginners/pinned-points/data-gen.d.ts +0 -5
- package/dist/stories/beginners/pinned-points/index.d.ts +0 -5
- package/dist/stories/beginners/point-labels/data.d.ts +0 -13
- package/dist/stories/beginners/point-labels/index.d.ts +0 -9
- package/dist/stories/beginners/point-labels/labels.d.ts +0 -8
- package/dist/stories/beginners/quick-start.d.ts +0 -5
- package/dist/stories/beginners/remove-points/config.d.ts +0 -2
- package/dist/stories/beginners/remove-points/data-gen.d.ts +0 -4
- package/dist/stories/beginners/remove-points/index.d.ts +0 -5
- package/dist/stories/beginners.stories.d.ts +0 -11
- package/dist/stories/clusters/polygon-selection/index.d.ts +0 -6
- package/dist/stories/clusters/polygon-selection/polygon.d.ts +0 -20
- package/dist/stories/clusters/radial.d.ts +0 -5
- package/dist/stories/clusters/with-labels.d.ts +0 -6
- package/dist/stories/clusters/worm.d.ts +0 -5
- package/dist/stories/clusters.stories.d.ts +0 -9
- package/dist/stories/create-cluster-labels.d.ts +0 -4
- package/dist/stories/create-cosmos.d.ts +0 -16
- package/dist/stories/create-story.d.ts +0 -16
- package/dist/stories/experiments/full-mesh.d.ts +0 -5
- package/dist/stories/experiments/mesh-with-holes.d.ts +0 -5
- package/dist/stories/experiments.stories.d.ts +0 -7
- package/dist/stories/generate-mesh-data.d.ts +0 -12
- package/dist/stories/geospatial/moscow-metro-stations/index.d.ts +0 -15
- package/dist/stories/geospatial/moscow-metro-stations/moscow-metro-coords.d.ts +0 -1
- package/dist/stories/geospatial/moscow-metro-stations/point-colors.d.ts +0 -1
- package/dist/stories/geospatial.stories.d.ts +0 -6
- package/dist/stories/shapes/all-shapes/index.d.ts +0 -5
- package/dist/stories/shapes/image-example/index.d.ts +0 -5
- package/dist/stories/shapes.stories.d.ts +0 -7
- package/logo.svg +0 -3
- package/rollup.config.js +0 -70
- package/src/config.ts +0 -734
- package/src/declaration.d.ts +0 -12
- package/src/graph/utils/error-message.ts +0 -23
- package/src/helper.ts +0 -74
- package/src/index.ts +0 -1635
- package/src/modules/Clusters/calculate-centermass.frag +0 -9
- package/src/modules/Clusters/calculate-centermass.vert +0 -26
- package/src/modules/Clusters/force-cluster.frag +0 -39
- package/src/modules/Clusters/index.ts +0 -200
- package/src/modules/Drag/index.ts +0 -33
- package/src/modules/FPSMonitor/css.ts +0 -53
- package/src/modules/FPSMonitor/index.ts +0 -28
- package/src/modules/ForceCenter/calculate-centermass.frag +0 -9
- package/src/modules/ForceCenter/calculate-centermass.vert +0 -18
- package/src/modules/ForceCenter/force-center.frag +0 -27
- package/src/modules/ForceCenter/index.ts +0 -104
- package/src/modules/ForceGravity/force-gravity.frag +0 -27
- package/src/modules/ForceGravity/index.ts +0 -33
- package/src/modules/ForceLink/force-spring.ts +0 -73
- package/src/modules/ForceLink/index.ts +0 -149
- package/src/modules/ForceManyBody/calculate-level.frag +0 -9
- package/src/modules/ForceManyBody/calculate-level.vert +0 -25
- package/src/modules/ForceManyBody/force-centermass.frag +0 -52
- package/src/modules/ForceManyBody/force-level.frag +0 -121
- package/src/modules/ForceManyBody/index.ts +0 -223
- package/src/modules/ForceManyBody/quadtree-frag-shader.ts +0 -90
- package/src/modules/ForceManyBodyQuadtree/calculate-level.frag +0 -9
- package/src/modules/ForceManyBodyQuadtree/calculate-level.vert +0 -25
- package/src/modules/ForceManyBodyQuadtree/index.ts +0 -157
- package/src/modules/ForceManyBodyQuadtree/quadtree-frag-shader.ts +0 -93
- package/src/modules/ForceMouse/force-mouse.frag +0 -24
- package/src/modules/ForceMouse/index.ts +0 -32
- package/src/modules/GraphData/index.ts +0 -384
- package/src/modules/Lines/draw-curve-line.frag +0 -46
- package/src/modules/Lines/draw-curve-line.vert +0 -194
- package/src/modules/Lines/geometry.ts +0 -18
- package/src/modules/Lines/hovered-line-index.frag +0 -27
- package/src/modules/Lines/hovered-line-index.vert +0 -8
- package/src/modules/Lines/index.ts +0 -273
- package/src/modules/Points/atlas-utils.ts +0 -137
- package/src/modules/Points/drag-point.frag +0 -20
- package/src/modules/Points/draw-highlighted.frag +0 -16
- package/src/modules/Points/draw-highlighted.vert +0 -86
- package/src/modules/Points/draw-points.frag +0 -243
- package/src/modules/Points/draw-points.vert +0 -127
- package/src/modules/Points/fill-sampled-points.frag +0 -9
- package/src/modules/Points/fill-sampled-points.vert +0 -29
- package/src/modules/Points/find-hovered-point.frag +0 -9
- package/src/modules/Points/find-hovered-point.vert +0 -57
- package/src/modules/Points/find-points-on-area-selection.frag +0 -48
- package/src/modules/Points/find-points-on-polygon-selection.frag +0 -65
- package/src/modules/Points/index.ts +0 -968
- package/src/modules/Points/track-positions.frag +0 -18
- package/src/modules/Points/update-position.frag +0 -37
- package/src/modules/Shared/buffer.ts +0 -37
- package/src/modules/Shared/clear.frag +0 -7
- package/src/modules/Shared/quad.vert +0 -12
- package/src/modules/Store/index.ts +0 -173
- package/src/modules/Zoom/index.ts +0 -148
- package/src/modules/core-module.ts +0 -28
- package/src/stories/1. welcome.mdx +0 -81
- package/src/stories/2. configuration.mdx +0 -113
- package/src/stories/3. api-reference.mdx +0 -591
- package/src/stories/beginners/basic-set-up/data-gen.ts +0 -33
- package/src/stories/beginners/basic-set-up/index.ts +0 -163
- package/src/stories/beginners/basic-set-up/style.css +0 -35
- package/src/stories/beginners/link-hovering/data-generator.ts +0 -198
- package/src/stories/beginners/link-hovering/index.ts +0 -61
- package/src/stories/beginners/link-hovering/style.css +0 -73
- package/src/stories/beginners/pinned-points/data-gen.ts +0 -153
- package/src/stories/beginners/pinned-points/index.ts +0 -61
- package/src/stories/beginners/point-labels/data.ts +0 -73
- package/src/stories/beginners/point-labels/index.ts +0 -65
- package/src/stories/beginners/point-labels/labels.ts +0 -46
- package/src/stories/beginners/point-labels/style.css +0 -16
- package/src/stories/beginners/quick-start.ts +0 -50
- package/src/stories/beginners/remove-points/config.ts +0 -25
- package/src/stories/beginners/remove-points/data-gen.ts +0 -30
- package/src/stories/beginners/remove-points/index.ts +0 -92
- package/src/stories/beginners/remove-points/style.css +0 -31
- package/src/stories/beginners.stories.ts +0 -131
- package/src/stories/clusters/polygon-selection/index.ts +0 -51
- package/src/stories/clusters/polygon-selection/polygon.ts +0 -143
- package/src/stories/clusters/polygon-selection/style.css +0 -8
- package/src/stories/clusters/radial.ts +0 -24
- package/src/stories/clusters/with-labels.ts +0 -53
- package/src/stories/clusters/worm.ts +0 -40
- package/src/stories/clusters.stories.ts +0 -77
- package/src/stories/create-cluster-labels.ts +0 -50
- package/src/stories/create-cosmos.ts +0 -68
- package/src/stories/create-story.ts +0 -51
- package/src/stories/experiments/full-mesh.ts +0 -13
- package/src/stories/experiments/mesh-with-holes.ts +0 -13
- package/src/stories/experiments.stories.ts +0 -43
- package/src/stories/generate-mesh-data.ts +0 -125
- package/src/stories/geospatial/moscow-metro-stations/index.ts +0 -62
- package/src/stories/geospatial/moscow-metro-stations/moscow-metro-coords.ts +0 -1
- package/src/stories/geospatial/moscow-metro-stations/point-colors.ts +0 -46
- package/src/stories/geospatial/moscow-metro-stations/style.css +0 -30
- package/src/stories/geospatial.stories.ts +0 -30
- package/src/stories/shapes/all-shapes/index.ts +0 -69
- package/src/stories/shapes/image-example/icons/box.png +0 -0
- package/src/stories/shapes/image-example/icons/lego.png +0 -0
- package/src/stories/shapes/image-example/icons/s.png +0 -0
- package/src/stories/shapes/image-example/icons/swift.png +0 -0
- package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
- package/src/stories/shapes/image-example/index.ts +0 -238
- package/src/stories/shapes.stories.ts +0 -37
- package/src/variables.ts +0 -68
- package/tsconfig.json +0 -41
- package/vite.config.ts +0 -54
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
// Fragment shader for rendering points with various shapes and smooth edges
|
|
2
|
-
|
|
3
|
-
#ifdef GL_ES
|
|
4
|
-
precision highp float;
|
|
5
|
-
#endif
|
|
6
|
-
|
|
7
|
-
uniform float greyoutOpacity;
|
|
8
|
-
uniform float pointOpacity;
|
|
9
|
-
uniform sampler2D imageAtlasTexture;
|
|
10
|
-
uniform bool isDarkenGreyout;
|
|
11
|
-
uniform vec4 backgroundColor;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
varying float pointShape;
|
|
15
|
-
varying float isGreyedOut;
|
|
16
|
-
varying vec4 shapeColor;
|
|
17
|
-
varying vec4 imageAtlasUV;
|
|
18
|
-
varying float shapeSize;
|
|
19
|
-
varying float imageSizeVarying;
|
|
20
|
-
varying float overallSize;
|
|
21
|
-
|
|
22
|
-
// Smoothing controls the smoothness of the point's edge
|
|
23
|
-
const float smoothing = 0.9;
|
|
24
|
-
|
|
25
|
-
// Shape constants
|
|
26
|
-
const float CIRCLE = 0.0;
|
|
27
|
-
const float SQUARE = 1.0;
|
|
28
|
-
const float TRIANGLE = 2.0;
|
|
29
|
-
const float DIAMOND = 3.0;
|
|
30
|
-
const float PENTAGON = 4.0;
|
|
31
|
-
const float HEXAGON = 5.0;
|
|
32
|
-
const float STAR = 6.0;
|
|
33
|
-
const float CROSS = 7.0;
|
|
34
|
-
const float NONE = 8.0;
|
|
35
|
-
|
|
36
|
-
// Distance functions for different shapes
|
|
37
|
-
float circleDistance(vec2 p) {
|
|
38
|
-
return dot(p, p);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Function to apply greyout logic to image colors
|
|
42
|
-
vec4 applyGreyoutToImage(vec4 imageColor) {
|
|
43
|
-
vec3 finalColor = imageColor.rgb;
|
|
44
|
-
float finalAlpha = imageColor.a;
|
|
45
|
-
|
|
46
|
-
if (isGreyedOut > 0.0) {
|
|
47
|
-
float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color)
|
|
48
|
-
|
|
49
|
-
if (isDarkenGreyout) {
|
|
50
|
-
finalColor = mix(finalColor, vec3(0.2), blendFactor);
|
|
51
|
-
} else {
|
|
52
|
-
finalColor = mix(finalColor, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return vec4(finalColor, finalAlpha);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
float squareDistance(vec2 p) {
|
|
60
|
-
vec2 d = abs(p) - vec2(0.8);
|
|
61
|
-
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
float triangleDistance(vec2 p) {
|
|
65
|
-
const float k = sqrt(3.0); // ≈1.732; slope of 60° lines for an equilateral triangle
|
|
66
|
-
p.x = abs(p.x) - 0.9; // fold the X axis and shift: brings left and right halves together
|
|
67
|
-
p.y = p.y + 0.55; // move the whole shape up slightly so it is centred vertically
|
|
68
|
-
|
|
69
|
-
// reflect points that fall outside the main triangle back inside, to reuse the same maths
|
|
70
|
-
if (p.x + k * p.y > 0.0)
|
|
71
|
-
p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;
|
|
72
|
-
|
|
73
|
-
p.x -= clamp(p.x, -1.0, 0.0); // clip any remainder on the left side
|
|
74
|
-
|
|
75
|
-
// Return signed distance: negative = inside; positive = outside
|
|
76
|
-
return -length(p) * sign(p.y);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
float diamondDistance(vec2 p) {
|
|
80
|
-
// aspect > 1 → taller diamond
|
|
81
|
-
const float aspect = 1.2;
|
|
82
|
-
return abs(p.x) + abs(p.y) / aspect - 0.8;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
float pentagonDistance(vec2 p) {
|
|
86
|
-
// Regular pentagon signed-distance (Inigo Quilez)
|
|
87
|
-
const vec3 k = vec3(0.809016994, 0.587785252, 0.726542528);
|
|
88
|
-
p.x = abs(p.x);
|
|
89
|
-
|
|
90
|
-
// Reflect across the two tilted edges ─ only if point is outside
|
|
91
|
-
p -= 2.0 * min(dot(vec2(-k.x, k.y), p), 0.0) * vec2(-k.x, k.y);
|
|
92
|
-
p -= 2.0 * min(dot(vec2( k.x, k.y), p), 0.0) * vec2( k.x, k.y);
|
|
93
|
-
|
|
94
|
-
// Clip against the top horizontal edge (keeps top point sharp)
|
|
95
|
-
p -= vec2(clamp(p.x, -k.z * k.x, k.z * k.x), k.z);
|
|
96
|
-
|
|
97
|
-
// Return signed distance (negative → inside, positive → outside)
|
|
98
|
-
return length(p) * sign(p.y);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
float hexagonDistance(vec2 p) {
|
|
102
|
-
const vec3 k = vec3(-0.866025404, 0.5, 0.577350269);
|
|
103
|
-
p = abs(p);
|
|
104
|
-
p -= 2.0 * min(dot(k.xy, p), 0.0) * k.xy;
|
|
105
|
-
p -= vec2(clamp(p.x, -k.z * 0.8, k.z * 0.8), 0.8);
|
|
106
|
-
return length(p) * sign(p.y);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
float starDistance(vec2 p) {
|
|
110
|
-
// 5-point star signed-distance function (adapted from Inigo Quilez)
|
|
111
|
-
// r – outer radius, rf – inner/outer radius ratio
|
|
112
|
-
const float r = 0.9;
|
|
113
|
-
const float rf = 0.45;
|
|
114
|
-
|
|
115
|
-
// Pre-computed rotation vectors for the star arms (36° increments)
|
|
116
|
-
const vec2 k1 = vec2(0.809016994, -0.587785252);
|
|
117
|
-
const vec2 k2 = vec2(-k1.x, k1.y);
|
|
118
|
-
|
|
119
|
-
// Fold the plane into a single arm sector
|
|
120
|
-
p.x = abs(p.x);
|
|
121
|
-
p -= 2.0 * max(dot(k1, p), 0.0) * k1;
|
|
122
|
-
p -= 2.0 * max(dot(k2, p), 0.0) * k2;
|
|
123
|
-
p.x = abs(p.x);
|
|
124
|
-
|
|
125
|
-
// Translate so the top tip of the star lies on the X-axis
|
|
126
|
-
p.y -= r;
|
|
127
|
-
|
|
128
|
-
// Vector describing the edge between an outer tip and its adjacent inner point
|
|
129
|
-
vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0.0, 1.0);
|
|
130
|
-
// Project the point onto that edge and clamp the projection to the segment
|
|
131
|
-
float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);
|
|
132
|
-
|
|
133
|
-
// Return signed distance (negative => inside, positive => outside)
|
|
134
|
-
return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
float crossDistance(vec2 p) {
|
|
138
|
-
// Signed distance function for a cross (union of two rectangles)
|
|
139
|
-
// Adapted from Inigo Quilez (https://iquilezles.org/)
|
|
140
|
-
// Each arm has half-sizes 0.3 (thickness) and 0.8 (length)
|
|
141
|
-
p = abs(p);
|
|
142
|
-
if (p.y > p.x) p = p.yx; // exploit symmetry
|
|
143
|
-
|
|
144
|
-
vec2 q = p - vec2(0.8, 0.3); // subtract half-sizes (length, thickness)
|
|
145
|
-
|
|
146
|
-
// Standard rectangle SDF, then take union of the two arms
|
|
147
|
-
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
float getShapeDistance(vec2 p, float shape) {
|
|
151
|
-
if (shape == SQUARE) return squareDistance(p);
|
|
152
|
-
else if (shape == TRIANGLE) return triangleDistance(p);
|
|
153
|
-
else if (shape == DIAMOND) return diamondDistance(p);
|
|
154
|
-
else if (shape == PENTAGON) return pentagonDistance(p);
|
|
155
|
-
else if (shape == HEXAGON) return hexagonDistance(p);
|
|
156
|
-
else if (shape == STAR) return starDistance(p);
|
|
157
|
-
else if (shape == CROSS) return crossDistance(p);
|
|
158
|
-
else return circleDistance(p); // Default to circle
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
void main() {
|
|
162
|
-
// Discard the fragment if the point is fully transparent and has no image
|
|
163
|
-
if (shapeColor.a == 0.0 && imageAtlasUV.x == -1.0) {
|
|
164
|
-
discard;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Discard the fragment if the point has no shape and no image
|
|
168
|
-
if (pointShape == NONE && imageAtlasUV.x == -1.0) {
|
|
169
|
-
discard;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Calculate coordinates within the point
|
|
173
|
-
vec2 pointCoord = 2.0 * gl_PointCoord - 1.0;
|
|
174
|
-
|
|
175
|
-
vec4 finalShapeColor = vec4(0.0);
|
|
176
|
-
vec4 finalImageColor = vec4(0.0);
|
|
177
|
-
|
|
178
|
-
// Handle shape rendering with centering logic
|
|
179
|
-
if (pointShape != NONE) {
|
|
180
|
-
// Calculate shape coordinates with centering
|
|
181
|
-
vec2 shapeCoord = pointCoord;
|
|
182
|
-
if (overallSize > shapeSize && shapeSize > 0.0) {
|
|
183
|
-
// Shape is smaller than overall size, center it
|
|
184
|
-
float scale = shapeSize / overallSize;
|
|
185
|
-
shapeCoord = pointCoord / scale;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
float opacity;
|
|
189
|
-
if (pointShape == CIRCLE) {
|
|
190
|
-
// For circles, use the original distance calculation
|
|
191
|
-
float pointCenterDistance = dot(shapeCoord, shapeCoord);
|
|
192
|
-
opacity = 1.0 - smoothstep(smoothing, 1.0, pointCenterDistance);
|
|
193
|
-
} else {
|
|
194
|
-
// For other shapes, use the shape distance function
|
|
195
|
-
float shapeDistance = getShapeDistance(shapeCoord, pointShape);
|
|
196
|
-
opacity = 1.0 - smoothstep(-0.01, 0.01, shapeDistance);
|
|
197
|
-
}
|
|
198
|
-
opacity *= shapeColor.a;
|
|
199
|
-
|
|
200
|
-
finalShapeColor = vec4(shapeColor.rgb, opacity);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Handle image rendering with centering logic
|
|
204
|
-
if (imageAtlasUV.x != -1.0) {
|
|
205
|
-
// Calculate image coordinates with centering
|
|
206
|
-
vec2 imageCoord = pointCoord;
|
|
207
|
-
if (overallSize > imageSizeVarying && imageSizeVarying > 0.0) {
|
|
208
|
-
// Image is smaller than overall size, center it
|
|
209
|
-
float scale = imageSizeVarying / overallSize;
|
|
210
|
-
imageCoord = pointCoord / scale;
|
|
211
|
-
|
|
212
|
-
// Check if we're outside the valid image area
|
|
213
|
-
if (abs(imageCoord.x) > 1.0 || abs(imageCoord.y) > 1.0) {
|
|
214
|
-
// We're outside the image bounds, don't render the image
|
|
215
|
-
finalImageColor = vec4(0.0);
|
|
216
|
-
} else {
|
|
217
|
-
// Sample from texture atlas
|
|
218
|
-
vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
|
|
219
|
-
vec4 imageColor = texture2D(imageAtlasTexture, atlasUV);
|
|
220
|
-
finalImageColor = applyGreyoutToImage(imageColor);
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
// Image is same size or larger than overall size, no scaling needed
|
|
224
|
-
// Sample from texture atlas
|
|
225
|
-
vec2 atlasUV = mix(imageAtlasUV.xy, imageAtlasUV.zw, (imageCoord + 1.0) * 0.5);
|
|
226
|
-
vec4 imageColor = texture2D(imageAtlasTexture, atlasUV);
|
|
227
|
-
finalImageColor = applyGreyoutToImage(imageColor);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
float finalPointAlpha = max(finalShapeColor.a, finalImageColor.a);
|
|
232
|
-
if (isGreyedOut > 0.0 && greyoutOpacity != -1.0) {
|
|
233
|
-
finalPointAlpha *= greyoutOpacity;
|
|
234
|
-
} else {
|
|
235
|
-
finalPointAlpha *= pointOpacity;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Blend image color above point color
|
|
239
|
-
gl_FragColor = vec4(
|
|
240
|
-
mix(finalShapeColor.rgb, finalImageColor.rgb, finalImageColor.a),
|
|
241
|
-
finalPointAlpha
|
|
242
|
-
);
|
|
243
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#ifdef GL_ES
|
|
2
|
-
precision highp float;
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
attribute vec2 pointIndices;
|
|
6
|
-
attribute float size;
|
|
7
|
-
attribute vec4 color;
|
|
8
|
-
attribute float shape;
|
|
9
|
-
attribute float imageIndex;
|
|
10
|
-
attribute float imageSize;
|
|
11
|
-
|
|
12
|
-
uniform sampler2D positionsTexture;
|
|
13
|
-
uniform sampler2D pointGreyoutStatus;
|
|
14
|
-
uniform sampler2D imageAtlasCoords;
|
|
15
|
-
uniform float ratio;
|
|
16
|
-
uniform mat3 transformationMatrix;
|
|
17
|
-
uniform float pointsTextureSize;
|
|
18
|
-
uniform float sizeScale;
|
|
19
|
-
uniform float spaceSize;
|
|
20
|
-
uniform vec2 screenSize;
|
|
21
|
-
|
|
22
|
-
uniform vec4 greyoutColor;
|
|
23
|
-
uniform vec4 backgroundColor;
|
|
24
|
-
uniform bool scalePointsOnZoom;
|
|
25
|
-
uniform float maxPointSize;
|
|
26
|
-
uniform bool isDarkenGreyout;
|
|
27
|
-
uniform bool skipSelected;
|
|
28
|
-
uniform bool skipUnselected;
|
|
29
|
-
uniform bool hasImages;
|
|
30
|
-
uniform float imageCount;
|
|
31
|
-
uniform float imageAtlasCoordsTextureSize;
|
|
32
|
-
|
|
33
|
-
varying float pointShape;
|
|
34
|
-
varying float isGreyedOut;
|
|
35
|
-
varying vec4 shapeColor;
|
|
36
|
-
varying vec4 imageAtlasUV;
|
|
37
|
-
varying float shapeSize;
|
|
38
|
-
varying float imageSizeVarying;
|
|
39
|
-
varying float overallSize;
|
|
40
|
-
|
|
41
|
-
float calculatePointSize(float size) {
|
|
42
|
-
float pSize;
|
|
43
|
-
if (scalePointsOnZoom) {
|
|
44
|
-
pSize = size * ratio * transformationMatrix[0][0];
|
|
45
|
-
} else {
|
|
46
|
-
pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return min(pSize, maxPointSize * ratio);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
void main() {
|
|
53
|
-
// Check greyout status for selective rendering
|
|
54
|
-
vec4 greyoutStatus = texture2D(pointGreyoutStatus, (pointIndices + 0.5) / pointsTextureSize);
|
|
55
|
-
isGreyedOut = greyoutStatus.r;
|
|
56
|
-
bool isSelected = greyoutStatus.r == 0.0;
|
|
57
|
-
|
|
58
|
-
// Discard point based on rendering mode
|
|
59
|
-
if (skipSelected && isSelected) {
|
|
60
|
-
gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Move off-screen
|
|
61
|
-
gl_PointSize = 0.0;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (skipUnselected && !isSelected) {
|
|
65
|
-
gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Move off-screen
|
|
66
|
-
gl_PointSize = 0.0;
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Position
|
|
71
|
-
vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
|
|
72
|
-
vec2 point = pointPosition.rg;
|
|
73
|
-
|
|
74
|
-
// Transform point position to normalized device coordinates
|
|
75
|
-
vec2 normalizedPosition = 2.0 * point / spaceSize - 1.0;
|
|
76
|
-
normalizedPosition *= spaceSize / screenSize;
|
|
77
|
-
vec3 finalPosition = transformationMatrix * vec3(normalizedPosition, 1);
|
|
78
|
-
gl_Position = vec4(finalPosition.rg, 0, 1);
|
|
79
|
-
|
|
80
|
-
// Calculate sizes for shape and image
|
|
81
|
-
float shapeSizeValue = calculatePointSize(size * sizeScale);
|
|
82
|
-
float imageSizeValue = calculatePointSize(imageSize * sizeScale);
|
|
83
|
-
|
|
84
|
-
// Use the larger of the two sizes for the overall point size
|
|
85
|
-
float overallSizeValue = max(shapeSizeValue, imageSizeValue);
|
|
86
|
-
gl_PointSize = overallSizeValue;
|
|
87
|
-
|
|
88
|
-
// Pass size information to fragment shader
|
|
89
|
-
shapeSize = shapeSizeValue;
|
|
90
|
-
imageSizeVarying = imageSizeValue;
|
|
91
|
-
overallSize = overallSizeValue;
|
|
92
|
-
|
|
93
|
-
shapeColor = color;
|
|
94
|
-
pointShape = shape;
|
|
95
|
-
|
|
96
|
-
// Adjust alpha of selected points
|
|
97
|
-
if (isGreyedOut > 0.0) {
|
|
98
|
-
if (greyoutColor[0] != -1.0) {
|
|
99
|
-
shapeColor = greyoutColor;
|
|
100
|
-
} else {
|
|
101
|
-
// If greyoutColor is not set, make color lighter or darker based on isDarkenGreyout
|
|
102
|
-
float blendFactor = 0.65; // Controls how much to modify (0.0 = original, 1.0 = target color)
|
|
103
|
-
|
|
104
|
-
if (isDarkenGreyout) {
|
|
105
|
-
// Darken the color
|
|
106
|
-
shapeColor.rgb = mix(shapeColor.rgb, vec3(0.2), blendFactor);
|
|
107
|
-
} else {
|
|
108
|
-
// Lighten the color
|
|
109
|
-
shapeColor.rgb = mix(shapeColor.rgb, max(backgroundColor.rgb, vec3(0.8)), blendFactor);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!hasImages || imageIndex < 0.0 || imageIndex >= imageCount) {
|
|
115
|
-
imageAtlasUV = vec4(-1.0);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
// Calculate image atlas UV coordinates based on imageIndex
|
|
119
|
-
float atlasCoordIndex = imageIndex;
|
|
120
|
-
// Calculate the position in the texture grid
|
|
121
|
-
float texX = mod(atlasCoordIndex, imageAtlasCoordsTextureSize);
|
|
122
|
-
float texY = floor(atlasCoordIndex / imageAtlasCoordsTextureSize);
|
|
123
|
-
// Convert to texture coordinates (0.0 to 1.0)
|
|
124
|
-
vec2 atlasCoordTexCoord = (vec2(texX, texY) + 0.5) / imageAtlasCoordsTextureSize;
|
|
125
|
-
vec4 atlasCoords = texture2D(imageAtlasCoords, atlasCoordTexCoord);
|
|
126
|
-
imageAtlasUV = atlasCoords;
|
|
127
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#ifdef GL_ES
|
|
2
|
-
precision highp float;
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
uniform sampler2D positionsTexture;
|
|
6
|
-
uniform float pointsTextureSize;
|
|
7
|
-
uniform float spaceSize;
|
|
8
|
-
uniform vec2 screenSize;
|
|
9
|
-
uniform mat3 transformationMatrix;
|
|
10
|
-
|
|
11
|
-
attribute vec2 pointIndices;
|
|
12
|
-
|
|
13
|
-
varying vec4 rgba;
|
|
14
|
-
|
|
15
|
-
void main() {
|
|
16
|
-
vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
|
|
17
|
-
vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
|
|
18
|
-
p *= spaceSize / screenSize;
|
|
19
|
-
vec3 final = transformationMatrix * vec3(p, 1);
|
|
20
|
-
|
|
21
|
-
vec2 pointScreenPosition = (final.xy + 1.0) * screenSize / 2.0;
|
|
22
|
-
float index = pointIndices.g * pointsTextureSize + pointIndices.r;
|
|
23
|
-
rgba = vec4(index, 1.0, pointPosition.xy);
|
|
24
|
-
float i = (pointScreenPosition.x + 0.5) / screenSize.x;
|
|
25
|
-
float j = (pointScreenPosition.y + 0.5) / screenSize.y;
|
|
26
|
-
gl_Position = vec4(2.0 * vec2(i, j) - 1.0, 0.0, 1.0);
|
|
27
|
-
|
|
28
|
-
gl_PointSize = 1.0;
|
|
29
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#ifdef GL_ES
|
|
2
|
-
precision highp float;
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
attribute float size;
|
|
6
|
-
|
|
7
|
-
uniform sampler2D positionsTexture;
|
|
8
|
-
uniform float pointsTextureSize;
|
|
9
|
-
uniform float sizeScale;
|
|
10
|
-
uniform float spaceSize;
|
|
11
|
-
uniform vec2 screenSize;
|
|
12
|
-
uniform float ratio;
|
|
13
|
-
uniform mat3 transformationMatrix;
|
|
14
|
-
uniform vec2 mousePosition;
|
|
15
|
-
uniform bool scalePointsOnZoom;
|
|
16
|
-
uniform float maxPointSize;
|
|
17
|
-
|
|
18
|
-
attribute vec2 pointIndices;
|
|
19
|
-
|
|
20
|
-
varying vec4 rgba;
|
|
21
|
-
|
|
22
|
-
float calculatePointSize(float size) {
|
|
23
|
-
float pSize;
|
|
24
|
-
if (scalePointsOnZoom) {
|
|
25
|
-
pSize = size * ratio * transformationMatrix[0][0];
|
|
26
|
-
} else {
|
|
27
|
-
pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
|
|
28
|
-
}
|
|
29
|
-
return min(pSize, maxPointSize * ratio);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
float euclideanDistance (float x1, float x2, float y1, float y2) {
|
|
33
|
-
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
void main() {
|
|
37
|
-
vec4 pointPosition = texture2D(positionsTexture, (pointIndices + 0.5) / pointsTextureSize);
|
|
38
|
-
|
|
39
|
-
// Transform point position to normalized device coordinates
|
|
40
|
-
vec2 normalizedPoint = 2.0 * pointPosition.rg / spaceSize - 1.0;
|
|
41
|
-
normalizedPoint *= spaceSize / screenSize;
|
|
42
|
-
vec3 finalPosition = transformationMatrix * vec3(normalizedPoint, 1);
|
|
43
|
-
|
|
44
|
-
float pointRadius = 0.5 * calculatePointSize(size * sizeScale);
|
|
45
|
-
|
|
46
|
-
vec2 pointScreenPosition = (finalPosition.xy + 1.0) * screenSize / 2.0;
|
|
47
|
-
rgba = vec4(0.0);
|
|
48
|
-
gl_Position = vec4(0.5, 0.5, 0.0, 1.0);
|
|
49
|
-
// Check if the mouse is within the point radius
|
|
50
|
-
if (euclideanDistance(pointScreenPosition.x, mousePosition.x, pointScreenPosition.y, mousePosition.y) < pointRadius / ratio) {
|
|
51
|
-
float index = pointIndices.g * pointsTextureSize + pointIndices.r;
|
|
52
|
-
rgba = vec4(index, size, pointPosition.xy);
|
|
53
|
-
gl_Position = vec4(-0.5, -0.5, 0.0, 1.0);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
gl_PointSize = 1.0;
|
|
57
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#ifdef GL_ES
|
|
2
|
-
precision highp float;
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
uniform sampler2D positionsTexture;
|
|
6
|
-
uniform sampler2D pointSize;
|
|
7
|
-
uniform float sizeScale;
|
|
8
|
-
uniform float spaceSize;
|
|
9
|
-
uniform vec2 screenSize;
|
|
10
|
-
uniform float ratio;
|
|
11
|
-
uniform mat3 transformationMatrix;
|
|
12
|
-
uniform vec2 selection0;
|
|
13
|
-
uniform vec2 selection1;
|
|
14
|
-
uniform bool scalePointsOnZoom;
|
|
15
|
-
uniform float maxPointSize;
|
|
16
|
-
|
|
17
|
-
varying vec2 textureCoords;
|
|
18
|
-
|
|
19
|
-
float pointSizeF(float size) {
|
|
20
|
-
float pSize;
|
|
21
|
-
if (scalePointsOnZoom) {
|
|
22
|
-
pSize = size * ratio * transformationMatrix[0][0];
|
|
23
|
-
} else {
|
|
24
|
-
pSize = size * ratio * min(5.0, max(1.0, transformationMatrix[0][0] * 0.01));
|
|
25
|
-
}
|
|
26
|
-
return min(pSize, maxPointSize * ratio);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
void main() {
|
|
30
|
-
vec4 pointPosition = texture2D(positionsTexture, textureCoords);
|
|
31
|
-
vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
|
|
32
|
-
p *= spaceSize / screenSize;
|
|
33
|
-
vec3 final = transformationMatrix * vec3(p, 1);
|
|
34
|
-
|
|
35
|
-
vec4 pSize = texture2D(pointSize, textureCoords);
|
|
36
|
-
float size = pSize.r * sizeScale;
|
|
37
|
-
|
|
38
|
-
float left = 2.0 * (selection0.x - 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
|
|
39
|
-
float right = 2.0 * (selection1.x + 0.5 * pointSizeF(size)) / screenSize.x - 1.0;
|
|
40
|
-
float top = 2.0 * (selection0.y - 0.5 * pointSizeF(size)) / screenSize.y - 1.0;
|
|
41
|
-
float bottom = 2.0 * (selection1.y + 0.5 * pointSizeF(size)) / screenSize.y - 1.0;
|
|
42
|
-
|
|
43
|
-
gl_FragColor = vec4(0.0, 0.0, pointPosition.rg);
|
|
44
|
-
if (final.x >= left && final.x <= right && final.y >= top && final.y <= bottom) {
|
|
45
|
-
gl_FragColor.r = 1.0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#ifdef GL_ES
|
|
2
|
-
precision highp float;
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
uniform sampler2D positionsTexture;
|
|
6
|
-
uniform sampler2D polygonPathTexture; // Texture containing polygon path points
|
|
7
|
-
uniform int polygonPathLength;
|
|
8
|
-
uniform float spaceSize;
|
|
9
|
-
uniform vec2 screenSize;
|
|
10
|
-
uniform mat3 transformationMatrix;
|
|
11
|
-
|
|
12
|
-
varying vec2 textureCoords;
|
|
13
|
-
|
|
14
|
-
// Get a point from the polygon path texture at a specific index
|
|
15
|
-
vec2 getPolygonPoint(sampler2D pathTexture, int index, int pathLength) {
|
|
16
|
-
if (index >= pathLength) return vec2(0.0);
|
|
17
|
-
|
|
18
|
-
// Calculate texture coordinates for the index
|
|
19
|
-
int textureSize = int(ceil(sqrt(float(pathLength))));
|
|
20
|
-
int x = index - (index / textureSize) * textureSize;
|
|
21
|
-
int y = index / textureSize;
|
|
22
|
-
|
|
23
|
-
vec2 texCoord = (vec2(float(x), float(y)) + 0.5) / float(textureSize);
|
|
24
|
-
vec4 pathData = texture2D(pathTexture, texCoord);
|
|
25
|
-
|
|
26
|
-
return pathData.xy;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Point-in-polygon algorithm using ray casting
|
|
30
|
-
bool pointInPolygon(vec2 point, sampler2D pathTexture, int pathLength) {
|
|
31
|
-
bool inside = false;
|
|
32
|
-
|
|
33
|
-
for (int i = 0; i < 2048; i++) {
|
|
34
|
-
if (i >= pathLength) break;
|
|
35
|
-
|
|
36
|
-
int j = int(mod(float(i + 1), float(pathLength)));
|
|
37
|
-
|
|
38
|
-
vec2 pi = getPolygonPoint(pathTexture, i, pathLength);
|
|
39
|
-
vec2 pj = getPolygonPoint(pathTexture, j, pathLength);
|
|
40
|
-
|
|
41
|
-
if (((pi.y > point.y) != (pj.y > point.y)) &&
|
|
42
|
-
(point.x < (pj.x - pi.x) * (point.y - pi.y) / (pj.y - pi.y) + pi.x)) {
|
|
43
|
-
inside = !inside;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return inside;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
void main() {
|
|
51
|
-
vec4 pointPosition = texture2D(positionsTexture, textureCoords);
|
|
52
|
-
vec2 p = 2.0 * pointPosition.rg / spaceSize - 1.0;
|
|
53
|
-
p *= spaceSize / screenSize;
|
|
54
|
-
vec3 final = transformationMatrix * vec3(p, 1);
|
|
55
|
-
|
|
56
|
-
// Convert to screen coordinates for polygon check
|
|
57
|
-
vec2 screenPos = (final.xy + 1.0) * screenSize / 2.0;
|
|
58
|
-
|
|
59
|
-
gl_FragColor = vec4(0.0, 0.0, pointPosition.rg);
|
|
60
|
-
|
|
61
|
-
// Check if point center is inside the polygon
|
|
62
|
-
if (pointInPolygon(screenPos, polygonPathTexture, polygonPathLength)) {
|
|
63
|
-
gl_FragColor.r = 1.0;
|
|
64
|
-
}
|
|
65
|
-
}
|