由 GPU 加速的力图形布局和渲染
GPU-accelerated Force Graph
cosmos.gl is a high-performance WebGL Force Graph algorithm and rendering engine. All the computations and drawing occur on the GPU in fragment and vertex shaders, avoiding expensive memory operations. It enables the real-time simulation of network graphs consisting of hundreds of thousands of points and links on modern hardware.
This engine powers Cosmograph — a toolset for exploring complex networks and AI embeddings.
Comparison with other libraries
Check out our storybook for examples
Install the package:
npm install @cosmos.gl/graph
Get the data, configure the graph and run the simulation:
…
cosmos.gl v3.0 brings a new rendering engine, async initialization, and several new features:
Device across multiple graphs via new Graph(div, config, devicePromise).graph.ready / graph.isReady to know when the graph is usable.start(), stop(), pause(), and unpause() to control it independently.getSampledLinks() and getSampledLinkPositionsMap() for rendering labels or overlays along links.onMouseMove and all click callbacks fire from touch input.onContextMenu, onPointContextMenu, onLinkContextMenu, onBackgroundContextMenu.setZoomTransformByPointPositions() zooms and pans to fit a set of points into view.highlightedPointIndices, highlightedLinkIndices, and outlinedPointIndices config properties. Points and links are highlighted independently. Focused links are rendered wider via focusedLinkIndex / focusedLinkWidthIncrease. New findPointsInRect(), findPointsInPolygon(), getNeighboringPointIndices(), getConnectedLinkIndices(), and getConnectedPointIndices() methods.linkBlending: false disables alpha blending for significantly faster link rendering on dense graphs.onPointMouseOver now includes isHighlighted and isOutlined parameters; hover correctly highlights the topmost point when points overlap.setConfig() now resets all values to defaults before applying; use the new setConfigPartial() to update individual properties without resetting the rest.initialZoomLevel, randomSeed, and attribution can only be set during initialization and are preserved across config updates.enableSimulation can now be changed at runtime via setConfig() or setConfigPartial().transitionDuration: 800, transitionEasing: TransitionEasing.CubicInOut). Use transitionDuration: 0 to keep snap updates.onTransitionStart, onTransition, and onTransitionEnd to track transition lifecycle and progress.pointDefaultShape config property lets you set the fallback shape for all points when no per-point shapes are provided. Accepts a PointShape enum value (e.g., PointShape.Star), a plain number (e.g., 6), or a numeric string (e.g., "6").simulationCollision, and tune the spacing with simulationCollisionRadius (fixed radius vs. size-derived) and simulationCollisionPadding (extra gap between points). See the Collision example.defaultConfigValues is now part of the public API.Check the Migration Guide for upgrading from v2.
cosmos.gl v2.0 introduces significant improvements in performance and data handling:
setPointPositions and setLinks replace setData for improved efficiency.setPointClusters, setClusterPositions and setPointClusterStrength).Check the Migration Guide for upgrading from v1.
EXT_float_blend). We're investigating this issue and exploring solutions. The latest iOS works again!OES_texture_float WebGL extension.MIT
暂无开放 Issues,或尚未同步最近议题。