@cosmos.gl/graph 2.2.0 → 2.3.0-beta.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/README.md +7 -7
- package/dist/config.d.ts +16 -0
- package/dist/index.d.ts +68 -7
- package/dist/index.js +1989 -1880
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +64 -55
- package/dist/index.min.js.map +1 -1
- package/dist/modules/Points/index.d.ts +11 -6
- package/dist/stories/clusters/{lasso-selection → polygon-selection}/index.d.ts +1 -1
- package/dist/stories/clusters/{lasso-selection/lasso.d.ts → polygon-selection/polygon.d.ts} +5 -5
- package/dist/stories/clusters.stories.d.ts +1 -1
- package/dist/variables.d.ts +2 -0
- package/package.json +1 -1
- package/src/config.ts +21 -0
- package/src/index.ts +115 -22
- package/src/modules/Lines/draw-curve-line.frag +2 -1
- package/src/modules/Lines/draw-curve-line.vert +9 -3
- package/src/modules/Lines/index.ts +1 -0
- package/src/modules/Points/draw-highlighted.vert +2 -1
- package/src/modules/Points/draw-points.vert +2 -1
- package/src/modules/Points/{find-points-on-lasso-selection.frag → find-points-on-polygon-selection.frag} +8 -8
- package/src/modules/Points/index.ts +68 -25
- package/src/stories/2. configuration.mdx +2 -0
- package/src/stories/3. api-reference.mdx +82 -27
- package/src/stories/beginners/basic-set-up/index.ts +1 -1
- package/src/stories/clusters/{lasso-selection → polygon-selection}/index.ts +11 -11
- package/src/stories/clusters/{lasso-selection/lasso.ts → polygon-selection/polygon.ts} +16 -16
- package/src/stories/clusters/{lasso-selection → polygon-selection}/style.css +1 -1
- package/src/stories/clusters/worm.ts +22 -1
- package/src/stories/clusters.stories.ts +9 -9
- package/src/variables.ts +2 -0
|
@@ -6,7 +6,7 @@ import { generateMeshData } from '../generate-mesh-data'
|
|
|
6
6
|
export const worm = (): {graph: Graph; div: HTMLDivElement} => {
|
|
7
7
|
const { pointPositions, pointColors, links, linkColors, pointClusters } = generateMeshData(100, 100, 1000, 1.0)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const { div, graph } = createCosmos({
|
|
10
10
|
simulationGravity: 0.5,
|
|
11
11
|
simulationRepulsion: 1,
|
|
12
12
|
simulationLinkSpring: 1,
|
|
@@ -15,5 +15,26 @@ export const worm = (): {graph: Graph; div: HTMLDivElement} => {
|
|
|
15
15
|
pointClusters,
|
|
16
16
|
links,
|
|
17
17
|
linkColors,
|
|
18
|
+
onSimulationTick: () => {
|
|
19
|
+
const currentPointColors = graph.getPointColors()
|
|
20
|
+
const newPointColors = new Float32Array(currentPointColors.length)
|
|
21
|
+
for (let i = 0; i < currentPointColors.length / 4; i++) {
|
|
22
|
+
if (i === 0) {
|
|
23
|
+
newPointColors[i * 4] = currentPointColors[currentPointColors.length - 4] as number
|
|
24
|
+
newPointColors[i * 4 + 1] = currentPointColors[currentPointColors.length - 3] as number
|
|
25
|
+
newPointColors[i * 4 + 2] = currentPointColors[currentPointColors.length - 2] as number
|
|
26
|
+
newPointColors[i * 4 + 3] = currentPointColors[currentPointColors.length - 1] as number
|
|
27
|
+
} else {
|
|
28
|
+
newPointColors[i * 4] = currentPointColors[(i - 1) * 4] as number
|
|
29
|
+
newPointColors[i * 4 + 1] = currentPointColors[(i - 1) * 4 + 1] as number
|
|
30
|
+
newPointColors[i * 4 + 2] = currentPointColors[(i - 1) * 4 + 2] as number
|
|
31
|
+
newPointColors[i * 4 + 3] = currentPointColors[(i - 1) * 4 + 3] as number
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
graph.setPointColors(newPointColors)
|
|
35
|
+
graph.render()
|
|
36
|
+
},
|
|
18
37
|
})
|
|
38
|
+
|
|
39
|
+
return { div, graph }
|
|
19
40
|
}
|
|
@@ -4,7 +4,7 @@ import { createStory, Story } from '@/graph/stories/create-story'
|
|
|
4
4
|
import { withLabels } from './clusters/with-labels'
|
|
5
5
|
import { worm } from './clusters/worm'
|
|
6
6
|
import { radial } from './clusters/radial'
|
|
7
|
-
import {
|
|
7
|
+
import { polygonSelection } from './clusters/polygon-selection'
|
|
8
8
|
|
|
9
9
|
import createCosmosRaw from './create-cosmos?raw'
|
|
10
10
|
import generateMeshDataRaw from './generate-mesh-data?raw'
|
|
@@ -12,9 +12,9 @@ import withLabelsStoryRaw from './clusters/with-labels?raw'
|
|
|
12
12
|
import createClusterLabelsRaw from './create-cluster-labels?raw'
|
|
13
13
|
import wormStory from './clusters/worm?raw'
|
|
14
14
|
import radialStory from './clusters/radial?raw'
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
15
|
+
import polygonSelectionStory from './clusters/polygon-selection?raw'
|
|
16
|
+
import polygonSelectionStyleRaw from './clusters/polygon-selection/style.css?raw'
|
|
17
|
+
import polygonSelectionPolygonRaw from './clusters/polygon-selection/polygon.ts?raw'
|
|
18
18
|
|
|
19
19
|
const meta: Meta<CosmosStoryProps> = {
|
|
20
20
|
title: 'Examples/Clusters',
|
|
@@ -61,14 +61,14 @@ export const WithLabels: Story = {
|
|
|
61
61
|
},
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const
|
|
65
|
-
...createStory(
|
|
64
|
+
export const PolygonSelection: Story = {
|
|
65
|
+
...createStory(polygonSelection),
|
|
66
66
|
parameters: {
|
|
67
67
|
sourceCode: [
|
|
68
|
-
{ name: 'Story', code:
|
|
69
|
-
{ name: '
|
|
68
|
+
{ name: 'Story', code: polygonSelectionStory },
|
|
69
|
+
{ name: 'polygon.ts', code: polygonSelectionPolygonRaw },
|
|
70
70
|
...sourceCodeAddonParams,
|
|
71
|
-
{ name: 'style.css', code:
|
|
71
|
+
{ name: 'style.css', code: polygonSelectionStyleRaw },
|
|
72
72
|
],
|
|
73
73
|
},
|
|
74
74
|
}
|
package/src/variables.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export const defaultPointColor = '#b3b3b3'
|
|
2
2
|
export const defaultGreyoutPointOpacity = undefined
|
|
3
3
|
export const defaultGreyoutPointColor = undefined
|
|
4
|
+
export const defaultPointOpacity = 1.0
|
|
4
5
|
export const defaultPointSize = 4
|
|
5
6
|
export const defaultLinkColor = '#666666'
|
|
6
7
|
export const defaultGreyoutLinkOpacity = 0.1
|
|
8
|
+
export const defaultLinkOpacity = 1.0
|
|
7
9
|
export const defaultLinkWidth = 1
|
|
8
10
|
export const defaultBackgroundColor = '#222222'
|
|
9
11
|
|