@neo4j-nvl/base 1.2.0-d88ba7c2 → 1.2.0-dbc13ec2

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 (60) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/base.mjs +1 -1
  4. package/dist/types/index.d.ts +6 -5
  5. package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +2 -2
  6. package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +2 -2
  7. package/dist/types/layouts/forcedirectedlayout/{physlayout/PhysLayout.d.ts → PhysLayout.d.ts} +106 -26
  8. package/dist/types/layouts/forcedirectedlayout/clustering/ClusterByMerger.d.ts +61 -0
  9. package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.d.ts +56 -0
  10. package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.d.ts +143 -0
  11. package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.test.d.ts +1 -0
  12. package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger → clustering}/types.d.ts +11 -1
  13. package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-fragment.d.ts +2 -0
  14. package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
  15. package/dist/types/layouts/freeLayout/FreeLayout.d.ts +2 -4
  16. package/dist/types/layouts/gridLayout/GridLayout.d.ts +2 -6
  17. package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +5 -0
  18. package/dist/types/modules/NvlController.d.ts +72 -4
  19. package/dist/types/modules/dataset.d.ts +1 -0
  20. package/dist/types/modules/state/types.d.ts +90 -19
  21. package/dist/types/modules/state/utils.d.ts +2 -2
  22. package/dist/types/renderers/ClusterOverlay.d.ts +80 -0
  23. package/dist/types/renderers/ClusterOverlay.test.d.ts +1 -0
  24. package/dist/types/renderers/domrenderer/canvasrenderer/arrowDrawing.d.ts +2 -16
  25. package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +1 -0
  26. package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +4 -6
  27. package/dist/types/renderers/webglrenderer/Controller.d.ts +27 -6
  28. package/dist/types/renderers/webglrenderer/IconLayerRegistry.d.ts +14 -0
  29. package/dist/types/renderers/webglrenderer/IconLayerRegistry.test.d.ts +1 -0
  30. package/dist/types/renderers/webglrenderer/Renderer.d.ts +43 -2
  31. package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
  32. package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
  33. package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
  34. package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
  35. package/dist/types/renderers/webglrenderer/rel-glsl-utils.d.ts +1 -0
  36. package/dist/types/renderers/webglrenderer/rel-vertex-arrow.d.ts +2 -0
  37. package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
  38. package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
  39. package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
  40. package/dist/types/types/graph-element.d.ts +9 -1
  41. package/dist/types/types/nvl-window-functions.d.ts +2 -2
  42. package/dist/types/utils/clusterGeometry.d.ts +14 -0
  43. package/dist/types/utils/clusterGeometry.test.d.ts +1 -0
  44. package/dist/types/utils/geometry.d.ts +29 -0
  45. package/dist/types/utils/webWorkerUtils.d.ts +1 -1
  46. package/dist/types/utils/zoomFunctions.d.ts +9 -2
  47. package/package.json +5 -5
  48. package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +0 -22
  49. package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +0 -33
  50. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +0 -2
  51. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +0 -2
  52. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +0 -21
  53. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +0 -2
  54. /package/dist/types/layouts/forcedirectedlayout/{physlayout/PhysLayout.test.d.ts → PhysLayout.test.d.ts} +0 -0
  55. /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/SolarMerger.bench.d.ts → clustering/ClusterByMerger.test.d.ts} +0 -0
  56. /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/SolarMerger.test.d.ts → clustering/SolarMerger.bench.d.ts} +0 -0
  57. /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/solar-placer.test.d.ts → clustering/SolarMerger.test.d.ts} +0 -0
  58. /package/dist/types/layouts/forcedirectedlayout/{physlayout/glwrapper.d.ts → glwrapper.d.ts} +0 -0
  59. /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/multilevel-update-fragment.d.ts +0 -0
  60. /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/sim-vertex.d.ts +0 -0
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nprecision lowp float;\n\nuniform mediump float u_zoom;\nuniform lowp float u_animPos;\nuniform mediump float u_glAdjust;\n\nin lowp vec4 color;\nin lowp float varNodeSize;\n\nout vec4 fragColor;\n\nmediump float circleSize = 0.50;\n\nvoid main(void) {\n\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float alpha = 1.0 - smoothstep(circleSize - (1.0 / (varNodeSize * 2.0 * u_zoom * u_glAdjust)), circleSize, dist);\n lowp float pulseAlpha = 0.9 - 0.9 * u_animPos;\n fragColor = vec4(color.xyz, 1.0) * alpha * pulseAlpha;\n }\n}\n";
1
+ declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform mediump float u_zoom;\nuniform lowp float u_animPos;\nuniform mediump float u_glAdjust;\n\nin lowp vec4 color;\nin mediump float varNodeSize;\n\nout vec4 fragColor;\n\nconst float pulseCircleEdge = 0.50;\n\nvoid main(void) {\n float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n } else {\n float alpha = 1.0 - smoothstep(pulseCircleEdge - (1.0 / (varNodeSize * 2.0 * u_zoom * u_glAdjust)), pulseCircleEdge, dist);\n float pulseAlpha = 0.9 - 0.9 * u_animPos;\n fragColor = vec4(color.xyz, 1.0) * alpha * pulseAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform lowp float u_animPos;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin float a_size;\nin lowp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_active;\n\nout lowp float varNodeSize;\nout lowp vec4 color;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = a_size * u_zoom * u_glAdjust;\n nodeSize = nodeSize * (0.4 / 0.5); // Remove extra space added for shadow and selection ring\n\n gl_PointSize = a_active > 0.5\n ? nodeSize + 0.88 * nodeSize * u_animPos\n : 0.0;\n\n color = a_color;\n varNodeSize = a_size;\n}";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform lowp float u_animPos;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin float a_size;\nin highp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_active;\n\nout mediump float varNodeSize;\nout lowp vec4 color;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = a_size * u_zoom * u_glAdjust;\n nodeSize = nodeSize * 0.8;\n\n gl_PointSize = a_active > 0.5\n ? nodeSize + 0.88 * nodeSize * u_animPos\n : 0.0;\n\n color = a_color;\n varNodeSize = a_size;\n}";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nprecision lowp float;\n\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin lowp vec4 color;\nin lowp float drawDefaultBorder;\nin lowp vec3 nodeBorderColor;\nin lowp vec3 selectedBorderColor;\nin lowp vec3 selectedInnerBorderColor;\nin lowp vec3 shadowColor;\nin lowp float selected;\nin lowp float hovered;\nin lowp float varNodeSize;\n\nout vec4 fragColor;\n\nmediump float circleSize = 0.40;\nmediump float defaultBoderSize = 0.42;\nmediump float innerSelectedRingSize = 0.43;\nmediump float outerSelectedRingSize = 0.47;\nmediump float shadowSize = 0.51;\n\nlowp float getShadowAlpha(lowp float size, lowp float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nlowp float getCircleAlpha(lowp float ringSize, lowp float nodeSize, lowp float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n lowp float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n }\n else {\n lowp float nodeSize = 1.0 / varNodeSize;\n lowp float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n lowp float borderAlpha = getCircleAlpha(defaultBoderSize, nodeSize, dist);\n lowp float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n lowp vec3 finalColor = color.xyz;\n lowp float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n lowp float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (drawDefaultBorder > 0.0) {\n lowp float shadowAlpha = getShadowAlpha(defaultBoderSize, dist);\n \n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n lowp float shadowAlpha = getShadowAlpha(circleSize, dist);\n\n finalColor = mix(shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (drawDefaultBorder > 0.0) {\n finalColor = mix(nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n fragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
1
+ declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\nuniform lowp sampler2DArray u_icons;\n\nin lowp vec4 color;\nin lowp float selected;\nin lowp float hovered;\nin mediump float varNodeSize;\nin mediump float iconLayer;\nin lowp float hasIcon;\n\nout vec4 fragColor;\n\nconst float circleSize = 0.40;\nconst float defaultBorderSize = 0.42;\nconst float innerSelectedRingSize = 0.43;\nconst float outerSelectedRingSize = 0.47;\nconst float shadowSize = 0.51;\n\nfloat getShadowAlpha(float size, float dist) {\n return (1.0 - smoothstep(size, shadowSize, dist)) * 0.25;\n}\n\nfloat getCircleAlpha(float ringSize, float nodeSize, float dist) {\n return color.w - smoothstep(ringSize - nodeSize, ringSize, dist);\n}\n\nvoid main() {\n float dist = distance(gl_PointCoord, vec2(0.5));\n\n if (dist > 0.51) {\n discard;\n } else {\n float nodeSize = 1.0 / varNodeSize;\n float nodeAlpha = getCircleAlpha(circleSize, nodeSize, dist);\n float borderAlpha = getCircleAlpha(defaultBorderSize, nodeSize, dist);\n float ringAlpha = getCircleAlpha(innerSelectedRingSize, nodeSize, dist);\n vec3 finalColor = color.xyz;\n float finalAlpha = nodeAlpha;\n\n if (selected > 0.0) {\n float shadowAlpha = getShadowAlpha(outerSelectedRingSize, dist);\n float ringAlpha2 = getCircleAlpha(outerSelectedRingSize, nodeSize, dist);\n\n if (u_drawDefaultBorder > 0.0) {\n finalColor = mix(u_nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(u_selectedInnerBorderColor, finalColor, borderAlpha);\n finalColor = mix(u_selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(u_shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(borderAlpha, ringAlpha2)));\n } else {\n finalColor = mix(u_selectedInnerBorderColor, finalColor, nodeAlpha);\n finalColor = mix(u_selectedBorderColor, finalColor, ringAlpha);\n finalColor = mix(u_shadowColor, finalColor, ringAlpha2);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, max(ringAlpha, ringAlpha2)));\n }\n } else if (hovered > 0.0) {\n if (u_drawDefaultBorder > 0.0) {\n float shadowAlpha = getShadowAlpha(defaultBorderSize, dist);\n finalColor = mix(u_nodeBorderColor, finalColor, nodeAlpha);\n finalColor = mix(u_shadowColor, finalColor, borderAlpha);\n finalAlpha = max(shadowAlpha, max(nodeAlpha, ringAlpha));\n } else {\n float shadowAlpha = getShadowAlpha(circleSize, dist);\n finalColor = mix(u_shadowColor, finalColor, nodeAlpha);\n finalAlpha = max(shadowAlpha, nodeAlpha);\n }\n } else {\n if (u_drawDefaultBorder > 0.0) {\n finalColor = mix(u_nodeBorderColor, finalColor, nodeAlpha);\n finalAlpha = borderAlpha;\n }\n }\n\n if (hasIcon > 0.5) {\n vec2 uv = (gl_PointCoord - vec2(0.5)) / circleSize + 0.5;\n\n float inX = step(0.0, uv.x) - step(1.0, uv.x);\n float inY = step(0.0, uv.y) - step(1.0, uv.y);\n float isInside = inX * inY;\n\n vec4 ic = texture(u_icons, vec3(uv, iconLayer));\n finalColor = mix(finalColor, ic.rgb, ic.a * isInside);\n }\n\n fragColor = vec4(finalColor, 1.0) * finalAlpha;\n }\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\nuniform lowp vec3 u_nodeBorderColor;\nuniform lowp vec3 u_selectedBorderColor;\nuniform lowp vec3 u_selectedInnerBorderColor;\nuniform lowp vec3 u_shadowColor;\nuniform lowp float u_drawDefaultBorder;\n\nin float a_size;\nin lowp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_selected;\nin lowp float a_hovered;\n\nout lowp vec4 color;\nout lowp float selected;\nout lowp float hovered;\nout lowp float varNodeSize;\nout lowp vec3 nodeBorderColor;\nout lowp vec3 selectedBorderColor;\nout lowp vec3 selectedInnerBorderColor;\nout lowp vec3 shadowColor;\nout lowp float drawDefaultBorder;\n\nlowp float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n lowp float nodeSize = a_size * u_zoom * u_glAdjust;\n if (nodeSize < MinNodeSize) {\n gl_PointSize = MinNodeSize;\n varNodeSize = MinNodeSize;\n } else {\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n }\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n nodeBorderColor = u_nodeBorderColor;\n selectedBorderColor = u_selectedBorderColor;\n selectedInnerBorderColor = u_selectedInnerBorderColor;\n shadowColor = u_shadowColor;\n drawDefaultBorder = u_drawDefaultBorder;\n}";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_zoom;\nuniform mediump float u_glAdjust;\n\nin float a_size;\nin highp vec2 a_index;\nin lowp vec4 a_color;\nin lowp float a_selected;\nin lowp float a_hovered;\nin lowp float a_iconLayer;\nin lowp float a_hasIcon;\n\nout lowp vec4 color;\nout lowp float selected;\nout lowp float hovered;\nout mediump float varNodeSize;\nout mediump float iconLayer;\nout lowp float hasIcon;\n\nconst float MinNodeSize = 5.0;\n\nvoid main(void) {\n vec4 data = texture(u_positions, a_index);\n gl_Position = u_projection * vec4(data.xy, 0.0, 1.0);\n\n float nodeSize = max(a_size * u_zoom * u_glAdjust, MinNodeSize);\n gl_PointSize = nodeSize;\n varNodeSize = nodeSize;\n\n color = a_color;\n selected = a_selected;\n hovered = a_hovered;\n iconLayer = a_iconLayer * 255.0;\n hasIcon = a_hasIcon;\n}";
2
2
  export default _default;
@@ -0,0 +1 @@
1
+ export declare const arrowShaderUtilsGLSL = "\nconst float CircleSize = 0.40;\nconst float HeadHalfWidthScale = 4.0;\nconst float HeadLengthScale = 2.5;\nconst float MaxHeadHalfWidthRatio = 0.6;\nconst float MaxHeadLengthRatio = 1.0;\n\n// Self-referencing relationships aren't supported in WebGL yet.\nbool relationshipIsSelfLoop(vec2 fromTexel, vec2 toTexel) {\n return all(equal(fromTexel, toTexel));\n}\n\nvec2 perpendicular(vec2 dir) {\n return vec2(-dir.y, dir.x);\n}\n\nfloat nodeRadiusFromSize(float size) {\n return size * u_glAdjust * CircleSize;\n}\n\nfloat relationshipHalfWidth(float width) {\n return width * u_glAdjust * 0.25;\n}\n\nfloat naturalArrowHeadHalfWidth(float lineHalfWidth) {\n return lineHalfWidth * HeadHalfWidthScale + u_glAdjust;\n}\n\nfloat naturalArrowHeadLength(float headHalfWidth) {\n return headHalfWidth * HeadLengthScale;\n}\n\nfloat clampArrowHeadHalfWidth(float lineHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadHalfWidth(lineHalfWidth);\n float minHalfWidth = lineHalfWidth;\n float maxHalfWidth = max(minHalfWidth, nodeRadius * MaxHeadHalfWidthRatio);\n return clamp(natural, minHalfWidth, maxHalfWidth);\n}\n\nfloat clampArrowHeadLength(float headHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadLength(headHalfWidth);\n float maxLength = nodeRadius * MaxHeadLengthRatio;\n return min(natural, maxLength);\n}\n\nfloat arrowHeadClearance(float lineHalfWidth, float nodeRadius) {\n float headHalfWidth = clampArrowHeadHalfWidth(lineHalfWidth, nodeRadius);\n return clampArrowHeadLength(headHalfWidth, nodeRadius);\n}\n";
@@ -0,0 +1,2 @@
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nin vec2 a_from;\nin vec2 a_to;\nin lowp vec4 a_color;\nin float a_width;\nin float a_toSize;\n\nout lowp vec4 color;\n\n\nconst float CircleSize = 0.40;\nconst float HeadHalfWidthScale = 4.0;\nconst float HeadLengthScale = 2.5;\nconst float MaxHeadHalfWidthRatio = 0.6;\nconst float MaxHeadLengthRatio = 1.0;\n\n// Self-referencing relationships aren't supported in WebGL yet.\nbool relationshipIsSelfLoop(vec2 fromTexel, vec2 toTexel) {\n return all(equal(fromTexel, toTexel));\n}\n\nvec2 perpendicular(vec2 dir) {\n return vec2(-dir.y, dir.x);\n}\n\nfloat nodeRadiusFromSize(float size) {\n return size * u_glAdjust * CircleSize;\n}\n\nfloat relationshipHalfWidth(float width) {\n return width * u_glAdjust * 0.25;\n}\n\nfloat naturalArrowHeadHalfWidth(float lineHalfWidth) {\n return lineHalfWidth * HeadHalfWidthScale + u_glAdjust;\n}\n\nfloat naturalArrowHeadLength(float headHalfWidth) {\n return headHalfWidth * HeadLengthScale;\n}\n\nfloat clampArrowHeadHalfWidth(float lineHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadHalfWidth(lineHalfWidth);\n float minHalfWidth = lineHalfWidth;\n float maxHalfWidth = max(minHalfWidth, nodeRadius * MaxHeadHalfWidthRatio);\n return clamp(natural, minHalfWidth, maxHalfWidth);\n}\n\nfloat clampArrowHeadLength(float headHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadLength(headHalfWidth);\n float maxLength = nodeRadius * MaxHeadLengthRatio;\n return min(natural, maxLength);\n}\n\nfloat arrowHeadClearance(float lineHalfWidth, float nodeRadius) {\n float headHalfWidth = clampArrowHeadHalfWidth(lineHalfWidth, nodeRadius);\n return clampArrowHeadLength(headHalfWidth, nodeRadius);\n}\n\n\nvoid main(void) {\n vec4 from = texture(u_positions, a_from);\n vec4 to = texture(u_positions, a_to);\n\n if (relationshipIsSelfLoop(a_from, a_to)) {\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n return;\n }\n\n vec2 delta = to.xy - from.xy;\n vec2 dir = normalize(delta);\n vec2 perp = perpendicular(dir);\n\n float toRadius = nodeRadiusFromSize(a_toSize);\n float lineHalfWidth = relationshipHalfWidth(a_width);\n float headHalfWidth = clampArrowHeadHalfWidth(lineHalfWidth, toRadius);\n float headLength = clampArrowHeadLength(headHalfWidth, toRadius);\n\n vec2 tip = to.xy - dir * toRadius;\n vec2 baseCenter = tip - dir * headLength;\n\n int corner = gl_VertexID % 3;\n float isTip = float(corner == 0);\n float perpSign = float(corner == 1) - float(corner == 2);\n vec2 basePos = mix(baseCenter, tip, isTip);\n vec2 vertexPosition = basePos + perp * (headHalfWidth * perpSign);\n\n color = a_color;\n gl_Position = u_projection * vec4(vertexPosition, 0.0, 1.0);\n}\n";
2
+ export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nin vec2 a_from;\nin vec2 a_to;\nin lowp vec4 a_color;\nin lowp float a_triside;\nin float a_width;\n\nout lowp vec4 color;\n\nvoid main(void) {\n vec4 from = texture(u_positions, a_from);\n vec4 to = texture(u_positions, a_to);\n vec2 direction = normalize(to.xy - from.xy);\n direction = vec2(-direction.y, direction.x);\n\n float width = a_width * u_glAdjust * 0.5;\n\n if (a_triside == 0.0) {\n from.y += (width / 2.0) * direction.y;\n from.x += (width / 2.0) * direction.x;\n } else {\n from.y -= (width / 2.0) * direction.y;\n from.x -= (width / 2.0) * direction.x;\n }\n\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n}\n";
1
+ declare const _default: "#version 300 es\nuniform mat4 u_projection;\nuniform sampler2D u_positions;\nuniform mediump float u_glAdjust;\n\nin vec2 a_from;\nin vec2 a_to;\nin lowp vec4 a_color;\nin lowp float a_triside;\nin lowp float a_isTarget;\nin float a_endpointSize;\nin float a_otherEndpointSize;\nin float a_width;\n\nout lowp vec4 color;\n\n\nconst float CircleSize = 0.40;\nconst float HeadHalfWidthScale = 4.0;\nconst float HeadLengthScale = 2.5;\nconst float MaxHeadHalfWidthRatio = 0.6;\nconst float MaxHeadLengthRatio = 1.0;\n\n// Self-referencing relationships aren't supported in WebGL yet.\nbool relationshipIsSelfLoop(vec2 fromTexel, vec2 toTexel) {\n return all(equal(fromTexel, toTexel));\n}\n\nvec2 perpendicular(vec2 dir) {\n return vec2(-dir.y, dir.x);\n}\n\nfloat nodeRadiusFromSize(float size) {\n return size * u_glAdjust * CircleSize;\n}\n\nfloat relationshipHalfWidth(float width) {\n return width * u_glAdjust * 0.25;\n}\n\nfloat naturalArrowHeadHalfWidth(float lineHalfWidth) {\n return lineHalfWidth * HeadHalfWidthScale + u_glAdjust;\n}\n\nfloat naturalArrowHeadLength(float headHalfWidth) {\n return headHalfWidth * HeadLengthScale;\n}\n\nfloat clampArrowHeadHalfWidth(float lineHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadHalfWidth(lineHalfWidth);\n float minHalfWidth = lineHalfWidth;\n float maxHalfWidth = max(minHalfWidth, nodeRadius * MaxHeadHalfWidthRatio);\n return clamp(natural, minHalfWidth, maxHalfWidth);\n}\n\nfloat clampArrowHeadLength(float headHalfWidth, float nodeRadius) {\n float natural = naturalArrowHeadLength(headHalfWidth);\n float maxLength = nodeRadius * MaxHeadLengthRatio;\n return min(natural, maxLength);\n}\n\nfloat arrowHeadClearance(float lineHalfWidth, float nodeRadius) {\n float headHalfWidth = clampArrowHeadHalfWidth(lineHalfWidth, nodeRadius);\n return clampArrowHeadLength(headHalfWidth, nodeRadius);\n}\n\n\nvoid main(void) {\n vec4 from = texture(u_positions, a_from);\n vec4 to = texture(u_positions, a_to);\n\n if (relationshipIsSelfLoop(a_from, a_to)) {\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n return;\n }\n\n vec2 delta = from.xy - to.xy;\n float halfWidth = relationshipHalfWidth(a_width);\n float ownRadius = nodeRadiusFromSize(a_endpointSize);\n float otherRadius = nodeRadiusFromSize(a_otherEndpointSize);\n float toRadius = mix(otherRadius, ownRadius, a_isTarget);\n float arrowClearance = arrowHeadClearance(halfWidth, toRadius);\n float endpointClearance = ownRadius + a_isTarget * arrowClearance;\n\n vec2 along = normalize(delta);\n from.xy -= along * endpointClearance;\n\n float sideSign = 1.0 - 2.0 * a_triside;\n from.xy += sideSign * halfWidth * perpendicular(along);\n\n color = a_color;\n gl_Position = u_projection * vec4(from.xy, 0.0, 1.0);\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nprecision lowp float;\n\nin lowp vec4 minimapViewportBoxColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n fragColor = minimapViewportBoxColor;\n}\n";
1
+ declare const _default: "#version 300 es\nprecision lowp float;\n\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nout vec4 fragColor;\n\nvoid main(void) {\n fragColor = u_minimapViewportBoxColor;\n}\n";
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: "#version 300 es\nin vec2 coordinates;\nuniform mat4 u_projection;\nuniform lowp vec4 u_minimapViewportBoxColor;\n\nout lowp vec4 minimapViewportBoxColor;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n minimapViewportBoxColor = u_minimapViewportBoxColor;\n}\n";
1
+ declare const _default: "#version 300 es\nin vec2 coordinates;\nuniform mat4 u_projection;\n\nvoid main(void) {\n gl_Position = u_projection * vec4(coordinates, 0.0, 1.0);\n}\n";
2
2
  export default _default;
@@ -1,4 +1,5 @@
1
1
  import type { StyledCaption } from '../renderers/domrenderer/shared/types';
2
+ import type { Point } from '../utils/geometry';
2
3
  /**
3
4
  * The base type for graph elements.
4
5
  * @private
@@ -97,6 +98,13 @@ interface Node extends GraphElement {
97
98
  */
98
99
  html?: HTMLElement;
99
100
  }
101
+ /**
102
+ * A node returned by {@link NVL.getNodes} with layout coordinates and screen position.
103
+ * `x` and `y` are canvas/layout space; `clientPosition` is relative to the canvas element.
104
+ */
105
+ type NodeWithClientPosition = Node & Point & {
106
+ clientPosition: Point;
107
+ };
100
108
  /**
101
109
  * A node with only a subset of its properties.
102
110
  */
@@ -132,4 +140,4 @@ type PartialRelationship = Partial<Relationship> & {
132
140
  /** The id of the relationship. */
133
141
  id: string;
134
142
  };
135
- export type { Node, Relationship, PartialNode, PartialRelationship };
143
+ export type { Node, NodeWithClientPosition, Relationship, PartialNode, PartialRelationship };
@@ -1,6 +1,6 @@
1
- import type { Node, Relationship } from './graph-element';
1
+ import type { Node, NodeWithClientPosition, Relationship } from './graph-element';
2
2
  export interface NvlWindow {
3
- __Nvl_dumpNodes: (instanceId?: string) => Node[];
3
+ __Nvl_dumpNodes: (instanceId?: string) => NodeWithClientPosition[];
4
4
  __Nvl_dumpRelationships: (instanceId?: string) => Relationship[];
5
5
  __Nvl_getNodesOnScreen: (instanceId?: string) => {
6
6
  nodes: Node[];
@@ -0,0 +1,14 @@
1
+ import { type Point } from './geometry';
2
+ /** Extra world-space padding around each member disk before taking the cluster hull. */
3
+ export declare const ClusterHullPadding = 14;
4
+ /** Circumference samples per member disk before taking the convex hull. */
5
+ export declare const DiskSampleCount = 8;
6
+ export type ClusterMemberDisk = Point & {
7
+ radius: number;
8
+ };
9
+ /**
10
+ * Fits a convex hull around the given disks by sampling each member circumference.
11
+ * @param members - The cluster member disks to fit the hull around.
12
+ * @returns The fitted hull, or null if fewer than two members have a usable position/radius.
13
+ */
14
+ export declare const fitClusterHull: (members: ClusterMemberDisk[]) => Point[] | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -126,3 +126,32 @@ export declare const getIntersection: (p0: Point, p1: Point, p2: Point, p3: Poin
126
126
  * @returns The distance between the point and the curve.
127
127
  */
128
128
  export declare const getDistanceToQuadratic: (fromCoordinates: Point, toCoordinates: Point, control: Point, point: Point) => number;
129
+ /**
130
+ * Converts a polar coordinate (radius + angle around a centre) to a cartesian point.
131
+ * @param centre - The centre of the circle.
132
+ * @param radius - The radius of the circle.
133
+ * @param angle - The angle around the circle, in radians.
134
+ * @returns The point at that angle and radius from the centre.
135
+ */
136
+ export declare const pointOnCircle: (centre: Point, radius: number, angle: number) => Point;
137
+ /**
138
+ * Returns the point halfway between two points.
139
+ * @param a - The first point.
140
+ * @param b - The second point.
141
+ * @returns The midpoint of the segment from a to b.
142
+ */
143
+ export declare const getMidPoint: (a: Point, b: Point) => Point;
144
+ /**
145
+ * Places child points evenly spaced around a circle centred on a point.
146
+ * @param centre - The centre of the circle.
147
+ * @param radius - The radius of the circle.
148
+ * @param noOfChildren - The number of points to place around the circle.
149
+ * @returns The evenly spaced points.
150
+ */
151
+ export declare const calculateCirclePositions: (centre: Point, radius: number, noOfChildren: number) => Point[];
152
+ /**
153
+ * Andrew's monotone-chain convex hull.
154
+ * @param points - The points to get the convex hull of.
155
+ * @returns The convex hull of the points.
156
+ */
157
+ export declare const getConvexHull: (points: Point[]) => Point[];
@@ -1,3 +1,3 @@
1
- type Layouts = 'CoseBilkentLayout' | 'HierarchicalLayout';
1
+ type Layouts = 'HierarchicalLayout';
2
2
  export declare const initializeWorker: (workerName: Layouts, workersDisabled?: boolean) => SharedWorker;
3
3
  export {};
@@ -1,5 +1,11 @@
1
1
  import type { Node } from '../index';
2
2
  import type { Point } from './geometry';
3
+ /**
4
+ * Gets padding for fitting nodes, which is twice the largest node radius.
5
+ * @param maxNodeRadius - The largest node radius.
6
+ * @returns The padding for fitting nodes.
7
+ */
8
+ declare const getFitNodesPadding: (maxNodeRadius?: number) => number;
3
9
  declare const getExtremeLimits: (nodePositions: Point[]) => Point[];
4
10
  declare const getMaxDistance: (extremeLimits?: Point[]) => number;
5
11
  /**
@@ -40,7 +46,8 @@ declare const createZoomTarget: (zoomX: number, zoomY: number, minZoom?: number,
40
46
  * @param nodePositions - The node positions.
41
47
  * @param containerWidth - The width of the container NVL is displayed in.
42
48
  * @param containerHeight - The height of the container NVL is displayed in.
43
- * @param maxNodeRadius - The maximum node radius, which is added as margin to the scene (defaults to `50`).
49
+ * @param maxNodeRadius - The maximum node radius, which is added as margin to the scene
50
+ * (defaults to 2 * {@link DefaultNodeSize}).
44
51
  * @returns The zoom and pan targets.
45
52
  */
46
53
  declare const getZoomTargetForNodePositions: (nodePositions: Point[], containerWidth: number, containerHeight: number, maxNodeRadius?: number) => {
@@ -55,4 +62,4 @@ declare const getFlexibleZoomLimit: (nodePositions: Point[], rect: HTMLCanvasEle
55
62
  declare const getNewZoomWithinLimits: (newZoom: number, oldZoom: number, minZoom: number, maxZoom: number) => number;
56
63
  declare const isZoomOutAtLimit: (newZoom: number, oldZoom: number, zoomOutLimit: number) => boolean;
57
64
  declare const getDynamicZoom: (nodePositions: Point[] & Node[], minZoom: number, maxZoom: number, rect: HTMLCanvasElement, newZoom: number, currentZoom: number) => number;
58
- export { getFlexibleZoomLimit, getZoomTargetForNodePositions, isZoomOutAtLimit, getNewZoomWithinLimits, getExtremeLimits, getMaxDistance, getPositionBoundaries, getZoomLevel, createZoomTarget, getDynamicZoom };
65
+ export { getFitNodesPadding, getFlexibleZoomLimit, getZoomTargetForNodePositions, isZoomOutAtLimit, getNewZoomWithinLimits, getExtremeLimits, getMaxDistance, getPositionBoundaries, getZoomLevel, createZoomTarget, getDynamicZoom };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-nvl/base",
3
- "version": "1.2.0-d88ba7c2",
3
+ "version": "1.2.0-dbc13ec2",
4
4
  "license": "SEE LICENSE IN 'LICENSE.txt'",
5
5
  "homepage": "https://neo4j.com/docs/nvl/current/",
6
6
  "description": "Base library for the Neo4j Visualization Library",
@@ -30,7 +30,7 @@
30
30
  "postpack": "rm LICENSE.txt && rm CHANGELOG.md"
31
31
  },
32
32
  "dependencies": {
33
- "@neo4j-nvl/layout-workers": "1.2.0-d88ba7c2",
33
+ "@neo4j-nvl/layout-workers": "1.2.0-dbc13ec2",
34
34
  "@segment/analytics-next": "1.81.1",
35
35
  "color-string": "1.9.1",
36
36
  "d3-force": "3.0.0",
@@ -38,14 +38,14 @@
38
38
  "glsl-inject-defines": "1.0.3",
39
39
  "lodash": "4.18.1",
40
40
  "loglevel": "1.9.2",
41
- "mobx": "3.6.2",
41
+ "mobx": "6.15.0",
42
42
  "node-pid-controller": "1.0.1",
43
43
  "resizelistener": "1.1.0",
44
44
  "tinycolor2": "1.6.0",
45
- "uuid": "14.0.0"
45
+ "uuid": "14.0.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@babel/core": "7.28.5",
48
+ "@babel/core": "7.29.7",
49
49
  "@types/color-string": "1.5.5",
50
50
  "@types/d3-force": "3.0.10",
51
51
  "@types/lodash": "4.17.21",
@@ -1,22 +0,0 @@
1
- export declare const ForceDirectedLayoutType = "forceDirected";
2
- export declare const CoseBilkentType = "coseBilkent";
3
- export declare class ForceCytoLayout {
4
- private readonly physLayout;
5
- private readonly coseBilkentLayout;
6
- private readonly state;
7
- private currentLayoutType;
8
- private enableCytoscape;
9
- private currentLayout;
10
- constructor(config: any);
11
- setOptions(options: any): void;
12
- private getLayout;
13
- private setLayout;
14
- copyLayoutPositions(nodeList: any, prevLayout: any, nextLayout: any): void;
15
- update(refreshPositions?: boolean): void;
16
- getShouldUpdate(): boolean;
17
- getComputing(): boolean;
18
- updateNodes(positionList: any): void;
19
- getNodePositions(data: any): import("../..").Node[];
20
- terminateUpdate(): void;
21
- destroy(): void;
22
- }
@@ -1,33 +0,0 @@
1
- import type { NvlState } from '../../../modules/state/types';
2
- import type { Node, Relationship } from '../../../types/graph-element';
3
- import AnimatedLayout from '../../animatedlayout/AnimatedLayout';
4
- type LayoutData = {
5
- elements: {
6
- group: string;
7
- data: {
8
- id: string;
9
- };
10
- }[];
11
- spacingFactor: number;
12
- };
13
- export declare class CoseBilkentLayout extends AnimatedLayout {
14
- private stateDisposers;
15
- cytoCompleteCallback: () => void;
16
- computing: boolean;
17
- pendingLayoutData: LayoutData;
18
- worker: SharedWorker;
19
- private workersDisabled;
20
- constructor(config: {
21
- state: NvlState;
22
- cytoCompleteCallback?: () => void;
23
- animationCompleteCallback?: () => void;
24
- });
25
- setOptions(): void;
26
- update(refreshPositions?: boolean, updateMobXNodes?: Node[], updateMobXRelationships?: Relationship[]): void;
27
- getShouldUpdate(): boolean;
28
- getComputing(): boolean;
29
- layout(nodes: Node[], relationships: Relationship[]): void;
30
- terminateUpdate(): void;
31
- destroy(): void;
32
- }
33
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\n\nout vec4 fragColor;\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).r;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).r;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).r;\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).r;\n float avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist);\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterWeight = clusterData.w;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).r;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).r;\n\n if (isPinned > 0.5) {\n fragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).r;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).r;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale * (dist / 1000.0);\n acceleration += grav;\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n if (u_curIteration == 0.0) {\n fragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n float TEMP = max(0.02, pow(COOL, u_curIteration));\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n fragColor = vec4(newPos, newVelocity);\n }\n}";
2
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: "#version 300 es\nprecision mediump float;\nuniform sampler2D u_physData;\nuniform sampler2D u_clusterData;\nuniform sampler2D u_finestIndexes;\nuniform sampler2D u_prevForce;\n\nuniform float u_baseLength;\nuniform float u_numNodes;\nuniform float u_iterationMultiplier;\nuniform float u_isTopLevel;\n\nout vec4 fragColor;\n\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 1.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nfloat getSquaredLogClusterWeight(float value) {\n return pow(log(value), 2.0);\n}\n\nvoid main(void) {\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * 256.0;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterArea = pow(clusterSize + u_baseLength * 2.0, 2.0);\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).r;\n vec4 myPosition = getTextureData(u_physData, finestIndex, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n\n vec2 acceleration = previousForce.xy;\n\n // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getSquaredLogClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).r;\n vec4 otherPosition = getTextureData(u_physData, otherFinestIndex, 256.0);\n\n vec2 delta = myPosition.xy - otherPosition.xy;\n float dist = max(length(delta), 0.0000001);\n float maxDist = 25.0;\n float repulsionForceScale = 0.1;\n\n float F = (clusterArea * fScale) / (dist * dist);\n\n if (u_isTopLevel == 1.0) {\n repulsionForceScale = 0.2;\n }\n\n acceleration += ((delta / sqrt(dist)) * F) * repulsionForceScale * otherClusterWeight;\n\n if (dist < maxDist) {\n float collide = (maxDist - dist) / (dist * dist);\n acceleration += delta * collide * fScale * maxDist / (maxDist + 1.0);\n }\n }\n\n fragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
2
- export default _default;
@@ -1,21 +0,0 @@
1
- import type { Node, Relationship } from '../../../../types/graph-element';
2
- import type { CoarsenedGraph, SolarRelationship } from './types';
3
- export default class SolarMerger {
4
- graph: {
5
- nodes: Node[];
6
- relationships: number[][];
7
- idToRel: Record<string, SolarRelationship>;
8
- };
9
- subGraphs: CoarsenedGraph[];
10
- sunMap: Record<string, string>;
11
- relIdMap: string[][];
12
- nodeSortMap?: Record<number, number>;
13
- constructor(inputGraph: {
14
- nodes: Node[];
15
- rels: Relationship[];
16
- }, nodeIdToIndex: Record<string, number>);
17
- private constructGraphObjects;
18
- coarsenTo(targetSize: number): CoarsenedGraph;
19
- coarsenBy(levelToCoarsenBy: number): CoarsenedGraph;
20
- private coarsen;
21
- }
@@ -1,2 +0,0 @@
1
- import type { Point } from '../../../../utils/geometry';
2
- export declare const calculatePositions: (centre: Point, r: number, noOfChildren: number) => any[];