@cosmos.gl/graph 2.0.0 → 2.2.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.
Files changed (32) hide show
  1. package/dist/config.d.ts +15 -1
  2. package/dist/index.d.ts +12 -0
  3. package/dist/index.js +2825 -2635
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js +165 -54
  6. package/dist/index.min.js.map +1 -1
  7. package/dist/modules/Points/index.d.ts +6 -0
  8. package/dist/stories/clusters/lasso-selection/index.d.ts +6 -0
  9. package/dist/stories/clusters/lasso-selection/lasso.d.ts +20 -0
  10. package/dist/stories/clusters.stories.d.ts +1 -0
  11. package/dist/variables.d.ts +2 -0
  12. package/package.json +1 -1
  13. package/src/config.ts +15 -1
  14. package/src/index.ts +104 -5
  15. package/src/modules/Lines/draw-curve-line.frag +7 -8
  16. package/src/modules/Lines/draw-curve-line.vert +65 -15
  17. package/src/modules/Lines/index.ts +2 -3
  18. package/src/modules/Points/find-points-on-lasso-selection.frag +65 -0
  19. package/src/modules/Points/index.ts +69 -0
  20. package/src/stories/2. configuration.mdx +3 -1
  21. package/src/stories/3. api-reference.mdx +19 -0
  22. package/src/stories/beginners/basic-set-up/index.ts +2 -1
  23. package/src/stories/beginners/point-labels/index.ts +2 -1
  24. package/src/stories/beginners/quick-start.ts +1 -0
  25. package/src/stories/beginners/remove-points/config.ts +2 -1
  26. package/src/stories/clusters/lasso-selection/index.ts +53 -0
  27. package/src/stories/clusters/lasso-selection/lasso.ts +143 -0
  28. package/src/stories/clusters/lasso-selection/style.css +8 -0
  29. package/src/stories/clusters.stories.ts +16 -0
  30. package/src/stories/create-cosmos.ts +2 -1
  31. package/src/stories/generate-mesh-data.ts +1 -1
  32. package/src/variables.ts +3 -1
package/dist/config.d.ts CHANGED
@@ -118,6 +118,11 @@ export interface GraphConfigInterface {
118
118
  * Default value: `1`
119
119
  */
120
120
  linkWidthScale?: number;
121
+ /**
122
+ * Increase or decrease the size of the links when zooming in or out.
123
+ * Default value: `false`
124
+ */
125
+ scaleLinksOnZoom?: boolean;
121
126
  /**
122
127
  * If set to true, links are rendered as curved lines.
123
128
  * Otherwise as straight lines.
@@ -226,6 +231,13 @@ export interface GraphConfigInterface {
226
231
  * Default value: `2`
227
232
  */
228
233
  simulationRepulsionFromMouse?: number;
234
+ /**
235
+ * Enable or disable the repulsion force from mouse when right-clicking.
236
+ * When set to `true`, holding the right mouse button will activate the mouse repulsion force.
237
+ * When set to `false`, right-clicking will not trigger any repulsion force.
238
+ * Default value: `false`
239
+ */
240
+ enableRightClickRepulsion?: boolean;
229
241
  /**
230
242
  * Friction coefficient.
231
243
  * Values range from 0 (high friction, stops quickly) to 1 (no friction, keeps moving).
@@ -357,7 +369,7 @@ export interface GraphConfigInterface {
357
369
  pixelRatio?: number;
358
370
  /**
359
371
  * Increase or decrease the size of the points when zooming in or out.
360
- * Default value: true
372
+ * Default value: `false`
361
373
  */
362
374
  scalePointsOnZoom?: boolean;
363
375
  /**
@@ -473,6 +485,7 @@ export declare class GraphConfig implements GraphConfigInterface {
473
485
  curvedLinkControlPointDistance: number;
474
486
  linkArrows: boolean;
475
487
  linkArrowsSizeScale: number;
488
+ scaleLinksOnZoom: boolean;
476
489
  linkVisibilityDistanceRange: number[];
477
490
  linkVisibilityMinTransparency: number;
478
491
  useClassicQuadtree: boolean;
@@ -486,6 +499,7 @@ export declare class GraphConfig implements GraphConfigInterface {
486
499
  simulationLinkDistance: number;
487
500
  simulationLinkDistRandomVariationRange: number[];
488
501
  simulationRepulsionFromMouse: number;
502
+ enableRightClickRepulsion: boolean;
489
503
  simulationFriction: number;
490
504
  simulationCluster: number;
491
505
  onSimulationStart: GraphConfigInterface['onSimulationStart'];
package/dist/index.d.ts CHANGED
@@ -239,11 +239,23 @@ export declare class Graph {
239
239
  * @returns A Float32Array containing the indices of points inside a rectangular area.
240
240
  */
241
241
  getPointsInRange(selection: [[number, number], [number, number]]): Float32Array;
242
+ /**
243
+ * Get points indices inside a lasso (polygon) area.
244
+ * @param lassoPath - Array of points `[[x1, y1], [x2, y2], ..., [xn, yn]]` that defines the lasso polygon.
245
+ * The coordinates should be from 0 to the width/height of the canvas.
246
+ * @returns A Float32Array containing the indices of points inside the lasso area.
247
+ */
248
+ getPointsInLasso(lassoPath: [number, number][]): Float32Array;
242
249
  /** Select points inside a rectangular area.
243
250
  * @param selection - Array of two corner points `[[left, top], [right, bottom]]`.
244
251
  * The `left` and `right` coordinates should be from 0 to the width of the canvas.
245
252
  * The `top` and `bottom` coordinates should be from 0 to the height of the canvas. */
246
253
  selectPointsInRange(selection: [[number, number], [number, number]] | null): void;
254
+ /** Select points inside a lasso (polygon) area.
255
+ * @param lassoPath - Array of points `[[x1, y1], [x2, y2], ..., [xn, yn]]` that defines the lasso polygon.
256
+ * The coordinates should be from 0 to the width/height of the canvas.
257
+ * Set to null to clear selection. */
258
+ selectPointsInLasso(lassoPath: [number, number][] | null): void;
247
259
  /**
248
260
  * Select a point by index. If you want the adjacent points to get selected too, provide `true` as the second argument.
249
261
  * @param index The index of the point in the array of points.