@cosmos.gl/deck-layers 3.5.0 → 3.6.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 +136 -69
- package/dist/cosmos-graph-layer.d.ts +297 -123
- package/dist/index.d.ts +6 -6
- package/dist/index.js +454 -592
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/blend-parameters.d.ts +0 -23
- package/dist/cosmos-links-layer-uniforms.d.ts +0 -20
- package/dist/cosmos-links-layer.d.ts +0 -68
- package/dist/cosmos-points-layer-uniforms.d.ts +0 -18
- package/dist/cosmos-points-layer.d.ts +0 -52
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/blend-parameters.ts","../src/cosmos-points-layer-uniforms.ts","../src/cosmos-points-layer.ts","../src/cosmos-links-layer-uniforms.ts","../src/cosmos-links-layer.ts","../src/cosmos-graph-layer.ts"],"sourcesContent":["/**\n * Premultiplied-style alpha blending with depth writes disabled: points and\n * links are drawn back-to-front by layer order, never by depth.\n *\n * Wire through `defaultProps.parameters`: before every draw, deck resets each\n * model's pipeline parameters from `layer.props.parameters`. Parameters given\n * only at `Model` creation last one frame.\n *\n * Declare the default with `compare: 2`, like the base layer does — a plain\n * object default would drop deep comparison, and every new-but-equal\n * `parameters` object from the caller would count as a prop change.\n */\nexport const BLEND_PARAMETERS = {\n depthWriteEnabled: false,\n depthCompare: 'always',\n blend: true,\n blendColorOperation: 'add',\n blendColorSrcFactor: 'src-alpha',\n blendColorDstFactor: 'one-minus-src-alpha',\n blendAlphaOperation: 'add',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one-minus-src-alpha',\n} as const\n","import type { ShaderModule } from '@luma.gl/shadertools'\nimport type { Texture } from '@luma.gl/core'\n\nconst uniformBlock = `\\\nlayout(std140) uniform cosmosPointsUniforms {\n float pointsTextureSize;\n highp int sizeUnits;\n} cosmosPoints;\n`\n\ntype CosmosPointsBindingProps = {\n positionsTexture: Texture;\n}\n\ntype CosmosPointsUniformProps = {\n pointsTextureSize: number;\n sizeUnits: number;\n}\n\nexport type CosmosPointsProps = CosmosPointsBindingProps & CosmosPointsUniformProps\n\nexport const cosmosPointsUniforms = {\n name: 'cosmosPoints',\n vs: uniformBlock,\n uniformTypes: {\n pointsTextureSize: 'f32',\n sizeUnits: 'i32',\n },\n} as const satisfies ShaderModule<CosmosPointsProps>\n","import { Layer, project32, picking, UNIT } from '@deck.gl/core'\nimport type { Accessor, Color, DefaultProps, LayerDataSource, LayerProps, Unit, UpdateParameters } from '@deck.gl/core'\nimport { Model, Geometry } from '@luma.gl/engine'\nimport type { PositionTextureSource } from '@cosmos.gl/graph'\n\nimport { BLEND_PARAMETERS } from './blend-parameters'\nimport { cosmosPointsUniforms } from './cosmos-points-layer-uniforms'\nimport type { CosmosPointsProps } from './cosmos-points-layer-uniforms'\n\nconst DEFAULT_POINT_COLOR: [number, number, number, number] = [74, 92, 191, 230]\n\nconst vs = /* glsl */ `\\\n#version 300 es\n#define SHADER_NAME cosmos-points-layer-vertex-shader\n\nin vec3 positions;\n\nin float instanceSizes;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\n\nuniform sampler2D positionsTexture;\n\nout vec4 vColor;\nout vec2 unitPosition;\nout float outerRadiusPixels;\n\n// Collapse the quad so it clips away: nothing rasterizes, nothing picks\nvoid collapse() {\n gl_Position = vec4(0.0);\n unitPosition = vec2(0.0);\n outerRadiusPixels = 0.0;\n vColor = vec4(0.0);\n}\n\nvoid main(void) {\n int pointIndex = gl_InstanceID;\n int textureSize = int(cosmosPoints.pointsTextureSize);\n // Point i lives at texel (i % size, i / size) as [x, y, i, unused] in space coordinates\n vec4 pointPosition = texelFetch(positionsTexture, ivec2(pointIndex % textureSize, pointIndex / textureSize), 0);\n\n // A removed (absent) point's texel is NaN — see PointPositionTexture\n if (isnan(pointPosition.x)) {\n collapse();\n return;\n }\n\n geometry.worldPosition = vec3(pointPosition.xy, 0.0);\n geometry.pickingColor = instancePickingColors;\n\n // instanceSizes is a diameter; the quad expands by radius\n outerRadiusPixels = project_size_to_pixel(instanceSizes * 0.5, cosmosPoints.sizeUnits);\n // A non-positive size hides the point — and the edge-padding divide below\n // is undefined at zero\n if (outerRadiusPixels <= 0.0) {\n collapse();\n return;\n }\n // Expand the quad so edge smoothing has room outside the circle\n float edgePadding = (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels;\n\n unitPosition = edgePadding * positions.xy;\n geometry.uv = unitPosition;\n\n vec3 offset = vec3(edgePadding * positions.xy * project_pixel_size(outerRadiusPixels), 0.0);\n DECKGL_FILTER_SIZE(offset, geometry);\n gl_Position = project_position_to_clipspace(geometry.worldPosition, vec3(0.0), offset, geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n`\n\nconst fs = /* glsl */ `\\\n#version 300 es\n#define SHADER_NAME cosmos-points-layer-fragment-shader\n\nprecision highp float;\n\nin vec4 vColor;\nin vec2 unitPosition;\nin float outerRadiusPixels;\n\nout vec4 fragColor;\n\nvoid main(void) {\n geometry.uv = unitPosition;\n\n float distToCenter = length(unitPosition) * outerRadiusPixels;\n float inCircle = smoothedge(distToCenter, outerRadiusPixels);\n if (inCircle == 0.0) {\n discard;\n }\n\n fragColor = vec4(vColor.rgb, vColor.a * inCircle);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n`\n\nexport type CosmosPointsLayerProps<DataT = unknown> = CosmosPointsLayerOwnProps<DataT> & LayerProps\n\ntype CosmosPointsLayerOwnProps<DataT> = {\n /**\n * One entry per simulation point, in point-index order: an array to run\n * accessors over, or `{ length }` when accessors are constants. The length\n * must equal the simulation's point count.\n */\n data: LayerDataSource<DataT>;\n /** The simulation whose live position texture to sample. */\n graph: PositionTextureSource;\n /**\n * Point diameter accessor, in `pointSizeUnits`; `0` hides the point.\n * @default 4\n */\n getPointSize?: Accessor<DataT, number>;\n /**\n * Point RGBA color accessor, channels in 0..255.\n * @default [74, 92, 191, 230]\n */\n getPointColor?: Accessor<DataT, Color>;\n /**\n * The units of the point diameter, one of `'meters'`, `'common'`, `'pixels'`.\n * @default 'pixels'\n */\n pointSizeUnits?: Unit;\n}\n\nconst defaultProps: DefaultProps<CosmosPointsLayerProps> = {\n getPointSize: { type: 'accessor', value: 4 },\n getPointColor: { type: 'accessor', value: DEFAULT_POINT_COLOR },\n pointSizeUnits: 'pixels',\n parameters: { type: 'object', value: BLEND_PARAMETERS, optional: true, compare: 2 },\n}\n\n/**\n * Renders every cosmos.gl point as an instanced quad whose position comes from\n * a `texelFetch` on the simulation's live GPU position texture — no position\n * attribute, no CPU copy, no per-frame attribute updates. Color and size are\n * ordinary deck instanced attributes, and picking works out of the box: the\n * instance index is the point index.\n *\n * Internal: the points sublayer of `CosmosGraphLayer`, not a package export —\n * the composite keeps `data` aligned with the simulation's point index space.\n */\nexport class CosmosPointsLayer<DataT = unknown> extends Layer<Required<CosmosPointsLayerOwnProps<DataT>>> {\n public static layerName = 'CosmosPointsLayer'\n public static defaultProps = defaultProps\n\n declare public state: { model?: Model }\n\n public getShaders (): ReturnType<Layer['getShaders']> {\n return super.getShaders({ vs, fs, modules: [project32, picking, cosmosPointsUniforms] })\n }\n\n public initializeState (): void {\n this.getAttributeManager()!.addInstanced({\n instanceSizes: {\n size: 1,\n transition: true,\n accessor: 'getPointSize',\n defaultValue: 4,\n },\n instanceColors: {\n size: 4,\n transition: true,\n type: 'unorm8',\n accessor: 'getPointColor',\n defaultValue: [...DEFAULT_POINT_COLOR],\n },\n })\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n\n if (params.changeFlags.extensionsChanged) {\n this.state.model?.destroy()\n this.state.model = this._getModel()\n this.getAttributeManager()!.invalidateAll()\n }\n }\n\n public draw (): void {\n const positionInfo = this.props.graph.getPointPositionTexture()\n const { model } = this.state\n if (!positionInfo || !model || positionInfo.pointCount === 0) return\n\n const moduleProps: CosmosPointsProps = {\n pointsTextureSize: positionInfo.textureSize,\n sizeUnits: UNIT[this.props.pointSizeUnits],\n positionsTexture: positionInfo.texture,\n }\n model.shaderInputs.setProps({ cosmosPoints: moduleProps })\n model.draw(this.context.renderPass)\n }\n\n private _getModel (): Model {\n // A quad that minimally covers the unit circle\n return new Model(this.context.device, {\n ...this.getShaders(),\n id: this.props.id,\n bufferLayout: this.getAttributeManager()!.getBufferLayouts(),\n geometry: new Geometry({\n topology: 'triangle-strip',\n attributes: {\n positions: { size: 3, value: new Float32Array([-1, -1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0]) },\n },\n }),\n isInstanced: true,\n })\n }\n}\n","import type { ShaderModule } from '@luma.gl/shadertools'\nimport type { Texture } from '@luma.gl/core'\n\nconst uniformBlock = `\\\nlayout(std140) uniform cosmosLinksUniforms {\n float pointsTextureSize;\n highp int widthUnits;\n float pointCount;\n} cosmosLinks;\n`\n\ntype CosmosLinksBindingProps = {\n positionsTexture: Texture;\n}\n\ntype CosmosLinksUniformProps = {\n pointsTextureSize: number;\n widthUnits: number;\n pointCount: number;\n}\n\nexport type CosmosLinksProps = CosmosLinksBindingProps & CosmosLinksUniformProps\n\nexport const cosmosLinksUniforms = {\n name: 'cosmosLinks',\n vs: uniformBlock,\n uniformTypes: {\n pointsTextureSize: 'f32',\n widthUnits: 'i32',\n pointCount: 'f32',\n },\n} as const satisfies ShaderModule<CosmosLinksProps>\n","import { Layer, project32, picking, UNIT } from '@deck.gl/core'\nimport type { Accessor, Color, DefaultProps, LayerDataSource, LayerProps, Unit, UpdateParameters } from '@deck.gl/core'\nimport { Model, Geometry } from '@luma.gl/engine'\nimport type { PositionTextureSource } from '@cosmos.gl/graph'\n\nimport { BLEND_PARAMETERS } from './blend-parameters'\nimport { cosmosLinksUniforms } from './cosmos-links-layer-uniforms'\nimport type { CosmosLinksProps } from './cosmos-links-layer-uniforms'\n\nconst DEFAULT_LINK_COLOR: [number, number, number, number] = [94, 115, 194, 64]\n\nconst vs = /* glsl */ `\\\n#version 300 es\n#define SHADER_NAME cosmos-links-layer-vertex-shader\n\nin vec3 positions;\n\nin float instanceSourceIndices;\nin float instanceTargetIndices;\nin vec4 instanceColors;\nin float instanceWidths;\nin vec3 instancePickingColors;\n\nuniform sampler2D positionsTexture;\n\nout vec4 vColor;\nout vec2 uv;\n\n// Offset the vertex by half the link width, perpendicular to the link, in\n// screen space. offsetDirection is -1 (left) or 1 (right).\nvec2 getExtrusionOffset(vec2 lineClipspace, float offsetDirection, float width) {\n vec2 dirScreenspace = normalize(lineClipspace * project.viewportSize);\n dirScreenspace = vec2(-dirScreenspace.y, dirScreenspace.x);\n return dirScreenspace * offsetDirection * width / 2.0;\n}\n\n// The engine's isPointIndex: an integer in [0, pointCount). A fraction would\n// truncate to a neighbour, NaN would make int() undefined.\nbool namesPoint(float index, float pointCount) {\n return index >= 0.0 && index < pointCount && index == floor(index);\n}\n\nvec4 fetchPointPosition(float index, int textureSize) {\n int pointIndex = int(index);\n // Point i lives at texel (i % size, i / size) as [x, y, i, unused] in space coordinates\n return texelFetch(positionsTexture, ivec2(pointIndex % textureSize, pointIndex / textureSize), 0);\n}\n\nvoid main(void) {\n // An endpoint that names no point (an index outside the point count) is\n // skipped, never dropped, so the instance index stays the link index — the\n // rule the engine applies to the same pair in its link grouping. Its texel\n // would be outside the live data.\n float pointCount = cosmosLinks.pointCount;\n bool namesNoPoint = !namesPoint(instanceSourceIndices, pointCount) || !namesPoint(instanceTargetIndices, pointCount);\n\n int textureSize = int(cosmosLinks.pointsTextureSize);\n vec4 sourcePosition = namesNoPoint ? vec4(0.0) : fetchPointPosition(instanceSourceIndices, textureSize);\n vec4 targetPosition = namesNoPoint ? vec4(0.0) : fetchPointPosition(instanceTargetIndices, textureSize);\n\n // A removed (absent) endpoint's texel is NaN — see PointPositionTexture;\n // collapse the quad, as for an endpoint that names no point, so it clips away\n if (namesNoPoint || isnan(sourcePosition.x) || isnan(targetPosition.x)) {\n gl_Position = vec4(0.0);\n vColor = vec4(0.0);\n uv = vec2(0.0);\n return;\n }\n\n vec3 sourceWorld = vec3(sourcePosition.xy, 0.0);\n vec3 targetWorld = vec3(targetPosition.xy, 0.0);\n geometry.worldPosition = sourceWorld;\n geometry.worldPositionAlt = targetWorld;\n\n vec4 sourceCommonspace;\n vec4 targetCommonspace;\n vec4 source = project_position_to_clipspace(sourceWorld, vec3(0.0), vec3(0.0), sourceCommonspace);\n vec4 target = project_position_to_clipspace(targetWorld, vec3(0.0), vec3(0.0), targetCommonspace);\n\n // positions.x selects the endpoint, positions.y the extrusion side\n float segmentIndex = positions.x;\n vec4 p = mix(source, target, segmentIndex);\n geometry.position = mix(sourceCommonspace, targetCommonspace, segmentIndex);\n uv = positions.xy;\n geometry.uv = uv;\n geometry.pickingColor = instancePickingColors;\n\n float widthPixels = project_size_to_pixel(instanceWidths, cosmosLinks.widthUnits);\n\n vec3 offset = vec3(getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), 0.0);\n DECKGL_FILTER_SIZE(offset, geometry);\n DECKGL_FILTER_GL_POSITION(p, geometry);\n gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);\n\n vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity);\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n`\n\nconst fs = /* glsl */ `\\\n#version 300 es\n#define SHADER_NAME cosmos-links-layer-fragment-shader\n\nprecision highp float;\n\nin vec4 vColor;\nin vec2 uv;\n\nout vec4 fragColor;\n\nvoid main(void) {\n geometry.uv = uv;\n\n fragColor = vColor;\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n`\n\nexport type CosmosLinksLayerProps<DataT = unknown> = CosmosLinksLayerOwnProps<DataT> & LayerProps\n\ntype CosmosLinksLayerOwnProps<DataT> = {\n /**\n * One entry per link, in link-index order: an array to run accessors over,\n * or binary form. The cosmos links array `[src0, tgt0, src1, tgt1, …]` maps\n * without a copy as two interleaved attributes over the same buffer:\n * `{ length, attributes: { getLinkSource: { value, size: 1, stride: 8 },\n * getLinkTarget: { value, size: 1, offset: 4, stride: 8 } } }`.\n */\n data: LayerDataSource<DataT>;\n /** The simulation whose live position texture to sample. */\n graph: PositionTextureSource;\n /**\n * Source point index accessor.\n * @default l => l.source\n */\n getLinkSource?: Accessor<DataT, number>;\n /**\n * Target point index accessor.\n * @default l => l.target\n */\n getLinkTarget?: Accessor<DataT, number>;\n /**\n * Link RGBA color accessor, channels in 0..255.\n * @default [94, 115, 194, 64]\n */\n getLinkColor?: Accessor<DataT, Color>;\n /**\n * Link width accessor, in `linkWidthUnits`.\n * @default 1\n */\n getLinkWidth?: Accessor<DataT, number>;\n /**\n * The units of the link width, one of `'meters'`, `'common'`, `'pixels'`.\n * @default 'pixels'\n */\n linkWidthUnits?: Unit;\n}\n\nconst defaultProps: DefaultProps<CosmosLinksLayerProps> = {\n getLinkSource: { type: 'accessor', value: (l: unknown) => (l as { source: number }).source },\n getLinkTarget: { type: 'accessor', value: (l: unknown) => (l as { target: number }).target },\n getLinkColor: { type: 'accessor', value: DEFAULT_LINK_COLOR },\n getLinkWidth: { type: 'accessor', value: 1 },\n linkWidthUnits: 'pixels',\n parameters: { type: 'object', value: BLEND_PARAMETERS, optional: true, compare: 2 },\n}\n\n/**\n * Renders every cosmos.gl link as an instanced quad stretched between its two\n * endpoints: the vertex shader `texelFetch`es both point positions from the\n * simulation's live GPU texture and extrudes the quad by half the link width\n * in screen space — no position attribute, no CPU copy, no per-frame attribute\n * updates. Endpoint indices, color and width are ordinary deck instanced\n * attributes, and picking works out of the box: the instance index is the\n * link index.\n *\n * Internal: the links sublayer of `CosmosGraphLayer`, not a package export —\n * the composite resolves array links to point indices before they reach this\n * layer, and a pair that names no point collapses in the shader, keeping its\n * index.\n */\nexport class CosmosLinksLayer<DataT = unknown> extends Layer<Required<CosmosLinksLayerOwnProps<DataT>>> {\n public static layerName = 'CosmosLinksLayer'\n public static defaultProps = defaultProps\n\n declare public state: { model?: Model }\n\n public getShaders (): ReturnType<Layer['getShaders']> {\n return super.getShaders({ vs, fs, modules: [project32, picking, cosmosLinksUniforms] })\n }\n\n public initializeState (): void {\n this.getAttributeManager()!.addInstanced({\n instanceSourceIndices: {\n size: 1,\n accessor: 'getLinkSource',\n },\n instanceTargetIndices: {\n size: 1,\n accessor: 'getLinkTarget',\n },\n instanceColors: {\n size: 4,\n transition: true,\n type: 'unorm8',\n accessor: 'getLinkColor',\n defaultValue: [...DEFAULT_LINK_COLOR],\n },\n instanceWidths: {\n size: 1,\n transition: true,\n accessor: 'getLinkWidth',\n defaultValue: 1,\n },\n })\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n\n if (params.changeFlags.extensionsChanged) {\n this.state.model?.destroy()\n this.state.model = this._getModel()\n this.getAttributeManager()!.invalidateAll()\n }\n }\n\n public draw (): void {\n const positionInfo = this.props.graph.getPointPositionTexture()\n const { model } = this.state\n if (!positionInfo || !model || positionInfo.pointCount === 0) return\n\n const moduleProps: CosmosLinksProps = {\n pointsTextureSize: positionInfo.textureSize,\n widthUnits: UNIT[this.props.linkWidthUnits],\n pointCount: positionInfo.pointCount,\n positionsTexture: positionInfo.texture,\n }\n model.shaderInputs.setProps({ cosmosLinks: moduleProps })\n model.draw(this.context.renderPass)\n }\n\n private _getModel (): Model {\n // positions.x selects source/target, positions.y the extrusion side\n return new Model(this.context.device, {\n ...this.getShaders(),\n id: this.props.id,\n bufferLayout: this.getAttributeManager()!.getBufferLayouts(),\n geometry: new Geometry({\n topology: 'triangle-strip',\n attributes: {\n positions: { size: 3, value: new Float32Array([0, -1, 0, 0, 1, 0, 1, -1, 0, 1, 1, 0]) },\n },\n }),\n isInstanced: true,\n })\n }\n}\n","import { CompositeLayer } from '@deck.gl/core'\nimport type {\n Accessor,\n AccessorContext,\n BinaryAttribute,\n Color,\n DefaultProps,\n GetPickingInfoParams,\n Layer,\n LayerContext,\n LayerProps,\n PickingInfo,\n Unit,\n UpdateParameters,\n} from '@deck.gl/core'\nimport { GraphSimulation, defaultConfigValues } from '@cosmos.gl/graph'\nimport type { GraphSimulationConfig } from '@cosmos.gl/graph'\n\nimport { BLEND_PARAMETERS } from './blend-parameters'\nimport { CosmosPointsLayer } from './cosmos-points-layer'\nimport { CosmosLinksLayer } from './cosmos-links-layer'\n\n/**\n * Binary styling channels for binary points, keyed by the accessor each one\n * replaces: deck uploads the typed array as the instanced attribute instead of\n * calling the accessor per point. Colors are RGBA bytes (0..255), 4 per point;\n * sizes are one diameter per point, in `pointSizeUnits`.\n */\nexport type CosmosPointAttributes = {\n getPointColor?: BinaryAttribute;\n getPointSize?: BinaryAttribute;\n}\n\n/**\n * Points input: an array to run accessors over (picking returns the original\n * objects), or the cosmos-native binary form — a point count plus optional\n * `[x0, y0, x1, y1, …]` initial positions and binary styling channels. Points\n * without given positions are seeded randomly inside the simulation space.\n */\nexport type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {\n length: number;\n initialPositions?: Float32Array;\n attributes?: CosmosPointAttributes;\n}\n\n/**\n * Binary styling channels for binary links, keyed by the accessor each one\n * replaces. Colors are RGBA bytes (0..255), 4 per link; widths are one per\n * link, in `linkWidthUnits`.\n */\nexport type CosmosLinkAttributes = {\n getLinkColor?: BinaryAttribute;\n getLinkWidth?: BinaryAttribute;\n}\n\n/**\n * Links input: an array to run accessors over, the cosmos-native\n * `[source0, target0, source1, target1, …]` array of point indices, or that\n * array as `pairs` with binary styling channels beside it. An array link whose\n * source or target does not resolve to a point is dropped from both the\n * simulation and the rendering, with one warning per data change; a pair that\n * names no point is skipped by both and keeps its index.\n */\nexport type CosmosGraphLinks<LinkDataT> = readonly LinkDataT[] | Float32Array | {\n pairs: Float32Array;\n attributes?: CosmosLinkAttributes;\n}\n\n/** Picking info from a CosmosGraphLayer: which kind of element was hit. */\nexport type CosmosGraphPickingInfo = PickingInfo & {\n elementType?: 'point' | 'link';\n}\n\nexport type CosmosGraphLayerProps<PointDataT = unknown, LinkDataT = unknown> =\n CosmosGraphLayerOwnProps<PointDataT, LinkDataT> & LayerProps\n\ntype CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {\n /**\n * One entry per point — an array of your objects, or `{ length, initialPositions?, attributes? }`.\n * The layer loads them, with `links`, into the simulation. Omit it to draw the data the\n * simulation already holds instead: the layer then writes nothing into the simulation and\n * follows its point count and links — the mode for an application-loaded `simulation`.\n */\n points?: CosmosGraphPoints<PointDataT> | null;\n /** One entry per link — an array of your objects, or a flat point-index pair array. Ignored without `points`. */\n links?: CosmosGraphLinks<LinkDataT> | null;\n /**\n * Stable point id accessor. When provided (with array points), link\n * accessors may return ids instead of point indices.\n */\n getPointId?: Accessor<PointDataT, string | number> | null;\n /** Initial `[x, y]` position accessor for array points; points it leaves undefined are seeded randomly. */\n getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;\n /**\n * Point diameter accessor, in `pointSizeUnits`; `0` hides the point.\n * @default 4\n */\n getPointSize?: Accessor<PointDataT, number>;\n /**\n * Point RGBA color accessor, channels in 0..255.\n * @default [74, 92, 191, 230]\n */\n getPointColor?: Accessor<PointDataT, Color>;\n /**\n * The units of the point diameter.\n * @default 'pixels'\n */\n pointSizeUnits?: Unit;\n /**\n * Source accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.source\n */\n getLinkSource?: Accessor<LinkDataT, string | number>;\n /**\n * Target accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.target\n */\n getLinkTarget?: Accessor<LinkDataT, string | number>;\n /**\n * Link RGBA color accessor, channels in 0..255.\n * @default [94, 115, 194, 64]\n */\n getLinkColor?: Accessor<LinkDataT, Color>;\n /**\n * Link width accessor, in `linkWidthUnits`.\n * @default 1\n */\n getLinkWidth?: Accessor<LinkDataT, number>;\n /**\n * The units of the link width.\n * @default 'pixels'\n */\n linkWidthUnits?: Unit;\n /**\n * Lets pointer drags grab a point: pinned on drag start, moved with the\n * pointer, released per `unpinOnDragEnd`. View panning is suppressed while\n * a point is grabbed.\n * @default false\n */\n enablePointDrag?: boolean;\n /**\n * Simulation alpha to restart with when a drag starts, so the graph\n * responds to the moving point; `null` leaves the simulation untouched.\n * @default 0.1\n */\n dragReheatAlpha?: number | null;\n /**\n * Release the point on drag end; `false` keeps it pinned where dropped.\n * @default true\n */\n unpinOnDragEnd?: boolean;\n /** Called when a point drag starts. */\n onPointDragStart?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called for every pointer move while a point is dragged. */\n onPointDrag?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called when a point drag ends. */\n onPointDragEnd?: ((info: CosmosGraphPickingInfo) => void) | null;\n /**\n * An application-owned `GraphSimulation` to render instead of creating one.\n * It must run on deck's device — construct it with the device from deck's\n * `onDeviceInitialized`. The layer steps it while it runs (`pause()` it to\n * take over stepping, then `deck.redraw()` after each manual `step()`) and\n * renders it; it never configures or destroys it — `simulationConfig` and\n * `onSimulationCreated` apply only to a layer-created simulation, and\n * teardown is the application's, before `deck.finalize()`.\n *\n * `points` decides who loads the data. Given, the layer loads `points` and\n * `links` into the simulation once the device check has passed, over whatever\n * it held. Omitted, the layer draws the simulation's own data and follows its\n * changes. Several layers may draw one simulation — it steps once per frame\n * however many draw it — as long as at most one of them loads data.\n */\n simulation?: GraphSimulation | null;\n /**\n * Simulation configuration, passed through to the layer-created\n * `GraphSimulation` (forces, spaceSize, callbacks). Ignored when\n * `simulation` is provided.\n */\n simulationConfig?: GraphSimulationConfig;\n /**\n * Called once with the layer-created `GraphSimulation` — the escape hatch for\n * advanced control (pause, pinning, sparse position writes). Not called for\n * a provided `simulation`.\n */\n onSimulationCreated?: ((simulation: GraphSimulation) => void) | null;\n}\n\nconst defaultProps: DefaultProps<CosmosGraphLayerProps> = {\n points: { type: 'object', value: null, optional: true },\n links: null,\n getPointId: { type: 'accessor', value: null },\n getPointPosition: { type: 'accessor', value: null },\n getPointSize: { type: 'accessor', value: 4 },\n getPointColor: { type: 'accessor', value: [74, 92, 191, 230] },\n pointSizeUnits: 'pixels',\n getLinkSource: { type: 'accessor', value: (l: unknown) => (l as { source: number }).source },\n getLinkTarget: { type: 'accessor', value: (l: unknown) => (l as { target: number }).target },\n getLinkColor: { type: 'accessor', value: [94, 115, 194, 64] },\n getLinkWidth: { type: 'accessor', value: 1 },\n linkWidthUnits: 'pixels',\n enablePointDrag: false,\n dragReheatAlpha: 0.1,\n unpinOnDragEnd: true,\n onPointDragStart: { type: 'function', value: null, optional: true },\n onPointDrag: { type: 'function', value: null, optional: true },\n onPointDragEnd: { type: 'function', value: null, optional: true },\n simulation: { type: 'object', value: null, optional: true },\n simulationConfig: { type: 'object', value: {}, compare: 2 },\n onSimulationCreated: { type: 'function', value: null, optional: true },\n // getSubLayerProps forwards `parameters` into every sublayer, so the\n // composite must carry the same pipeline-state default the primitives do\n parameters: { type: 'object', value: BLEND_PARAMETERS, optional: true, compare: 2 },\n}\n\n/** The slice of a deck gesture event the drag handlers need. */\ntype DragGestureEvent = {\n stopImmediatePropagation?: () => void;\n}\n\n/** The update-trigger keys the composite forwards to its sublayers. */\ntype CosmosUpdateTriggers = {\n getPointId?: unknown;\n getPointPosition?: unknown;\n getPointSize?: unknown;\n getPointColor?: unknown;\n getLinkSource?: unknown;\n getLinkTarget?: unknown;\n getLinkColor?: unknown;\n getLinkWidth?: unknown;\n}\n\n/** Resolves a deck accessor (function or constant) for one object. */\nconst resolveAccessor = <In, Out>(accessor: Accessor<In, Out>, object: In, info: AccessorContext<In>): Out =>\n typeof accessor === 'function' ? (accessor as (o: In, i: AccessorContext<In>) => Out)(object, info) : accessor\n\n/**\n * When each simulation last stepped, by timeline time: layers drawing the same\n * simulation share one step per frame instead of each taking their own.\n */\nconst steppedAt = new WeakMap<GraphSimulation, number>()\n\n/** The endpoint channels of the links sublayer, read straight from the cosmos pair array. */\ntype LinkEndpointAttributes = {\n getLinkSource: BinaryAttribute;\n getLinkTarget: BinaryAttribute;\n}\n\ntype BinaryLinksData = { length: number; attributes: LinkEndpointAttributes & CosmosLinkAttributes }\n\n/**\n * The cosmos pair array as deck binary link data: two interleaved endpoint\n * attributes, no copy, plus the caller's styling channels — copied by name,\n * never spread, so nothing can replace the endpoints.\n */\nconst binaryLinksData = (pairs: Float32Array, attributes?: CosmosLinkAttributes): BinaryLinksData => ({\n length: pairs.length / 2,\n attributes: {\n getLinkSource: { value: pairs, size: 1, stride: 8 },\n getLinkTarget: { value: pairs, size: 1, offset: 4, stride: 8 },\n ...(attributes?.getLinkColor && { getLinkColor: attributes.getLinkColor }),\n ...(attributes?.getLinkWidth && { getLinkWidth: attributes.getLinkWidth }),\n },\n})\n\n/** What the layer loaded when binary points carried no `initialPositions`: a seed of its own. */\nconst SEEDED = Symbol('seeded')\nconst NO_LINKS = new Float32Array(0)\n\n/**\n * The cosmos.gl graph layer: give it points and links, and it handles the\n * rest. The layer creates a `GraphSimulation` on deck's device (or renders the\n * application's, via `simulation`), loads the data — or, without `points`,\n * follows the data the simulation holds — advances the simulation once per\n * animation frame from deck's shared timeline while it runs (deck goes idle\n * when it settles — no `_animate` required), renders through its internal\n * links and points sublayers (positions stay GPU-resident), and destroys a\n * simulation it created when the layer is removed. Picking reports\n * `elementType: 'point' | 'link'` alongside the index and, for array data, the\n * original object.\n */\nexport class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends CompositeLayer<\n Required<CosmosGraphLayerOwnProps<PointDataT, LinkDataT>>\n> {\n public static layerName = 'CosmosGraphLayer'\n public static defaultProps = defaultProps\n\n declare public state: {\n simulation?: GraphSimulation;\n /** The `simulation` prop this state was built from; `null` when the layer created its own. */\n providedSimulation: GraphSimulation | null;\n isReady: boolean;\n /** `points` changed before the simulation was ready: load them once it is. */\n isIngestPending: boolean;\n pointCount: number;\n pointsData: readonly PointDataT[] | { length: number; attributes?: CosmosPointAttributes };\n linksData: readonly LinkDataT[] | BinaryLinksData | null;\n /** Array links only: the resolved `[source, target]` point-index pairs, one per entry of `linksData`. */\n linkIndices: Float32Array | null;\n /**\n * Load mode: what the simulation holds, so a channel reloads only when its own\n * input changes and a restyle leaves the layout alone. `loadedPositions` is the\n * `initialPositions` array, `SEEDED`, or the points array; `loadedPairs` the pair\n * array sent last; `idToIndex` the id map of the loaded points.\n */\n hasLoaded: boolean;\n loadedPositions?: unknown;\n loadedPairs?: Float32Array | null;\n idToIndex?: Map<string | number, number> | null;\n /** Without `points`: the simulation's links array the render data was built from. */\n followedLinks?: Float32Array | null;\n draggedPointIndex: number | null;\n animationHandle?: number;\n }\n\n public get isLoaded (): boolean {\n return super.isLoaded && Boolean(this.state?.isReady)\n }\n\n public initializeState (): void {\n const { device, timeline } = this.context\n if (device.type !== 'webgl') {\n throw new Error(\n `@cosmos.gl/deck-layers requires a WebGL 2 device — the cosmos.gl simulation is WebGL-only, got '${device.type}'`\n )\n }\n\n this.state = {\n providedSimulation: null,\n isReady: false,\n isIngestPending: false,\n hasLoaded: false,\n pointCount: 0,\n pointsData: { length: 0 },\n linksData: null,\n linkIndices: null,\n draggedPointIndex: null,\n // Step the simulation exactly once per animation frame, independent of\n // draw passes (draw runs per viewport and again while picking)\n animationHandle: timeline.attachAnimation({ setTime: (time) => this._onTimelineTick(time) }),\n }\n this._attachSimulation(this.props.simulation ?? null)\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n const { props, oldProps, changeFlags } = params\n // Swapping simulations loads the current data into the new one, or follows it\n const providedSimulation = props.simulation ?? null\n const simulationSwapped = providedSimulation !== this.state.providedSimulation\n if (simulationSwapped) {\n this._releaseSimulation()\n this._attachSimulation(providedSimulation)\n }\n const simulation = this.state.simulation\n if (!simulation) return\n\n if (!providedSimulation && changeFlags.propsChanged && props.simulationConfig !== oldProps.simulationConfig) {\n simulation.setConfig(props.simulationConfig)\n }\n // Array links resolve against the id map and the position accessor at load,\n // so a change to either counts as a change of that channel\n const triggers = typeof changeFlags.updateTriggersChanged === 'object'\n ? changeFlags.updateTriggersChanged as CosmosUpdateTriggers\n : undefined\n const pointsChanged = simulationSwapped || props.points !== oldProps.points || Boolean(triggers?.getPointPosition)\n const idsChanged = Boolean(triggers?.getPointId)\n const linksChanged = simulationSwapped || props.links !== oldProps.links ||\n Boolean(triggers?.getLinkSource || triggers?.getLinkTarget) || idsChanged\n if (!pointsChanged && !linksChanged) return\n\n if (props.points) {\n // The layer's data goes into the simulation — once the device check has passed\n if (this.state.isReady) this._updateSimulationData(pointsChanged, linksChanged, idsChanged)\n else this.state.isIngestPending = true\n } else {\n // No data of its own: the layer draws what the simulation holds\n if (props.links) {\n console.warn('@cosmos.gl/deck-layers: `links` is ignored without `points` — load them into the simulation instead')\n }\n this.state.isIngestPending = false\n this.state.hasLoaded = false\n if (this.state.isReady) this._syncFromSimulation(true)\n }\n }\n\n public renderLayers (): Layer[] | null {\n const { simulation, isReady, pointCount, pointsData, linksData, linkIndices } = this.state\n if (!simulation || !isReady || pointCount === 0) return null\n\n const { getPointSize, getPointColor, pointSizeUnits, getLinkColor, getLinkWidth, linkWidthUnits } = this.props\n const triggers: CosmosUpdateTriggers = this.props.updateTriggers ?? {}\n const layers: Layer[] = []\n\n if (linksData) {\n layers.push(\n new CosmosLinksLayer<LinkDataT>(\n this.getSubLayerProps({\n id: 'links',\n updateTriggers: {\n getLinkSource: triggers.getLinkSource,\n getLinkTarget: triggers.getLinkTarget,\n getLinkColor: triggers.getLinkColor,\n getLinkWidth: triggers.getLinkWidth,\n },\n }),\n {\n data: linksData as CosmosLinksLayer<LinkDataT>['props']['data'],\n graph: simulation,\n getLinkColor,\n getLinkWidth,\n linkWidthUnits,\n // getSubLayerProps does not forward `transitions`\n transitions: this.props.transitions,\n },\n Array.isArray(linksData) && linkIndices\n ? {\n // Array links read the endpoints resolved at ingest, so the\n // rendered links are exactly the simulated ones\n getLinkSource: (_: LinkDataT, { index }: AccessorContext<LinkDataT>): number => linkIndices[index * 2] as number,\n getLinkTarget: (_: LinkDataT, { index }: AccessorContext<LinkDataT>): number => linkIndices[index * 2 + 1] as number,\n }\n : {}\n )\n )\n }\n\n layers.push(\n new CosmosPointsLayer<PointDataT>(\n this.getSubLayerProps({\n id: 'points',\n updateTriggers: {\n getPointSize: triggers.getPointSize,\n getPointColor: triggers.getPointColor,\n },\n }),\n {\n data: pointsData as CosmosPointsLayer<PointDataT>['props']['data'],\n graph: simulation,\n getPointSize,\n getPointColor,\n pointSizeUnits,\n // getSubLayerProps does not forward `transitions`\n transitions: this.props.transitions,\n }\n )\n )\n\n return layers\n }\n\n public onDragStart (info: PickingInfo, event: DragGestureEvent): boolean {\n const { simulation } = this.state\n const { enablePointDrag, dragReheatAlpha } = this.props\n const picked = info as CosmosGraphPickingInfo\n if (!enablePointDrag || !simulation || picked.elementType !== 'point' || info.index < 0) return false\n\n // A direct field write: per-gesture state must not re-render sublayers\n this.state.draggedPointIndex = info.index\n simulation.setPinnedPoint(info.index, true)\n if (dragReheatAlpha !== null) simulation.start(dragReheatAlpha)\n // A grabbed point must not also pan the view\n event.stopImmediatePropagation?.()\n this.props.onPointDragStart?.(picked)\n return true\n }\n\n public onDrag (info: PickingInfo, event: DragGestureEvent): boolean {\n const { simulation, draggedPointIndex } = this.state\n if (!simulation || draggedPointIndex === null) return false\n\n const [x, y] = this._dragCoordinate(info)\n simulation.setPointPosition(draggedPointIndex, x, y)\n event.stopImmediatePropagation?.()\n // Repaint even when the simulation is settled and the ticker is idle\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n this.props.onPointDrag?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n public onDragEnd (info: PickingInfo, event: DragGestureEvent): boolean {\n const { simulation, draggedPointIndex } = this.state\n if (!simulation || draggedPointIndex === null) return false\n\n if (this.props.unpinOnDragEnd) simulation.setPinnedPoint(draggedPointIndex, false)\n this.state.draggedPointIndex = null\n event.stopImmediatePropagation?.()\n this.props.onPointDragEnd?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n public getPickingInfo (params: GetPickingInfoParams): CosmosGraphPickingInfo {\n const info: CosmosGraphPickingInfo = params.info\n if (params.sourceLayer) {\n info.elementType = params.sourceLayer.id.endsWith('-links') ? 'link' : 'point'\n }\n return info\n }\n\n /** The whole simulation space; lets deck's viewport helpers frame the graph. */\n public getBounds (): [number[], number[]] | null {\n const spaceSize = this._spaceSize()\n return [[0, 0, 0], [spaceSize, spaceSize, 0]]\n }\n\n public finalizeState (context: LayerContext): void {\n if (this.state?.animationHandle !== undefined) {\n this.context.timeline.detachAnimation(this.state.animationHandle)\n }\n if (this.state) this._releaseSimulation()\n super.finalizeState(context)\n }\n\n /**\n * Points and links have separate index spaces, so the same picking color\n * exists in both sublayers: highlight only the sublayer that was hovered\n * and clear the other, or hovering point N would also tint link N.\n */\n protected _updateAutoHighlight (info: PickingInfo): void {\n for (const layer of this.getSubLayers()) {\n if (layer.id === info.sourceLayer?.id) {\n layer.updateAutoHighlight(info)\n } else {\n layer.updateAutoHighlight({ ...info, picked: false })\n }\n }\n }\n\n /** Adopts the provided simulation, or creates one on deck's device when `provided` is `null`. */\n private _attachSimulation (provided: GraphSimulation | null): void {\n const { device } = this.context\n const simulation = provided ?? new GraphSimulation(this.props.simulationConfig, Promise.resolve(device))\n this.setState({\n simulation,\n providedSimulation: provided,\n isReady: false,\n hasLoaded: false,\n loadedPositions: undefined,\n loadedPairs: null,\n idToIndex: null,\n draggedPointIndex: null,\n })\n\n if (!provided) this.props.onSimulationCreated?.(simulation)\n\n simulation.ready.then(() => {\n // `this` may be a stale descriptor by now; state is the stable identity\n if (this.state?.simulation !== simulation) return\n const layer = (this.getCurrentLayer() ?? this) as CosmosGraphLayer<PointDataT, LinkDataT>\n // Textures from another device cannot be sampled by deck's draws\n if (simulation.device !== layer.context.device) {\n console.error(\n '@cosmos.gl/deck-layers: the provided simulation runs on a different device than deck — construct it with the device from deck\\'s onDeviceInitialized'\n )\n return\n }\n // Only now may the layer touch the simulation's data\n if (layer.state.isIngestPending) {\n layer.state.isIngestPending = false\n layer._updateSimulationData(true, true, true)\n } else if (!layer.props.points) {\n layer._syncFromSimulation(true)\n }\n layer.setState({ isReady: true })\n }).catch((error: Error) => {\n console.error('@cosmos.gl/deck-layers: simulation failed to initialize', error)\n })\n }\n\n /** Destroys a layer-created simulation; a provided one is left to the application. */\n private _releaseSimulation (): void {\n const { simulation, providedSimulation } = this.state\n if (simulation && !providedSimulation) simulation.destroy()\n this.state.simulation = undefined\n }\n\n /** The simulation's space size — authoritative for a provided simulation too. */\n private _spaceSize (): number {\n return this.state?.simulation?.config.spaceSize ??\n this.props.simulationConfig?.spaceSize ??\n defaultConfigValues.spaceSize\n }\n\n private _onTimelineTick (time: number): void {\n const { simulation, isReady } = this.state ?? {}\n if (!simulation || !isReady) return\n const layer = (this.getCurrentLayer() ?? this) as CosmosGraphLayer<PointDataT, LinkDataT>\n // Without data of its own, the layer follows what the application loads\n if (!layer.props.points) layer._syncFromSimulation()\n if (!simulation.isSimulationRunning) return\n // One step per frame per simulation, however many layers draw it\n if (steppedAt.get(simulation) !== time) {\n steppedAt.set(simulation, time)\n simulation.step()\n }\n // Repaint the frame this step just computed; when the simulation settles,\n // the flag stops being set and deck goes idle on its own\n layer.setNeedsRedraw()\n }\n\n /**\n * Without `points`: builds the render data from what the simulation holds —\n * its point count and links — and rebuilds it when either changes. Runs every\n * tick, so it only compares until something differs.\n */\n private _syncFromSimulation (force = false): void {\n const { simulation } = this.state\n if (!simulation) return\n const pointCount = simulation.data.pointsNumber ?? 0\n const links = simulation.data.links ?? null\n if (!force && pointCount === this.state.pointCount && links === this.state.followedLinks) return\n this.setState({\n pointCount,\n pointsData: { length: pointCount },\n linksData: links && links.length > 0 ? binaryLinksData(links) : null,\n linkIndices: null,\n followedLinks: links,\n })\n }\n\n private _dragCoordinate (info: PickingInfo): [number, number] {\n // info.coordinate is unprojected at the current pointer; it can be absent\n // when the pointer leaves the picked object's viewport\n if (info.coordinate) return [info.coordinate[0] as number, info.coordinate[1] as number]\n const unprojected = this.context.viewport.unproject([info.x, info.y])\n return [unprojected[0] as number, unprojected[1] as number]\n }\n\n /**\n * Load mode: puts the layer's `points` and `links` into the simulation and\n * builds the render data from them. Each channel is sent only when its own\n * input changed — a new `points` or `links` object with the same positions\n * or pairs restyles in place and leaves the layout alone. A changed id map\n * re-resolves array links without touching the positions.\n */\n private _updateSimulationData (pointsChanged: boolean, linksChanged: boolean, idsChanged: boolean): void {\n const simulation = this.state.simulation\n if (!simulation) return\n const { points, links, getPointId, getPointPosition } = this.props\n if (!points) return\n const firstLoad = !this.state.hasLoaded\n const spaceSize = this._spaceSize()\n\n // Unseeded points land in the middle half of the space, clear of the walls\n const randomCoordinate = (): number => spaceSize * (0.25 + Math.random() * 0.5)\n\n let pointCount: number\n let pointsData: this['state']['pointsData']\n let positions: Float32Array | null = null // to load; null leaves the simulation's\n let loadedPositions = this.state.loadedPositions\n let idToIndex = this.state.idToIndex ?? null\n\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n pointCount = pointArray.length\n pointsData = pointArray\n // Object points carry positions and ids together: a change reloads both\n if (firstLoad || pointsChanged) {\n positions = new Float32Array(pointCount * 2)\n idToIndex = getPointId ? new Map() : null\n for (let i = 0; i < pointCount; i += 1) {\n const point = pointArray[i] as PointDataT\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, point, info) : null\n positions[i * 2] = position ? position[0] : randomCoordinate()\n positions[i * 2 + 1] = position ? position[1] : randomCoordinate()\n if (idToIndex && getPointId) idToIndex.set(resolveAccessor(getPointId, point, info), i)\n }\n loadedPositions = pointArray\n } else if (idsChanged) {\n idToIndex = getPointId ? new Map() : null\n if (idToIndex && getPointId) {\n for (let i = 0; i < pointCount; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n idToIndex.set(resolveAccessor(getPointId, pointArray[i] as PointDataT, info), i)\n }\n }\n }\n } else {\n const binaryPoints = points as { length: number; initialPositions?: Float32Array; attributes?: CosmosPointAttributes }\n pointCount = binaryPoints.length\n pointsData = binaryPoints.attributes\n ? { length: pointCount, attributes: binaryPoints.attributes }\n : { length: pointCount }\n idToIndex = null\n // Positions reload when their input changed: another `initialPositions`\n // array, a seed the layer must draw again for a new count, or a first load\n const positionsInput: unknown = binaryPoints.initialPositions ?? SEEDED\n if (firstLoad || positionsInput !== this.state.loadedPositions || pointCount !== this.state.pointCount) {\n if (binaryPoints.initialPositions) {\n positions = binaryPoints.initialPositions\n } else {\n positions = new Float32Array(pointCount * 2)\n for (let i = 0; i < positions.length; i += 1) positions[i] = randomCoordinate()\n }\n loadedPositions = positionsInput\n }\n }\n\n let pairs: Float32Array | null = null // to load; null leaves the simulation's\n let linksData: this['state']['linksData'] = this.state.linksData\n let linkIndices: Float32Array | null = this.state.linkIndices\n if (links instanceof Float32Array || (links && !Array.isArray(links) && 'pairs' in links)) {\n const pairArray = links instanceof Float32Array ? links : links.pairs\n linksData = binaryLinksData(pairArray, links instanceof Float32Array ? undefined : links.attributes)\n linkIndices = null\n if (firstLoad || pairArray !== this.state.loadedPairs) pairs = pairArray\n } else if (Array.isArray(links)) {\n // Array links resolve against the loaded points, so they reload with them\n if (firstLoad || linksChanged || positions) {\n const linkObjects = links as readonly LinkDataT[]\n const { getLinkSource, getLinkTarget } = this.props\n // An endpoint is a point index, or a point id when the id map exists;\n // anything that does not name a point drops the whole link from both\n // the simulation and the rendering, so the two never disagree\n const resolveEndpoint = (endpoint: string | number): number | undefined => {\n const index = idToIndex ? idToIndex.get(endpoint) : endpoint\n return typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < pointCount\n ? index\n : undefined\n }\n const keptLinks: LinkDataT[] = []\n const keptIndices: number[] = []\n for (let i = 0; i < linkObjects.length; i += 1) {\n const link = linkObjects[i] as LinkDataT\n const info: AccessorContext<LinkDataT> = { index: i, data: linkObjects, target: [] }\n const source = resolveEndpoint(resolveAccessor(getLinkSource, link, info))\n const target = resolveEndpoint(resolveAccessor(getLinkTarget, link, info))\n if (source === undefined || target === undefined) continue\n keptLinks.push(link)\n keptIndices.push(source, target)\n }\n const dropped = linkObjects.length - keptLinks.length\n if (dropped > 0) {\n const hint = idToIndex ? 'getLinkSource / getLinkTarget against getPointId' : 'getLinkSource / getLinkTarget'\n console.warn(\n `@cosmos.gl/deck-layers: dropped ${dropped} of ${linkObjects.length} links whose source or target is not a point — check ${hint}`\n )\n }\n pairs = Float32Array.from(keptIndices)\n linkIndices = pairs\n linksData = keptLinks\n }\n } else {\n linksData = null\n linkIndices = null\n if (firstLoad || this.state.loadedPairs !== NO_LINKS) pairs = NO_LINKS\n }\n\n if (positions) simulation.setPointPositions(positions)\n if (pairs) simulation.setLinks(pairs)\n if (positions || pairs) simulation.applyData()\n\n this.setState({\n hasLoaded: true,\n pointCount,\n pointsData,\n linksData,\n linkIndices,\n followedLinks: undefined,\n loadedPositions,\n loadedPairs: pairs ?? this.state.loadedPairs,\n idToIndex,\n })\n }\n}\n"],"names":["BLEND_PARAMETERS","uniformBlock","cosmosPointsUniforms","DEFAULT_POINT_COLOR","vs","fs","defaultProps","_CosmosPointsLayer","Layer","project32","picking","params","_a","positionInfo","model","moduleProps","UNIT","Model","Geometry","CosmosPointsLayer","cosmosLinksUniforms","DEFAULT_LINK_COLOR","l","_CosmosLinksLayer","CosmosLinksLayer","resolveAccessor","accessor","object","info","steppedAt","binaryLinksData","pairs","attributes","SEEDED","NO_LINKS","_CosmosGraphLayer","CompositeLayer","device","timeline","time","props","oldProps","changeFlags","providedSimulation","simulationSwapped","simulation","triggers","pointsChanged","idsChanged","linksChanged","isReady","pointCount","pointsData","linksData","linkIndices","getPointSize","getPointColor","pointSizeUnits","getLinkColor","getLinkWidth","linkWidthUnits","layers","_","index","event","enablePointDrag","dragReheatAlpha","picked","_c","_b","draggedPointIndex","x","y","spaceSize","context","layer","provided","GraphSimulation","error","defaultConfigValues","force","links","unprojected","points","getPointId","getPointPosition","firstLoad","randomCoordinate","positions","loadedPositions","idToIndex","pointArray","i","point","position","binaryPoints","positionsInput","pairArray","linkObjects","getLinkSource","getLinkTarget","resolveEndpoint","endpoint","keptLinks","keptIndices","link","source","target","dropped","hint","CosmosGraphLayer"],"mappings":";;;AAYO,MAAMA,IAAmB;AAAA,EAC9B,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,OAAO;AAAA,EACP,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AACvB,GCnBMC,KAAe;AAAA;AAAA;AAAA;AAAA,GAkBRC,KAAuB;AAAA,EAClC,MAAM;AAAA,EACN,IAAID;AAAAA,EACJ,cAAc;AAAA,IACZ,mBAAmB;AAAA,IACnB,WAAW;AAAA,EAAA;AAEf,GCnBME,IAAwD,CAAC,IAAI,IAAI,KAAK,GAAG,GAEzEC;AAAAA;AAAAA,EAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA+DhBC;AAAAA;AAAAA,EAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAsDhBC,KAAqD;AAAA,EACzD,cAAc,EAAE,MAAM,YAAY,OAAO,EAAA;AAAA,EACzC,eAAe,EAAE,MAAM,YAAY,OAAOH,EAAA;AAAA,EAC1C,gBAAgB;AAAA,EAChB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AAmCkB,CAAO,OAAOV,EAAY,MAAM,wDAAwDW,CAAI;AAAA,UAAA;AAAA,QAEnI;AACA,QAAA9E,IAAQ,aAAa,KAAKyE,CAAW,GACrClD,IAAcvB,GACdsB,IAAYkD;AAAA,MACd;AAAA;AAEA,MAAAlD,IAAY,MACZC,IAAc,OACVgC,KAAa,KAAK,MAAM,gBAAgBpD,OAAUH,IAAQG;AAGhE,IAAIsD,KAAW3C,EAAW,kBAAkB2C,CAAS,GACjDzD,KAAOc,EAAW,SAASd,CAAK,IAChCyD,KAAazD,MAAOc,EAAW,UAAA,GAEnC,KAAK,SAAS;AAAA,MACZ,WAAW;AAAA,MACX,YAAAM;AAAA,MACA,YAAAC;AAAA,MACA,WAAAC;AAAA,MACA,aAAAC;AAAA,MACA,eAAe;AAAA,MACf,iBAAAmC;AAAA,MACA,aAAa1D,KAAS,KAAK,MAAM;AAAA,MACjC,WAAA2D;AAAA,IAAA,CACD;AAAA,EACH;AACF;AAjeEvD,EAAc,YAAY,oBAC1BA,EAAc,eAAe7B;AAJxB,IAAMwG,IAAN3E;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/cosmos-graph-layer.ts"],"sourcesContent":["import { COORDINATE_SYSTEM, Layer } from '@deck.gl/core'\nimport type {\n Accessor,\n AccessorContext,\n BinaryAttribute,\n Color,\n DefaultProps,\n GetPickingInfoParams,\n LayerContext,\n LayerProps,\n PickingInfo,\n UpdateParameters,\n Viewport,\n} from '@deck.gl/core'\nimport { Graph, defaultConfigValues } from '@cosmos.gl/graph'\nimport type { GraphConfig } from '@cosmos.gl/graph'\n\n/**\n * Binary styling channels for binary points, keyed by the accessor each one\n * replaces. Colors are RGBA per point, 4 values each: a `Uint8Array` in\n * 0..255 (deck's convention) is converted, a `Float32Array` is cosmos's own\n * 0..1 and is handed over as it is. Sizes are one value per point, handed\n * over as they are. Values are read tightly packed; `offset` and `stride` are\n * not honoured.\n */\nexport type CosmosPointAttributes = {\n getPointColor?: BinaryAttribute;\n getPointSize?: BinaryAttribute;\n}\n\n/**\n * Points input: an array to run accessors over, or the cosmos-native binary\n * form — a point count plus optional `[x0, y0, x1, y1, …]` initial positions\n * and binary styling channels. Points without given positions are seeded\n * randomly inside the simulation space.\n */\nexport type CosmosGraphPoints<PointDataT> = readonly PointDataT[] | {\n length: number;\n initialPositions?: Float32Array;\n attributes?: CosmosPointAttributes;\n}\n\n/**\n * Binary styling channels for binary links, keyed by the accessor each one\n * replaces, with the same conventions as `CosmosPointAttributes`: colors a\n * `Uint8Array` in 0..255 or a `Float32Array` in 0..1, widths one per link.\n */\nexport type CosmosLinkAttributes = {\n getLinkColor?: BinaryAttribute;\n getLinkWidth?: BinaryAttribute;\n}\n\n/**\n * Links input: an array to run accessors over, the cosmos-native\n * `[source0, target0, source1, target1, …]` array of point indices, or that\n * array as `pairs` with binary styling channels beside it. An array link whose\n * source or target does not resolve to a point is dropped, with one warning\n * per data change; a pair that names no point is skipped by the engine and\n * keeps its index.\n */\nexport type CosmosGraphLinks<LinkDataT> = readonly LinkDataT[] | Float32Array | {\n pairs: Float32Array;\n attributes?: CosmosLinkAttributes;\n}\n\n/**\n * The cosmos.gl config keys deck owns in this embedding — the canvas, the view\n * and its zoom, the frame loop, the pointer and its callbacks. The layer strips\n * them from `config`: deck's view state, controller, event callbacks and\n * `useDevicePixels` are the way to those things.\n */\nexport const DECK_OWNED_CONFIG_KEYS = [\n 'enableRenderLoop', 'backgroundColor', 'pixelRatio', 'showFPSMonitor', 'attribution',\n 'hoveredPointCursor', 'hoveredLinkCursor',\n 'initialZoomLevel', 'enableZoom', 'enableSimulationDuringZoom', 'enableDrag',\n 'fitViewOnInit', 'fitViewDelay', 'fitViewPadding', 'fitViewDuration', 'fitViewByPointsInRect', 'fitViewByPointIndices',\n 'simulationRepulsionFromMouse', 'enableRightClickRepulsion',\n 'onClick', 'onPointClick', 'onLinkClick', 'onBackgroundClick',\n 'onContextMenu', 'onPointContextMenu', 'onLinkContextMenu', 'onBackgroundContextMenu',\n 'onMouseMove', 'onPointMouseOver', 'onPointMouseOut', 'onLinkMouseOver', 'onLinkMouseOut',\n 'onZoomStart', 'onZoom', 'onZoomEnd', 'onDragStart', 'onDrag', 'onDragEnd',\n] as const satisfies readonly (keyof GraphConfig)[]\n\n/**\n * cosmos.gl's configuration as the layer takes it: every key of `GraphConfig`\n * except the ones deck owns (`DECK_OWNED_CONFIG_KEYS`). Rendering keys work as\n * in cosmos.gl, because cosmos.gl does the rendering. The transition keys have\n * no effect: a headless `Graph` applies data changes at once.\n */\nexport type CosmosGraphLayerConfig = Omit<GraphConfig, (typeof DECK_OWNED_CONFIG_KEYS)[number]>\n\n/**\n * What `onGraphDataLoaded` reports: the graph, what the load replaced, and how\n * your data maps to the graph's point and link indices. Per-point and per-link\n * arrays you hand the graph (`setLinkStrength`, `setPointShapes`,\n * `setPointClusters`, …) follow those indices. `links` and `pointIndexById`\n * are the layer's own state: read or copy them, never mutate them.\n */\nexport type CosmosGraphDataLoadedInfo<LinkDataT = unknown> = {\n /** The graph the data was loaded into: layer-created or provided. */\n graph: Graph;\n /**\n * The point positions were replaced, and with them possibly the point count.\n * Per-point arrays sent before this load may no longer line up.\n */\n pointsLoaded: boolean;\n /**\n * The links were replaced. Per-link arrays sent before this load may no longer\n * line up: the engine reuses the last one it was sent whenever its length\n * matches the new link count, in the old order.\n */\n linksLoaded: boolean;\n /**\n * Point `i` is always entry `i` of `points` (or pair `i` of `initialPositions`).\n * With array points and `getPointId`, this maps each id to its index; a repeated\n * id maps to its last point. Otherwise `null`.\n */\n pointIndexById: ReadonlyMap<string | number, number> | null;\n /**\n * Array links: the links the graph holds, in its order — link `i` is\n * `info.links[i]`. Links whose endpoints name no point are not among them, so\n * an index into your `links` array can differ. Binary links, or no `links`\n * prop: `null`, and link `i` is pair `i` of your pair array.\n */\n links: readonly LinkDataT[] | null;\n}\n\n/**\n * Picking info from a CosmosGraphLayer: which kind of element was hit, with `index`\n * counting within that kind (point `i` or link `i`), and `object` the original record\n * for array data.\n */\nexport type CosmosGraphPickingInfo = PickingInfo & {\n elementType?: 'point' | 'link';\n}\n\nexport type CosmosGraphLayerProps<PointDataT = unknown, LinkDataT = unknown> =\n CosmosGraphLayerOwnProps<PointDataT, LinkDataT> & LayerProps\n\ntype CosmosGraphLayerOwnProps<PointDataT, LinkDataT> = {\n /**\n * One entry per point — an array of your objects, or `{ length, initialPositions?, attributes? }`.\n * The layer loads them, with `links` and the styling accessors, into the graph. Omit it to\n * draw the data the graph already holds instead: the layer then writes nothing into the\n * graph, styling accessors included — the mode for an application-loaded `graph`.\n */\n points?: CosmosGraphPoints<PointDataT> | null;\n /** One entry per link — an array of your objects, or a flat point-index pair array. Ignored without `points`. */\n links?: CosmosGraphLinks<LinkDataT> | null;\n /**\n * Stable point id accessor. When provided (with array points), link\n * accessors may return ids instead of point indices.\n */\n getPointId?: Accessor<PointDataT, string | number> | null;\n /**\n * Initial `[x, y]` position accessor for array points, in cosmos space\n * coordinates; points it leaves undefined are seeded randomly.\n */\n getPointPosition?: Accessor<PointDataT, readonly [number, number] | null | undefined> | null;\n /**\n * Point size accessor, in cosmos.gl's units: pixels at zoom 1, scaled with the view\n * when `config.scalePointsOnZoom` is on, times `config.pointSizeScale`. `0` hides the point.\n * Unset, every point draws `config.pointDefaultSize`.\n * @default null\n */\n getPointSize?: Accessor<PointDataT, number> | null;\n /**\n * Point RGBA color accessor, channels in 0..255 (deck's convention; converted for cosmos).\n * Unset, every point draws `config.pointDefaultColor`.\n * @default null\n */\n getPointColor?: Accessor<PointDataT, Color> | null;\n /**\n * Source accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.source\n */\n getLinkSource?: Accessor<LinkDataT, string | number>;\n /**\n * Target accessor for array links: a point index, or a point id when\n * `getPointId` is set.\n * @default l => l.target\n */\n getLinkTarget?: Accessor<LinkDataT, string | number>;\n /**\n * Link RGBA color accessor, channels in 0..255. Unset, every link draws\n * `config.linkDefaultColor`.\n * @default null\n */\n getLinkColor?: Accessor<LinkDataT, Color> | null;\n /**\n * Link width accessor, in cosmos.gl's units (see `config.scaleLinksOnZoom`, `config.linkWidthScale`).\n * Unset, every link draws `config.linkDefaultWidth`.\n * @default null\n */\n getLinkWidth?: Accessor<LinkDataT, number> | null;\n /**\n * Lets pointer drags grab a point: pinned on drag start, moved with the pointer,\n * released per `unpinOnDragEnd`. View panning is suppressed while a point is\n * grabbed. Needs `pickable`.\n * @default false\n */\n enablePointDrag?: boolean;\n /**\n * Simulation alpha to restart with when a drag starts, so the graph responds\n * to the moving point; `null` leaves the simulation untouched.\n * @default 0.1\n */\n dragReheatAlpha?: number | null;\n /**\n * Release the point on drag end; `false` keeps it pinned where dropped.\n * @default true\n */\n unpinOnDragEnd?: boolean;\n /** Called when a point drag starts. */\n onPointDragStart?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called for every pointer move while a point is dragged. */\n onPointDrag?: ((info: CosmosGraphPickingInfo) => void) | null;\n /** Called when a point drag ends. */\n onPointDragEnd?: ((info: CosmosGraphPickingInfo) => void) | null;\n /**\n * cosmos.gl's configuration — forces, space size, rendering options such as\n * `curvedLinks`, `pointDefaultShape`, `linkDefaultArrows`, the simulation\n * callbacks — passed to the layer-created `Graph`. A key left out goes back\n * to the engine default. Ignored when `graph` is provided.\n */\n config?: CosmosGraphLayerConfig;\n /**\n * An application-owned headless `Graph` to draw instead of creating one:\n * `new Graph(null, config, devicePromise)` with the device from deck's\n * `onDeviceInitialized`. The layer steps it while it runs (`pause()` it to\n * take over stepping, then `deck.redraw()` after each manual `step()`) and\n * draws it; it never configures or destroys it — `config` and\n * `onGraphCreated` apply only to a layer-created graph, and teardown is the\n * application's, before `deck.finalize()`.\n *\n * `points` decides who loads the data. Given, the layer loads `points`,\n * `links` and the styling accessors into the graph once the device check has\n * passed, over whatever it held. Omitted, the layer draws the graph's own\n * data and writes nothing. Several layers may draw one graph — it steps once\n * per frame however many draw it — as long as at most one of them loads data.\n */\n graph?: Graph | null;\n /**\n * Called once with the layer-created `Graph` — the whole cosmos.gl API for\n * what the props do not cover: pause, pin, reheat, shapes, clusters, trackers,\n * sparse position writes. Not called for a provided `graph`.\n */\n onGraphCreated?: ((graph: Graph) => void) | null;\n /**\n * Called after each load of `points` or `links` into the graph, once the\n * graph holds the new data — and, with both load flags `false`, when only the\n * id map changed. Use it to send what lines up with the graph's indices —\n * link strengths, shapes, arrows, clusters, pins — again after a reload:\n * `info.pointIndexById` and `info.links` map your data to those indices.\n * Not called when the layer draws a graph's own data (no `points`).\n *\n * The first call comes when the graph is ready (and again after a `graph`\n * swap), later ones during deck's layer update. Calls on `info.graph` are\n * fine in either; defer anything that changes layer props. A throw goes to\n * deck's `onError`, and the load stands.\n */\n onGraphDataLoaded?: ((info: CosmosGraphDataLoadedInfo<LinkDataT>) => void) | null;\n}\n\n/**\n * deck's accessor check takes a function, or a constant of the default's type. A style\n * accessor defaults to unset, so its check also takes the constant: a number or a color.\n */\nconst isStyleAccessor = (constant: 'number' | 'color') => (value: unknown): boolean =>\n value == null || typeof value === 'function' ||\n (constant === 'number' ? typeof value === 'number' : Array.isArray(value) || ArrayBuffer.isView(value))\n\nconst defaultProps: DefaultProps<CosmosGraphLayerProps> = {\n points: { type: 'object', value: null, optional: true },\n links: null,\n getPointId: { type: 'accessor', value: null },\n getPointPosition: { type: 'accessor', value: null },\n getPointSize: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n getPointColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkSource: { type: 'accessor', value: (l: unknown) => (l as { source: number }).source },\n getLinkTarget: { type: 'accessor', value: (l: unknown) => (l as { target: number }).target },\n getLinkColor: { type: 'accessor', value: null, validate: isStyleAccessor('color') },\n getLinkWidth: { type: 'accessor', value: null, validate: isStyleAccessor('number') },\n enablePointDrag: false,\n dragReheatAlpha: 0.1,\n unpinOnDragEnd: true,\n onPointDragStart: { type: 'function', value: null, optional: true },\n onPointDrag: { type: 'function', value: null, optional: true },\n onPointDragEnd: { type: 'function', value: null, optional: true },\n config: { type: 'object', value: {}, compare: 2 },\n graph: { type: 'object', value: null, optional: true },\n onGraphCreated: { type: 'function', value: null, optional: true },\n onGraphDataLoaded: { type: 'function', value: null, optional: true },\n // cosmos draws its space coordinates as world coordinates; `modelMatrix` places the space\n coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,\n}\n\n/** The slice of a deck gesture event the drag handlers need. */\ntype DragGestureEvent = {\n stopImmediatePropagation?: () => void;\n}\n\n/** The update-trigger keys the layer reads. */\ntype CosmosUpdateTriggers = {\n all?: unknown;\n getPointId?: unknown;\n getPointPosition?: unknown;\n getPointSize?: unknown;\n getPointColor?: unknown;\n getLinkSource?: unknown;\n getLinkTarget?: unknown;\n getLinkColor?: unknown;\n getLinkWidth?: unknown;\n}\n\n/** Resolves a deck accessor (function or constant) for one object. */\nconst resolveAccessor = <In, Out>(accessor: Accessor<In, Out>, object: In, info: AccessorContext<In>): Out =>\n typeof accessor === 'function' ? (accessor as (o: In, i: AccessorContext<In>) => Out)(object, info) : accessor\n\n/**\n * As deck compares its own accessors: replacing a function counts only through\n * the update trigger; replacing a constant, or switching to or from one, counts.\n */\nconst accessorReplaced = (next: unknown, previous: unknown): boolean =>\n next !== previous && !(typeof next === 'function' && typeof previous === 'function')\n\n/** deck's `compare: 2` for the config: keys shallow, arrays by element. */\nconst configEquals = (a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean => {\n if (a === b) return true\n if (!a || !b) return false\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false\n return keys.every((key) => {\n const x = a[key]\n const y = b[key]\n if (Array.isArray(x) && Array.isArray(y)) return x.length === y.length && x.every((v, i) => v === y[i])\n return x === y\n })\n}\n\n/**\n * RGBA per element as cosmos takes it (0..1), from a binary attribute or an\n * accessor. A `Float32Array` attribute is cosmos's own form and passes through.\n */\nconst toColorArray = <In>(\n count: number,\n accessor: Accessor<In, Color> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>, (channel) => channel / 255)\n }\n const colors = new Float32Array(count * 4)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n const color = resolveAccessor(accessor as Accessor<In, Color>, objects?.[i] as In, { index: i, data, target: [] })\n colors[i * 4] = (color[0] as number) / 255\n colors[i * 4 + 1] = (color[1] as number) / 255\n colors[i * 4 + 2] = (color[2] as number) / 255\n colors[i * 4 + 3] = (color[3] ?? 255) / 255\n }\n return colors\n}\n\n/** One value per element, from a binary attribute (passed through) or an accessor. */\nconst toValueArray = <In>(\n count: number,\n accessor: Accessor<In, number> | null,\n objects: readonly In[] | null,\n attribute: BinaryAttribute | undefined\n): Float32Array => {\n if (attribute) {\n const { value } = attribute\n return value instanceof Float32Array ? value : Float32Array.from(value as ArrayLike<number>)\n }\n const values = new Float32Array(count)\n const data = objects ?? { length: count }\n for (let i = 0; i < count; i += 1) {\n values[i] = resolveAccessor(accessor as Accessor<In, number>, objects?.[i] as In, { index: i, data, target: [] })\n }\n return values\n}\n\n/**\n * When each graph last stepped, by timeline time: layers drawing the same graph\n * share one step per frame instead of each taking their own.\n */\nconst steppedAt = new WeakMap<Graph, number>()\n\n/**\n * Bounds reads on their way per graph, from every layer drawing it: while one is, no layer\n * steps the graph, or the read would wait for the step (`getBounds`).\n */\nconst pendingBoundsReads = new WeakMap<Graph, number>()\n\n/**\n * Unseeded points are drawn in the middle half of the space, around the world origin\n * gravity pulls toward: these fractions of the engine's `spaceSize`. A default placement,\n * not a bound; `_load` draws inside it and `getBounds` reports it before anything settles.\n */\nconst UNSEEDED_PLACEMENT: readonly [number, number] = [0.25, 0.75]\n\n/**\n * The length `_viewTransform` projects to read deck's scale: any length long enough for the\n * projected pixels to resolve it does, so it is not tied to the engine.\n */\nconst VIEW_PROBE_LENGTH = 4096\n\n/**\n * A present point's coordinate as the engine stores it: rounded to float32, an infinity\n * (also one the rounding makes) on the matching edge — `0` or `infiniteEdge`, the engine's\n * `toFiniteCoordinate` in position-utils, which is not public. The edge is the space's\n * width today; a bad-input rule, not a bound.\n */\nconst toEngineCoordinate = (value: number, infiniteEdge: number): number => {\n const rounded = Math.fround(value)\n if (rounded === Infinity) return infiniteEdge\n if (rounded === -Infinity) return 0\n return rounded\n}\n\n/** A 2D bounding box grown one point at a time; non-finite points are left out. */\nclass BoundsBox {\n private minX = Infinity\n private minY = Infinity\n private maxX = -Infinity\n private maxY = -Infinity\n\n public add (x: number, y: number): void {\n if (!Number.isFinite(x) || !Number.isFinite(y)) return\n if (x < this.minX) this.minX = x\n if (x > this.maxX) this.maxX = x\n if (y < this.minY) this.minY = y\n if (y > this.maxY) this.maxY = y\n }\n\n /** Layer.getBounds' shape, z = 0; `null` when no point was added. */\n public bounds (): [number[], number[]] | null {\n if (this.minX > this.maxX) return null\n return [[this.minX, this.minY, 0], [this.maxX, this.maxY, 0]]\n }\n}\n\n/** What the layer loaded when binary points carried no `initialPositions`: a seed of its own. */\nconst SEEDED = Symbol('seeded')\nconst NO_LINKS = new Float32Array(0)\n/** An empty style array: the engine takes it as no data and draws the config default. */\nconst NO_STYLE = new Float32Array(0)\n\n/** A style channel is the app's per-element data when an accessor or a binary attribute gives it. */\nconst isChannelSet = (accessor: unknown, attribute: BinaryAttribute | undefined): boolean =>\n accessor != null || attribute != null\n\n/** The binary styling channels of a `points` prop, if it is in binary form. */\nconst pointAttributesOf = (points: unknown): CosmosPointAttributes | undefined =>\n points && !Array.isArray(points) ? (points as { attributes?: CosmosPointAttributes }).attributes : undefined\n\n/** The binary styling channels of a `links` prop, if it is `{ pairs, attributes }`. */\nconst linkAttributesOf = (links: unknown): CosmosLinkAttributes | undefined =>\n links && !Array.isArray(links) && !(links instanceof Float32Array)\n ? (links as { attributes?: CosmosLinkAttributes }).attributes\n : undefined\n\n/**\n * The cosmos.gl graph layer: give it points and links, and cosmos.gl lays them\n * out and draws them under deck's camera. The layer creates a headless `Graph`\n * on deck's device (or draws the application's, via `graph`), loads the data —\n * or, without `points`, leaves the graph's own data alone — advances the\n * simulation once per animation frame from deck's shared timeline while it runs\n * (deck goes idle when it settles), hands deck's view to cosmos.gl before each\n * draw and records cosmos.gl's own point and link draws into deck's render\n * pass. Everything cosmos.gl renders is available through `config` and the\n * `Graph` handle: shapes, arrows, dashes, curves, greyout, rings.\n *\n * The view: cosmos.gl's is a uniform scale plus a translation with y up, so\n * the layer draws under an `OrthographicView({ flipY: false })` or a map view\n * at pitch 0 and bearing 0, with `modelMatrix` placing the space in the world.\n * A rotated, pitched or y-down view is reported once and not drawn.\n *\n * Picking is deck's: in deck's pick pass cosmos.gl draws its picking colors\n * (an index per point and per link, hard-edged), so `pickable` gives hover and\n * click with `info.elementType`, `info.index` and, for array data, `info.object`.\n * `autoHighlight` lights the hovered point or link with cosmos.gl's own hover\n * ring and hovered-link width (`config.hoveredPointRingColor`,\n * `config.hoveredLinkWidthIncrease`, `config.hoveredLinkColor`) and leaves focus\n * to the application; `highlightColor` is not used.\n * `enablePointDrag` grabs a point and moves it, on a map as well.\n */\nexport class CosmosGraphLayer<PointDataT = unknown, LinkDataT = unknown> extends Layer<\n Required<CosmosGraphLayerOwnProps<PointDataT, LinkDataT>>\n> {\n public static layerName = 'CosmosGraphLayer'\n public static defaultProps = defaultProps\n\n declare public state: {\n graph?: Graph;\n /** The `graph` prop this state was built from; `null` when the layer created its own. */\n providedGraph: Graph | null;\n isReady: boolean;\n /** `points` changed before the graph was ready: load them once it is. */\n isIngestPending: boolean;\n pointCount: number;\n linkCount: number;\n /**\n * Load mode: what the graph holds, so a channel reloads only when its own input\n * changes and a restyle leaves the layout alone. `loadedPositions` is the\n * `initialPositions` array, `SEEDED`, or the points array; `loadedPairs` the pair\n * array sent last; `idToIndex` the id map of the loaded points; `keptLinks` the\n * array links the graph holds, in its order.\n */\n hasLoaded: boolean;\n loadedPositions?: unknown;\n loadedPairs?: Float32Array | null;\n idToIndex?: Map<string | number, number> | null;\n keptLinks: readonly LinkDataT[] | null;\n /**\n * `getBounds`' measured box: the last one read back (`null` when nothing finite was\n * there), the position texture version it was asked at, and whether a read is on its\n * way. Unset until the first read lands, and again when a new dataset is loaded. The\n * serial counts the datasets loaded: a read of the previous one that lands after the\n * next is dropped.\n */\n measuredBounds?: [number[], number[]] | null;\n measuredBoundsVersion?: number;\n isMeasuringBounds?: boolean;\n loadSerial?: number;\n /** The view was found unsupported and said so; said once. */\n viewWarned?: boolean;\n linksWarned?: boolean;\n draggedPointIndex: number | null;\n /**\n * This layer's last auto-highlight write was a hover. Several layers may draw one\n * graph, and the hover lives on the graph: only the layer holding it clears it.\n */\n holdsHover: boolean;\n animationHandle?: number;\n }\n\n public get isLoaded (): boolean {\n return super.isLoaded && Boolean(this.state?.isReady)\n }\n\n public initializeState (): void {\n const { device, timeline } = this.context\n if (device.type !== 'webgl') {\n throw new Error(\n `@cosmos.gl/deck-layers requires a WebGL 2 device — cosmos.gl is WebGL-only, got '${device.type}'`\n )\n }\n\n this.state = {\n providedGraph: null,\n isReady: false,\n isIngestPending: false,\n hasLoaded: false,\n pointCount: 0,\n linkCount: 0,\n keptLinks: null,\n draggedPointIndex: null,\n holdsHover: false,\n // Step the simulation exactly once per animation frame, independent of\n // draw passes (draw runs per viewport)\n animationHandle: timeline.attachAnimation({ setTime: (time) => this._onTimelineTick(time) }),\n }\n this._attachGraph(this.props.graph ?? null)\n }\n\n public updateState (params: UpdateParameters<this>): void {\n super.updateState(params)\n const { props, oldProps, changeFlags } = params\n // Swapping graphs loads the current data into the new one, or follows it\n const providedGraph = props.graph ?? null\n const graphSwapped = providedGraph !== this.state.providedGraph\n if (graphSwapped) {\n this._releaseGraph()\n this._attachGraph(providedGraph)\n }\n const graph = this.state.graph\n if (!graph) return\n\n if (!providedGraph && !graphSwapped && !configEquals(props.config, oldProps.config)) {\n // Graph.setConfig starts from the defaults: a key left out goes back to its default\n graph.setConfig(this._graphConfig())\n }\n\n const triggers = typeof changeFlags.updateTriggersChanged === 'object'\n ? changeFlags.updateTriggersChanged as CosmosUpdateTriggers\n : undefined\n const triggered = (key: keyof CosmosUpdateTriggers): boolean => Boolean(triggers?.all || triggers?.[key])\n // Array links resolve against the id map and the position accessor at load,\n // so a change to either counts as a change of that channel\n const pointsChanged = graphSwapped || props.points !== oldProps.points || triggered('getPointPosition')\n const idsChanged = triggered('getPointId')\n const linksChanged = graphSwapped || props.links !== oldProps.links ||\n triggered('getLinkSource') || triggered('getLinkTarget') || idsChanged\n // Styles follow their accessors (a constant by value, a function by trigger) and\n // ride along with a new points or links object, which may carry new attributes\n const pointStyleChanged = pointsChanged || triggered('getPointColor') || triggered('getPointSize') ||\n accessorReplaced(props.getPointColor, oldProps.getPointColor) || accessorReplaced(props.getPointSize, oldProps.getPointSize)\n const linkStyleChanged = linksChanged || triggered('getLinkColor') || triggered('getLinkWidth') ||\n accessorReplaced(props.getLinkColor, oldProps.getLinkColor) || accessorReplaced(props.getLinkWidth, oldProps.getLinkWidth)\n if (!pointsChanged && !linksChanged && !pointStyleChanged && !linkStyleChanged) return\n\n // A channel the layer uploaded and the app no longer gives goes back to the config\n // default. Only the layer's own upload is cleared: it had data to load (`points`) on\n // this graph, so an array the application set itself is never touched\n const uploaded = Boolean(oldProps.points) && !graphSwapped\n const oldPoints = pointAttributesOf(oldProps.points)\n const newPoints = pointAttributesOf(props.points)\n const oldLinks = linkAttributesOf(oldProps.links)\n const newLinks = linkAttributesOf(props.links)\n const stopped = (before: boolean, now: boolean): boolean => uploaded && before && !now\n const unsetChannels = {\n pointColorUnset: stopped(isChannelSet(oldProps.getPointColor, oldPoints?.getPointColor), isChannelSet(props.getPointColor, newPoints?.getPointColor)),\n pointSizeUnset: stopped(isChannelSet(oldProps.getPointSize, oldPoints?.getPointSize), isChannelSet(props.getPointSize, newPoints?.getPointSize)),\n linkColorUnset: stopped(isChannelSet(oldProps.getLinkColor, oldLinks?.getLinkColor), isChannelSet(props.getLinkColor, newLinks?.getLinkColor)),\n linkWidthUnset: stopped(isChannelSet(oldProps.getLinkWidth, oldLinks?.getLinkWidth), isChannelSet(props.getLinkWidth, newLinks?.getLinkWidth)),\n }\n\n if (props.points) {\n // The layer's data goes into the graph — once the device check has passed\n if (this.state.isReady) this._load({ pointsChanged, linksChanged, idsChanged, pointStyleChanged, linkStyleChanged, ...unsetChannels })\n else this.state.isIngestPending = true\n } else {\n // No data of its own: the layer draws what the graph holds and writes nothing\n if (props.links && !this.state.linksWarned) {\n this.state.linksWarned = true\n console.warn('@cosmos.gl/deck-layers: `links` is ignored without `points` — load them into the graph instead')\n }\n this.state.isIngestPending = false\n this.state.hasLoaded = false\n }\n }\n\n public draw (opts: {\n shaderModuleProps?: { picking?: { isActive?: number | boolean } };\n parameters?: { blendColor?: number[] };\n }): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n\n const { viewport } = this.context\n const view = this._viewTransform(graph, viewport)\n if (!view) return\n graph.setViewTransform(view, [viewport.width, viewport.height])\n if (opts.shaderModuleProps?.picking?.isActive) {\n // deck's pick pass: cosmos draws its picking colors with the alpha deck uses to tell\n // layers apart (the pass's blend constant), links offset past the points so one layer\n // carries both index spaces — getPickingInfo splits them again\n graph.drawToRenderPass(this.context.renderPass, {\n picking: {\n alpha: opts.parameters?.blendColor?.[3] ?? 1,\n linkIndexOffset: graph.graph.pointsNumber ?? 0,\n },\n })\n return\n }\n graph.drawToRenderPass(this.context.renderPass)\n }\n\n public getPickingInfo ({ info }: GetPickingInfoParams): CosmosGraphPickingInfo {\n const picked: CosmosGraphPickingInfo = info\n const graph = this.state.graph\n if (!graph || info.index < 0) return picked\n const pointCount = graph.graph.pointsNumber ?? 0\n const { points, links } = this.props\n if (info.index >= pointCount) {\n picked.elementType = 'link'\n picked.index = info.index - pointCount\n picked.object = Array.isArray(links) ? this.state.keptLinks?.[picked.index] : undefined\n } else {\n picked.elementType = 'point'\n picked.object = Array.isArray(points) ? points[info.index] : undefined\n }\n return picked\n }\n\n public onDragStart (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph } = this.state\n const { enablePointDrag, dragReheatAlpha } = this.props\n const picked = info as CosmosGraphPickingInfo\n if (!enablePointDrag || !graph || picked.elementType !== 'point' || info.index < 0) return false\n\n // A direct field write: per-gesture state must not re-run the layer's update\n this.state.draggedPointIndex = info.index\n graph.setPinnedPoint(info.index, true)\n if (dragReheatAlpha !== null) graph.start(dragReheatAlpha)\n // A grabbed point must not also pan the view\n event.stopImmediatePropagation?.()\n this.props.onPointDragStart?.(picked)\n return true\n }\n\n public onDrag (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n const position = this._dragPosition(graph, info)\n if (position) graph.setPointPosition(draggedPointIndex, position[0], position[1])\n event.stopImmediatePropagation?.()\n // Repaint even when the simulation is settled and the ticker is idle\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n this.props.onPointDrag?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n public onDragEnd (info: PickingInfo, event: DragGestureEvent): boolean {\n const { graph, draggedPointIndex } = this.state\n if (!graph || draggedPointIndex === null) return false\n\n if (this.props.unpinOnDragEnd) graph.setPinnedPoint(draggedPointIndex, false)\n this.state.draggedPointIndex = null\n event.stopImmediatePropagation?.()\n this.props.onPointDragEnd?.(info as CosmosGraphPickingInfo)\n return true\n }\n\n /**\n * The box around the graph's points, `[[minX, minY, 0], [maxX, maxY, 0]]`, for an\n * application to frame the layer with. In space coordinates, before `modelMatrix`: map it\n * through `modelMatrix` (and, on a map, unproject it) before fitting a viewport to it.\n * deck.gl's core does not call it; its mask effect reads it from every mask layer and its\n * collision-filter effect from every layer carrying that extension, each on every frame.\n *\n * `spaceSize` bounds no position — a layout grows past its square as far as its forces\n * take it — so the box is measured from the live positions, read back from the GPU. The\n * read does not stall the frame: it is asynchronous, started by a call that finds the\n * positions changed since the box was measured, one at a time, and the box it returns is\n * the last one measured. While a read is on its way the layer holds the graph's step, as\n * the engine's own render loop holds its frame for a copy: the read that completes a copy\n * waits for every command queued before it, and a step queued behind the copy would be\n * that wait. (A graph the application steps itself is not held.) While points move the\n * box trails the drawn frame, by a frame or so, and a call made before the first read\n * lands — or before the first read of a newly loaded dataset — gets the input box below.\n * When a read lands the layer asks for a redraw, so a consumer reading the box every\n * frame has the new one on the next. A layer nobody asks reads nothing. Absent points\n * (NaN) are left out.\n *\n * Until the graph holds positions (its device is still initializing) or the first read\n * has landed, the box is that of the positions the layer is about to load or has loaded:\n * `initialPositions`, or `getPointPosition` over the point objects, plus the middle half\n * of the space where unseeded points are placed — where the points start, so a view can\n * be framed before the first frame.\n *\n * When there is nothing to measure — no points yet, every point absent, or positions the\n * graph rescales on load (`rescalePositions: true`), which it centres on the space — the\n * box is the space's square, `[[0, 0, 0], [spaceSize, spaceSize, 0]]`: where the graph\n * starts, and what this method returned before layouts could leave the square. It is\n * never `null`; the declared type keeps deck's `Layer.getBounds` contract, so a subclass\n * may still override it with deck's own signature.\n */\n public getBounds (): [number[], number[]] | null {\n const { state } = this\n const graph = state?.graph\n const positions = graph?.getPointPositionTexture()\n if (graph && positions && positions.pointCount > 0) {\n if (positions.version !== state.measuredBoundsVersion && !state.isMeasuringBounds) this._measureBounds(graph, positions.version)\n if (state.measuredBounds !== undefined) return state.measuredBounds ?? this._spaceSquare()\n }\n const box = new BoundsBox()\n this._addInputPositions(box)\n return box.bounds() ?? this._spaceSquare()\n }\n\n public finalizeState (context: LayerContext): void {\n if (this.state?.animationHandle !== undefined) {\n this.context.timeline.detachAnimation(this.state.animationHandle)\n }\n if (this.state) this._releaseGraph()\n super.finalizeState(context)\n }\n\n /** No deck attributes: cosmos.gl holds every channel and draws them itself. */\n protected _getAttributeManager (): null {\n return null\n }\n\n /**\n * deck's auto-highlight, through cosmos.gl's own hover emphasis: the hovered point\n * gets the hover ring, the hovered link the hovered-link width and color. It is the\n * graph's host hover, so the graph's config — focus included — stays the\n * application's. deck's picking module has no model of ours to tint, so\n * `highlightColor` does not apply.\n */\n protected _updateAutoHighlight (info: PickingInfo): void {\n const { graph, isReady } = this.state\n if (!graph || !isReady) return\n const type = info.picked && info.index >= 0 ? (info as CosmosGraphPickingInfo).elementType : undefined\n const pointIndex = type === 'point' ? info.index : undefined\n const linkIndex = type === 'link' ? info.index : undefined\n graph.setHostHoveredPoint(pointIndex)\n graph.setHostHoveredLink(linkIndex)\n // A direct field write, as for a drag: hover state must not re-run the layer's update\n this.state.holdsHover = pointIndex !== undefined || linkIndex !== undefined\n this.setNeedsRedraw()\n }\n\n /**\n * The pointer in space coordinates, through the view of the viewport the pointer\n * is in — the same derivation `draw` hands cosmos, inverted — under a map as well\n * as an orthographic view. Not through the view cosmos holds: that is whichever\n * viewport drew the graph last, a thumbnail's as easily as the one being dragged\n * in. Pixels are relative to that viewport. Where the view cannot be derived the\n * point stays where it is.\n */\n private _dragPosition (graph: Graph, info: PickingInfo): [number, number] | null {\n const viewport = info.viewport ?? this.context.viewport\n const view = this._viewTransform(graph, viewport)\n if (!view) return null\n // Space is y up; the space origin's pixel and the scale are the whole affine map\n return [(info.x - viewport.x - view.originX) / view.k, (view.originY - (info.y - viewport.y)) / view.k]\n }\n\n /** Adopts the provided graph, or creates a headless one on deck's device when `provided` is `null`. */\n private _attachGraph (provided: Graph | null): void {\n const { device } = this.context\n const graph = provided ?? new Graph(null, this._graphConfig(), Promise.resolve(device))\n this.setState({\n graph,\n providedGraph: provided,\n isReady: false,\n hasLoaded: false,\n loadedPositions: undefined,\n loadedPairs: null,\n idToIndex: null,\n keptLinks: null,\n })\n\n if (!provided) this.props.onGraphCreated?.(graph)\n\n graph.ready.then(() => {\n // `this` may be a stale descriptor by now; state is the stable identity\n if (this.state?.graph !== graph) return\n const layer = (this.getCurrentLayer() ?? this) as CosmosGraphLayer<PointDataT, LinkDataT>\n // cosmos records its draws into deck's render pass: that needs deck's device\n if (graph.simulation.device !== layer.context.device) {\n console.error(\n '@cosmos.gl/deck-layers: the provided graph runs on a different device than deck — construct it with the device from deck\\'s onDeviceInitialized'\n )\n return\n }\n // Only now may the layer touch the graph's data\n if (layer.state.isIngestPending) {\n layer.state.isIngestPending = false\n layer._load({\n pointsChanged: true,\n linksChanged: true,\n idsChanged: true,\n pointStyleChanged: true,\n linkStyleChanged: true,\n pointColorUnset: false,\n pointSizeUnset: false,\n linkColorUnset: false,\n linkWidthUnset: false,\n })\n }\n layer.setState({ isReady: true })\n }).catch((error: Error) => {\n console.error('@cosmos.gl/deck-layers: the graph failed to initialize', error)\n })\n }\n\n /**\n * Destroys a layer-created graph; a provided one is left to the application, without\n * the hover this layer put on it. deck sends no leave to a layer it removes.\n */\n private _releaseGraph (): void {\n const { graph, providedGraph, holdsHover } = this.state\n if (graph && providedGraph) {\n if (holdsHover) {\n graph.setHostHoveredPoint(undefined)\n graph.setHostHoveredLink(undefined)\n }\n } else if (graph) graph.destroy()\n this.state.graph = undefined\n this.state.holdsHover = false\n // Another graph's texture versions would not mean the same box\n this.state.measuredBounds = undefined\n this.state.measuredBoundsVersion = undefined\n this.state.isMeasuringBounds = false\n }\n\n /**\n * Starts one asynchronous read of the live positions and keeps its box for `getBounds`,\n * stamped with the texture version the read was asked at. A read that lands after the\n * layer let go of the graph is dropped; an empty result (nothing to read, or the point\n * count changed under the copy) leaves the box as it was, and the next call asks again.\n */\n private _measureBounds (graph: Graph, version: number): void {\n const { state } = this\n const serial = state.loadSerial\n state.isMeasuringBounds = true\n pendingBoundsReads.set(graph, (pendingBoundsReads.get(graph) ?? 0) + 1)\n const settled = (): void => { pendingBoundsReads.set(graph, Math.max(0, (pendingBoundsReads.get(graph) ?? 1) - 1)) }\n graph.getPointPositionsAsync().then((positions) => {\n settled()\n if (state.graph !== graph) return\n state.isMeasuringBounds = false\n // Another dataset has been loaded since: not its box. The next frame starts a read of\n // the dataset there now\n if (state.loadSerial !== serial) {\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n return\n }\n if (positions.length === 0) return\n const box = new BoundsBox()\n for (let i = 0; i < positions.length; i += 2) box.add(positions[i] as number, positions[i + 1] as number)\n state.measuredBounds = box.bounds()\n state.measuredBoundsVersion = version\n // A consumer that reads the box every frame has the new one on the next\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n }, () => {\n settled()\n if (state.graph !== graph) return\n state.isMeasuringBounds = false\n // Nothing was measured: the next frame asks again\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n })\n }\n\n /** The space's square, the stand-in extent when there is nothing to measure (see `getBounds`). */\n private _spaceSquare (): [number[], number[]] {\n const spaceSize = this._spaceSize()\n return [[0, 0, 0], [spaceSize, spaceSize, 0]]\n }\n\n /**\n * Adds the positions the layer would load to `box` (see `getBounds`): the given ones,\n * placed as the engine will place them, and the square unseeded points are drawn in.\n * Nothing when they are rescaled on load.\n */\n private _addInputPositions (box: BoundsBox): void {\n const { points, getPointPosition } = this.props\n if (!points) return\n // Loaded positions are space coordinates unless the graph's config asks to rescale them\n if ((this.state?.graph?.config ?? this.props.config)?.rescalePositions === true) return\n const spaceSize = this._spaceSize()\n // The engine stores float32 and puts an infinite coordinate of a present point on the\n // matching edge of the space (position-utils' toFiniteCoordinate); NaN marks it absent\n const add = (x: number, y: number): void => {\n if (Number.isNaN(x) || Number.isNaN(y)) return\n box.add(toEngineCoordinate(x, spaceSize), toEngineCoordinate(y, spaceSize))\n }\n let unseeded = false\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n for (let i = 0; i < pointArray.length; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, pointArray[i] as PointDataT, info) : null\n if (position) add(position[0], position[1])\n else unseeded = true\n }\n } else {\n const { length, initialPositions } = points as { length: number; initialPositions?: Float32Array }\n if (initialPositions) {\n for (let i = 0; i < length; i += 1) add(initialPositions[i * 2] as number, initialPositions[i * 2 + 1] as number)\n } else unseeded = length > 0\n }\n if (unseeded) {\n // _load's randomCoordinate draws inside this square\n box.add(spaceSize * UNSEEDED_PLACEMENT[0], spaceSize * UNSEEDED_PLACEMENT[0])\n box.add(spaceSize * UNSEEDED_PLACEMENT[1], spaceSize * UNSEEDED_PLACEMENT[1])\n }\n }\n\n /**\n * The length the engine's placement rules are fractions of: the infinite-input edge, the\n * unseeded square, and the stand-in extent. The graph's own, validated, length once\n * there is a graph — from its construction, so the default when its config's `spaceSize`\n * is not a usable size, and authoritative for a provided graph — the config's before.\n * It sizes nothing.\n */\n private _spaceSize (): number {\n const engine = this.state?.graph?.simulation.store.referenceLength\n if (engine !== undefined) return engine\n // Before a graph exists, the config's, resolved as the engine will resolve it: the\n // default unless it is a positive finite number, and at least 2\n const configured = this.props.config?.spaceSize\n if (configured === undefined || !Number.isFinite(configured) || configured <= 0) return defaultConfigValues.spaceSize\n return Math.max(configured, 2)\n }\n\n /**\n * The config for a layer-created graph: the prop without the keys deck owns,\n * and the pixel ratio deck's canvas draws at, so cosmos sizes pixels alike.\n */\n private _graphConfig (): GraphConfig {\n const config: Partial<Record<keyof GraphConfig, unknown>> = { ...this.props.config }\n for (const key of DECK_OWNED_CONFIG_KEYS) delete config[key]\n config.pixelRatio = this._pixelRatio()\n return config as GraphConfig\n }\n\n /** deck's device pixels per CSS pixel, as its canvas context reports them. */\n private _pixelRatio (): number {\n const canvasContext = this.context.device.canvasContext as { cssToDeviceRatio?: () => number } | null\n const ratio = canvasContext?.cssToDeviceRatio?.()\n if (ratio && Number.isFinite(ratio)) return ratio\n return typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1\n }\n\n /**\n * cosmos's view for a deck viewport: a uniform scale `k` (pixels per space\n * unit) and a translation, per `setViewTransform`'s space → screen formula,\n * inverted. Three anchors through deck's projection — the space origin, its\n * x axis, its y axis — give the scale and tell whether the view is one cosmos\n * can draw: unrotated, unpitched, y up. The translation then follows from where\n * the space origin lands and the world origin cosmos centres its screen on, read\n * from the engine (`spaceSize / 2` on both axes, after the engine's own space-size\n * adjustment). The space origin's pixel is returned too, for mapping the other way.\n */\n private _viewTransform (\n graph: Graph,\n viewport: Viewport\n ): { k: number; x: number; y: number; originX: number; originY: number } | null {\n // The engine's own origin, not the config's: it is what cosmos draws with, and it stays\n // valid when `config.spaceSize` is not (the engine falls back to a default)\n const { worldOrigin } = graph.simulation.store\n const probeLength = VIEW_PROBE_LENGTH\n const modelMatrix = this.props.modelMatrix\n const toPixel = (sx: number, sy: number): [number, number] => {\n // Space → common (through modelMatrix, column-major, z = 0) → world → pixel.\n // On a map, common is Web Mercator and world is lng/lat; elsewhere both are\n // common, and unprojectPosition is the identity\n const cx = modelMatrix ? (modelMatrix[0] as number) * sx + (modelMatrix[4] as number) * sy + (modelMatrix[12] as number) : sx\n const cy = modelMatrix ? (modelMatrix[1] as number) * sx + (modelMatrix[5] as number) * sy + (modelMatrix[13] as number) : sy\n const world = viewport.unprojectPosition([cx, cy, 0])\n const pixel = viewport.project(world)\n return [pixel[0] as number, pixel[1] as number]\n }\n const [originX, originY] = toPixel(0, 0)\n const [eastX, eastY] = toPixel(probeLength, 0)\n const [northX, northY] = toPixel(0, probeLength)\n const k = (eastX - originX) / probeLength\n const tolerance = 1e-3 * Math.max(1, Math.abs(eastX - originX))\n const rotated = Math.abs(eastY - originY) > tolerance || Math.abs(northX - originX) > tolerance\n const yDown = northY > originY\n if (rotated || yDown || !(k > 0)) {\n if (!this.state.viewWarned) {\n this.state.viewWarned = true\n console.warn(\n '@cosmos.gl/deck-layers: cosmos.gl draws under a flat, north-up, y-up view only — ' +\n 'use OrthographicView({ flipY: false }) or a map at pitch 0 and bearing 0. The graph is not drawn.'\n )\n }\n return null\n }\n this.state.viewWarned = false\n // setViewTransform's formula at the space origin (0, 0), solved for the translation:\n // originX = k * (w / 2 - ox) + x, originY = k * (oy + h / 2) + y, with (ox, oy) the\n // world origin cosmos centres the screen on\n const [worldOriginX, worldOriginY] = worldOrigin\n return {\n k,\n x: originX - k * (viewport.width / 2 - worldOriginX),\n y: originY - k * (worldOriginY + viewport.height / 2),\n originX,\n originY,\n }\n }\n\n private _onTimelineTick (time: number): void {\n const { graph, isReady } = this.state ?? {}\n if (!graph || !isReady || !graph.isSimulationRunning) return\n // One step per frame per graph, however many layers draw it — and none while a bounds\n // read of any of them is on its way, which would otherwise wait for the step (getBounds)\n if (steppedAt.get(graph) !== time && !pendingBoundsReads.get(graph)) {\n steppedAt.set(graph, time)\n graph.step()\n }\n // Repaint the frame this step just computed; when the simulation settles,\n // the flag stops being set and deck goes idle on its own\n ;(this.getCurrentLayer() ?? this).setNeedsRedraw()\n }\n\n /**\n * Load mode: puts the layer's `points`, `links` and styles into the graph.\n * Each channel is sent only when its own input changed — a restyle leaves the\n * layout alone, a changed id map re-resolves array links without touching the\n * positions.\n */\n private _load (changes: {\n pointsChanged: boolean;\n linksChanged: boolean;\n idsChanged: boolean;\n pointStyleChanged: boolean;\n linkStyleChanged: boolean;\n pointColorUnset: boolean;\n pointSizeUnset: boolean;\n linkColorUnset: boolean;\n linkWidthUnset: boolean;\n }): void {\n const graph = this.state.graph\n if (!graph) return\n const { points, links, getPointId, getPointPosition } = this.props\n if (!points) return\n const firstLoad = !this.state.hasLoaded\n const spaceSize = this._spaceSize()\n\n // Unseeded points land in UNSEEDED_PLACEMENT, around the world origin gravity pulls\n // toward. They are drawn from the graph's own RNG, so a `randomSeed` reproduces the\n // layout\n const randomCoordinate = (): number =>\n spaceSize * graph.simulation.store.getRandomFloat(UNSEEDED_PLACEMENT[0], UNSEEDED_PLACEMENT[1])\n\n let pointCount: number\n let pointObjects: readonly PointDataT[] | null = null\n let pointAttributes: CosmosPointAttributes | undefined\n let positions: Float32Array | null = null // to load; null leaves the graph's\n let loadedPositions = this.state.loadedPositions\n let idToIndex = this.state.idToIndex ?? null\n\n if (Array.isArray(points)) {\n const pointArray = points as readonly PointDataT[]\n pointCount = pointArray.length\n pointObjects = pointArray\n // Object points carry positions and ids together: a change reloads both\n if (firstLoad || changes.pointsChanged) {\n positions = new Float32Array(pointCount * 2)\n idToIndex = getPointId ? new Map() : null\n for (let i = 0; i < pointCount; i += 1) {\n const point = pointArray[i] as PointDataT\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n const position = getPointPosition ? resolveAccessor(getPointPosition, point, info) : null\n positions[i * 2] = position ? position[0] : randomCoordinate()\n positions[i * 2 + 1] = position ? position[1] : randomCoordinate()\n if (idToIndex && getPointId) idToIndex.set(resolveAccessor(getPointId, point, info), i)\n }\n loadedPositions = pointArray\n } else if (changes.idsChanged) {\n idToIndex = getPointId ? new Map() : null\n if (idToIndex && getPointId) {\n for (let i = 0; i < pointCount; i += 1) {\n const info: AccessorContext<PointDataT> = { index: i, data: pointArray, target: [] }\n idToIndex.set(resolveAccessor(getPointId, pointArray[i] as PointDataT, info), i)\n }\n }\n }\n } else {\n const binaryPoints = points as { length: number; initialPositions?: Float32Array; attributes?: CosmosPointAttributes }\n pointCount = binaryPoints.length\n pointAttributes = binaryPoints.attributes\n idToIndex = null\n // Positions reload when their input changed: another `initialPositions`\n // array, a seed the layer must draw again for a new count, or a first load\n const positionsInput: unknown = binaryPoints.initialPositions ?? SEEDED\n if (firstLoad || positionsInput !== this.state.loadedPositions || pointCount !== this.state.pointCount) {\n if (binaryPoints.initialPositions) {\n positions = binaryPoints.initialPositions\n } else {\n positions = new Float32Array(pointCount * 2)\n for (let i = 0; i < positions.length; i += 1) positions[i] = randomCoordinate()\n }\n loadedPositions = positionsInput\n }\n }\n\n let pairs: Float32Array | null = null // to load; null leaves the graph's\n let linkCount = this.state.linkCount\n let keptLinks: readonly LinkDataT[] | null = this.state.keptLinks\n let linkAttributes: CosmosLinkAttributes | undefined\n if (links instanceof Float32Array || (links && !Array.isArray(links) && 'pairs' in links)) {\n const pairArray = links instanceof Float32Array ? links : links.pairs\n linkAttributes = links instanceof Float32Array ? undefined : links.attributes\n keptLinks = null\n linkCount = pairArray.length / 2\n if (firstLoad || pairArray !== this.state.loadedPairs) pairs = pairArray\n } else if (Array.isArray(links)) {\n // Array links resolve against the loaded points, so they reload with them\n if (firstLoad || changes.linksChanged || positions) {\n const linkObjects = links as readonly LinkDataT[]\n const { getLinkSource, getLinkTarget } = this.props\n // An endpoint is a point index, or a point id when the id map exists;\n // anything that does not name a point drops the whole link\n const resolveEndpoint = (endpoint: string | number): number | undefined => {\n const index = idToIndex ? idToIndex.get(endpoint) : endpoint\n return typeof index === 'number' && Number.isInteger(index) && index >= 0 && index < pointCount\n ? index\n : undefined\n }\n const kept: LinkDataT[] = []\n const keptIndices: number[] = []\n for (let i = 0; i < linkObjects.length; i += 1) {\n const link = linkObjects[i] as LinkDataT\n const info: AccessorContext<LinkDataT> = { index: i, data: linkObjects, target: [] }\n const source = resolveEndpoint(resolveAccessor(getLinkSource, link, info))\n const target = resolveEndpoint(resolveAccessor(getLinkTarget, link, info))\n if (source === undefined || target === undefined) continue\n kept.push(link)\n keptIndices.push(source, target)\n }\n const dropped = linkObjects.length - kept.length\n if (dropped > 0) {\n const hint = idToIndex ? 'getLinkSource / getLinkTarget against getPointId' : 'getLinkSource / getLinkTarget'\n console.warn(\n `@cosmos.gl/deck-layers: dropped ${dropped} of ${linkObjects.length} links whose source or target is not a point — check ${hint}`\n )\n }\n pairs = Float32Array.from(keptIndices)\n keptLinks = kept\n linkCount = kept.length\n }\n } else {\n keptLinks = null\n linkCount = 0\n if (firstLoad || this.state.loadedPairs !== NO_LINKS) pairs = NO_LINKS\n }\n\n // Positions are space coordinates by contract: not rescaled unless the graph's config asks\n if (positions) {\n graph.setPointPositions(positions, graph.config.rescalePositions === undefined ? true : undefined)\n // The box measured from the previous dataset is not this one's: until its first read\n // lands, getBounds serves the input box, and a read of the old positions is dropped\n this.state.measuredBounds = undefined\n this.state.measuredBoundsVersion = undefined\n this.state.loadSerial = (this.state.loadSerial ?? 0) + 1\n }\n if (pairs) graph.setLinks(pairs)\n // Styles: deck accessors and attributes, as cosmos's arrays. A channel the app gives\n // follows a reload (the count may have changed) and its own accessor; a channel it\n // does not give is left to the config default, and cleared when it just stopped\n const { getPointColor, getPointSize, getLinkColor, getLinkWidth } = this.props\n if (positions || changes.pointStyleChanged) {\n if (isChannelSet(getPointColor, pointAttributes?.getPointColor)) {\n graph.setPointColors(toColorArray(pointCount, getPointColor, pointObjects, pointAttributes?.getPointColor))\n } else if (changes.pointColorUnset) graph.setPointColors(NO_STYLE)\n if (isChannelSet(getPointSize, pointAttributes?.getPointSize)) {\n graph.setPointSizes(toValueArray(pointCount, getPointSize, pointObjects, pointAttributes?.getPointSize))\n } else if (changes.pointSizeUnset) graph.setPointSizes(NO_STYLE)\n }\n if (pairs || changes.linkStyleChanged) {\n if (isChannelSet(getLinkColor, linkAttributes?.getLinkColor)) {\n graph.setLinkColors(toColorArray(linkCount, getLinkColor, keptLinks, linkAttributes?.getLinkColor))\n } else if (changes.linkColorUnset) graph.setLinkColors(NO_STYLE)\n if (isChannelSet(getLinkWidth, linkAttributes?.getLinkWidth)) {\n graph.setLinkWidths(toValueArray(linkCount, getLinkWidth, keptLinks, linkAttributes?.getLinkWidth))\n } else if (changes.linkWidthUnset) graph.setLinkWidths(NO_STYLE)\n }\n // A headless graph applies at once: no transition, and the simulation keeps its alpha\n graph.render()\n\n // A new id map with nothing reloaded still changes how ids reach indices\n const idsRemapped = idToIndex !== this.state.idToIndex\n this.setState({\n hasLoaded: true,\n pointCount,\n linkCount,\n keptLinks,\n loadedPositions,\n loadedPairs: pairs ?? this.state.loadedPairs,\n idToIndex,\n })\n\n // After the graph holds the data, so what the callback sends lines up with it.\n // A throw is the app's error, not the layer's: it goes to deck's onError and leaves\n // the load, and the layer's readiness after a first load, intact.\n if (positions || pairs || idsRemapped) {\n try {\n this.props.onGraphDataLoaded?.({\n graph,\n pointsLoaded: Boolean(positions),\n linksLoaded: Boolean(pairs),\n pointIndexById: idToIndex,\n links: Array.isArray(links) ? keptLinks : null,\n })\n } catch (error) {\n this.raiseError(error as Error, 'onGraphDataLoaded')\n }\n }\n }\n}\n"],"names":["DECK_OWNED_CONFIG_KEYS","isStyleAccessor","constant","value","defaultProps","l","COORDINATE_SYSTEM","resolveAccessor","accessor","object","info","accessorReplaced","next","previous","configEquals","b","keys","key","x","y","v","i","toColorArray","count","objects","attribute","channel","colors","data","color","toValueArray","values","steppedAt","pendingBoundsReads","UNSEEDED_PLACEMENT","VIEW_PROBE_LENGTH","toEngineCoordinate","infiniteEdge","rounded","BoundsBox","SEEDED","NO_LINKS","NO_STYLE","isChannelSet","pointAttributesOf","points","linkAttributesOf","links","_CosmosGraphLayer","Layer","_a","device","timeline","time","params","props","oldProps","changeFlags","providedGraph","graphSwapped","graph","triggers","triggered","pointsChanged","idsChanged","linksChanged","pointStyleChanged","linkStyleChanged","uploaded","oldPoints","newPoints","oldLinks","newLinks","stopped","before","now","unsetChannels","opts","isReady","viewport","view","_b","_d","_c","picked","pointCount","event","enablePointDrag","dragReheatAlpha","draggedPointIndex","position","state","positions","box","context","type","pointIndex","linkIndex","provided","Graph","layer","error","holdsHover","version","serial","settled","spaceSize","getPointPosition","add","unseeded","pointArray","length","initialPositions","engine","configured","defaultConfigValues","config","canvasContext","ratio","worldOrigin","probeLength","modelMatrix","toPixel","sx","sy","cx","cy","world","pixel","originX","originY","eastX","eastY","northX","northY","k","tolerance","rotated","yDown","worldOriginX","worldOriginY","changes","getPointId","firstLoad","randomCoordinate","pointObjects","pointAttributes","loadedPositions","idToIndex","point","binaryPoints","positionsInput","pairs","linkCount","keptLinks","linkAttributes","pairArray","linkObjects","getLinkSource","getLinkTarget","resolveEndpoint","endpoint","index","kept","keptIndices","link","source","target","dropped","hint","getPointColor","getPointSize","getLinkColor","getLinkWidth","idsRemapped","CosmosGraphLayer"],"mappings":";;AAuEO,MAAMA,KAAyB;AAAA,EACpC;AAAA,EAAoB;AAAA,EAAmB;AAAA,EAAc;AAAA,EAAkB;AAAA,EACvE;AAAA,EAAsB;AAAA,EACtB;AAAA,EAAoB;AAAA,EAAc;AAAA,EAA8B;AAAA,EAChE;AAAA,EAAiB;AAAA,EAAgB;AAAA,EAAkB;AAAA,EAAmB;AAAA,EAAyB;AAAA,EAC/F;AAAA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A,GAAgB,mBAAmB;AAAA,MACrD;AAAA,EAEJ;AACF;AA3wBErD,EAAc,YAAY,oBAC1BA,EAAc,eAAe5C;AAJxB,IAAM2K,KAAN/H;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmos.gl/deck-layers",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "deck.gl
|
|
3
|
+
"version": "3.6.0",
|
|
4
|
+
"description": "A deck.gl layer that runs and draws a cosmos.gl graph — cosmos.gl's own renderer under deck's camera, on a shared luma.gl device",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@luma.gl/core": "~9.3.0",
|
|
35
35
|
"@luma.gl/engine": "~9.3.0",
|
|
36
36
|
"@luma.gl/shadertools": "~9.3.0",
|
|
37
|
-
"@cosmos.gl/graph": "^3.
|
|
37
|
+
"@cosmos.gl/graph": "^3.6.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@deck.gl/core": "~9.3.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vite": "^6.4.3",
|
|
48
48
|
"vite-plugin-dts": "^4.3.0",
|
|
49
|
-
"@cosmos.gl/graph": "^3.
|
|
49
|
+
"@cosmos.gl/graph": "^3.6.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "vite build",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Premultiplied-style alpha blending with depth writes disabled: points and
|
|
3
|
-
* links are drawn back-to-front by layer order, never by depth.
|
|
4
|
-
*
|
|
5
|
-
* Wire through `defaultProps.parameters`: before every draw, deck resets each
|
|
6
|
-
* model's pipeline parameters from `layer.props.parameters`. Parameters given
|
|
7
|
-
* only at `Model` creation last one frame.
|
|
8
|
-
*
|
|
9
|
-
* Declare the default with `compare: 2`, like the base layer does — a plain
|
|
10
|
-
* object default would drop deep comparison, and every new-but-equal
|
|
11
|
-
* `parameters` object from the caller would count as a prop change.
|
|
12
|
-
*/
|
|
13
|
-
export declare const BLEND_PARAMETERS: {
|
|
14
|
-
readonly depthWriteEnabled: false;
|
|
15
|
-
readonly depthCompare: "always";
|
|
16
|
-
readonly blend: true;
|
|
17
|
-
readonly blendColorOperation: "add";
|
|
18
|
-
readonly blendColorSrcFactor: "src-alpha";
|
|
19
|
-
readonly blendColorDstFactor: "one-minus-src-alpha";
|
|
20
|
-
readonly blendAlphaOperation: "add";
|
|
21
|
-
readonly blendAlphaSrcFactor: "one";
|
|
22
|
-
readonly blendAlphaDstFactor: "one-minus-src-alpha";
|
|
23
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Texture } from '@luma.gl/core';
|
|
2
|
-
type CosmosLinksBindingProps = {
|
|
3
|
-
positionsTexture: Texture;
|
|
4
|
-
};
|
|
5
|
-
type CosmosLinksUniformProps = {
|
|
6
|
-
pointsTextureSize: number;
|
|
7
|
-
widthUnits: number;
|
|
8
|
-
pointCount: number;
|
|
9
|
-
};
|
|
10
|
-
export type CosmosLinksProps = CosmosLinksBindingProps & CosmosLinksUniformProps;
|
|
11
|
-
export declare const cosmosLinksUniforms: {
|
|
12
|
-
readonly name: "cosmosLinks";
|
|
13
|
-
readonly vs: "layout(std140) uniform cosmosLinksUniforms {\n float pointsTextureSize;\n highp int widthUnits;\n float pointCount;\n} cosmosLinks;\n";
|
|
14
|
-
readonly uniformTypes: {
|
|
15
|
-
readonly pointsTextureSize: "f32";
|
|
16
|
-
readonly widthUnits: "i32";
|
|
17
|
-
readonly pointCount: "f32";
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Layer, Accessor, Color, DefaultProps, LayerDataSource, LayerProps, Unit, UpdateParameters } from '@deck.gl/core';
|
|
2
|
-
import { Model } from '@luma.gl/engine';
|
|
3
|
-
import { PositionTextureSource } from '@cosmos.gl/graph';
|
|
4
|
-
export type CosmosLinksLayerProps<DataT = unknown> = CosmosLinksLayerOwnProps<DataT> & LayerProps;
|
|
5
|
-
type CosmosLinksLayerOwnProps<DataT> = {
|
|
6
|
-
/**
|
|
7
|
-
* One entry per link, in link-index order: an array to run accessors over,
|
|
8
|
-
* or binary form. The cosmos links array `[src0, tgt0, src1, tgt1, …]` maps
|
|
9
|
-
* without a copy as two interleaved attributes over the same buffer:
|
|
10
|
-
* `{ length, attributes: { getLinkSource: { value, size: 1, stride: 8 },
|
|
11
|
-
* getLinkTarget: { value, size: 1, offset: 4, stride: 8 } } }`.
|
|
12
|
-
*/
|
|
13
|
-
data: LayerDataSource<DataT>;
|
|
14
|
-
/** The simulation whose live position texture to sample. */
|
|
15
|
-
graph: PositionTextureSource;
|
|
16
|
-
/**
|
|
17
|
-
* Source point index accessor.
|
|
18
|
-
* @default l => l.source
|
|
19
|
-
*/
|
|
20
|
-
getLinkSource?: Accessor<DataT, number>;
|
|
21
|
-
/**
|
|
22
|
-
* Target point index accessor.
|
|
23
|
-
* @default l => l.target
|
|
24
|
-
*/
|
|
25
|
-
getLinkTarget?: Accessor<DataT, number>;
|
|
26
|
-
/**
|
|
27
|
-
* Link RGBA color accessor, channels in 0..255.
|
|
28
|
-
* @default [94, 115, 194, 64]
|
|
29
|
-
*/
|
|
30
|
-
getLinkColor?: Accessor<DataT, Color>;
|
|
31
|
-
/**
|
|
32
|
-
* Link width accessor, in `linkWidthUnits`.
|
|
33
|
-
* @default 1
|
|
34
|
-
*/
|
|
35
|
-
getLinkWidth?: Accessor<DataT, number>;
|
|
36
|
-
/**
|
|
37
|
-
* The units of the link width, one of `'meters'`, `'common'`, `'pixels'`.
|
|
38
|
-
* @default 'pixels'
|
|
39
|
-
*/
|
|
40
|
-
linkWidthUnits?: Unit;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Renders every cosmos.gl link as an instanced quad stretched between its two
|
|
44
|
-
* endpoints: the vertex shader `texelFetch`es both point positions from the
|
|
45
|
-
* simulation's live GPU texture and extrudes the quad by half the link width
|
|
46
|
-
* in screen space — no position attribute, no CPU copy, no per-frame attribute
|
|
47
|
-
* updates. Endpoint indices, color and width are ordinary deck instanced
|
|
48
|
-
* attributes, and picking works out of the box: the instance index is the
|
|
49
|
-
* link index.
|
|
50
|
-
*
|
|
51
|
-
* Internal: the links sublayer of `CosmosGraphLayer`, not a package export —
|
|
52
|
-
* the composite resolves array links to point indices before they reach this
|
|
53
|
-
* layer, and a pair that names no point collapses in the shader, keeping its
|
|
54
|
-
* index.
|
|
55
|
-
*/
|
|
56
|
-
export declare class CosmosLinksLayer<DataT = unknown> extends Layer<Required<CosmosLinksLayerOwnProps<DataT>>> {
|
|
57
|
-
static layerName: string;
|
|
58
|
-
static defaultProps: DefaultProps<CosmosLinksLayerProps<unknown>>;
|
|
59
|
-
state: {
|
|
60
|
-
model?: Model;
|
|
61
|
-
};
|
|
62
|
-
getShaders(): ReturnType<Layer['getShaders']>;
|
|
63
|
-
initializeState(): void;
|
|
64
|
-
updateState(params: UpdateParameters<this>): void;
|
|
65
|
-
draw(): void;
|
|
66
|
-
private _getModel;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Texture } from '@luma.gl/core';
|
|
2
|
-
type CosmosPointsBindingProps = {
|
|
3
|
-
positionsTexture: Texture;
|
|
4
|
-
};
|
|
5
|
-
type CosmosPointsUniformProps = {
|
|
6
|
-
pointsTextureSize: number;
|
|
7
|
-
sizeUnits: number;
|
|
8
|
-
};
|
|
9
|
-
export type CosmosPointsProps = CosmosPointsBindingProps & CosmosPointsUniformProps;
|
|
10
|
-
export declare const cosmosPointsUniforms: {
|
|
11
|
-
readonly name: "cosmosPoints";
|
|
12
|
-
readonly vs: "layout(std140) uniform cosmosPointsUniforms {\n float pointsTextureSize;\n highp int sizeUnits;\n} cosmosPoints;\n";
|
|
13
|
-
readonly uniformTypes: {
|
|
14
|
-
readonly pointsTextureSize: "f32";
|
|
15
|
-
readonly sizeUnits: "i32";
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Layer, Accessor, Color, DefaultProps, LayerDataSource, LayerProps, Unit, UpdateParameters } from '@deck.gl/core';
|
|
2
|
-
import { Model } from '@luma.gl/engine';
|
|
3
|
-
import { PositionTextureSource } from '@cosmos.gl/graph';
|
|
4
|
-
export type CosmosPointsLayerProps<DataT = unknown> = CosmosPointsLayerOwnProps<DataT> & LayerProps;
|
|
5
|
-
type CosmosPointsLayerOwnProps<DataT> = {
|
|
6
|
-
/**
|
|
7
|
-
* One entry per simulation point, in point-index order: an array to run
|
|
8
|
-
* accessors over, or `{ length }` when accessors are constants. The length
|
|
9
|
-
* must equal the simulation's point count.
|
|
10
|
-
*/
|
|
11
|
-
data: LayerDataSource<DataT>;
|
|
12
|
-
/** The simulation whose live position texture to sample. */
|
|
13
|
-
graph: PositionTextureSource;
|
|
14
|
-
/**
|
|
15
|
-
* Point diameter accessor, in `pointSizeUnits`; `0` hides the point.
|
|
16
|
-
* @default 4
|
|
17
|
-
*/
|
|
18
|
-
getPointSize?: Accessor<DataT, number>;
|
|
19
|
-
/**
|
|
20
|
-
* Point RGBA color accessor, channels in 0..255.
|
|
21
|
-
* @default [74, 92, 191, 230]
|
|
22
|
-
*/
|
|
23
|
-
getPointColor?: Accessor<DataT, Color>;
|
|
24
|
-
/**
|
|
25
|
-
* The units of the point diameter, one of `'meters'`, `'common'`, `'pixels'`.
|
|
26
|
-
* @default 'pixels'
|
|
27
|
-
*/
|
|
28
|
-
pointSizeUnits?: Unit;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Renders every cosmos.gl point as an instanced quad whose position comes from
|
|
32
|
-
* a `texelFetch` on the simulation's live GPU position texture — no position
|
|
33
|
-
* attribute, no CPU copy, no per-frame attribute updates. Color and size are
|
|
34
|
-
* ordinary deck instanced attributes, and picking works out of the box: the
|
|
35
|
-
* instance index is the point index.
|
|
36
|
-
*
|
|
37
|
-
* Internal: the points sublayer of `CosmosGraphLayer`, not a package export —
|
|
38
|
-
* the composite keeps `data` aligned with the simulation's point index space.
|
|
39
|
-
*/
|
|
40
|
-
export declare class CosmosPointsLayer<DataT = unknown> extends Layer<Required<CosmosPointsLayerOwnProps<DataT>>> {
|
|
41
|
-
static layerName: string;
|
|
42
|
-
static defaultProps: DefaultProps<CosmosPointsLayerProps<unknown>>;
|
|
43
|
-
state: {
|
|
44
|
-
model?: Model;
|
|
45
|
-
};
|
|
46
|
-
getShaders(): ReturnType<Layer['getShaders']>;
|
|
47
|
-
initializeState(): void;
|
|
48
|
-
updateState(params: UpdateParameters<this>): void;
|
|
49
|
-
draw(): void;
|
|
50
|
-
private _getModel;
|
|
51
|
-
}
|
|
52
|
-
export {};
|