From c33f0300f35207d464d521d666b922626530dd6a Mon Sep 17 00:00:00 2001 From: Ib Green Date: Thu, 12 Mar 2026 12:24:12 -0400 Subject: [PATCH] wip --- .../src/hexagon-layer/hexagon-cell-layer.ts | 6 +-- .../layers/src/column-layer/column-layer.ts | 10 ++++ test/modules/layers/column-layer.spec.ts | 53 +++++++++++++++++++ test/modules/layers/index.ts | 1 + 4 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 test/modules/layers/column-layer.spec.ts diff --git a/modules/aggregation-layers/src/hexagon-layer/hexagon-cell-layer.ts b/modules/aggregation-layers/src/hexagon-layer/hexagon-cell-layer.ts index 831be59d0e0..795e56d5878 100644 --- a/modules/aggregation-layers/src/hexagon-layer/hexagon-cell-layer.ts +++ b/modules/aggregation-layers/src/hexagon-layer/hexagon-cell-layer.ts @@ -108,11 +108,7 @@ export default class HexagonCellLayer extends Colum const elevationCutoff = this.props.elevationCutoff || [-Infinity, Infinity]; const fillModel = this.state.fillModel!; - if (fillModel.vertexArray.indexBuffer) { - // indices are for drawing wireframe, disable them - // TODO - this should be handled in ColumnLayer? - fillModel.setIndexBuffer(null); - } + this._disableFillIndexBuffer(); fillModel.setVertexCount(this.state.fillVertexCount); const hexagonProps: Omit = { diff --git a/modules/layers/src/column-layer/column-layer.ts b/modules/layers/src/column-layer/column-layer.ts index d529d553e87..81b39451bf8 100644 --- a/modules/layers/src/column-layer/column-layer.ts +++ b/modules/layers/src/column-layer/column-layer.ts @@ -378,6 +378,14 @@ export default class ColumnLayer exten wireframeModel.setTopology('line-list'); } + protected _disableFillIndexBuffer() { + const fillModel = this.state.fillModel!; + if (fillModel.vertexArray.indexBuffer) { + // Geometry indices are only for wireframe. Model rebuilds can reattach them. + fillModel.setIndexBuffer(null); + } + } + draw({uniforms}) { const { lineWidthUnits, @@ -399,6 +407,8 @@ export default class ColumnLayer exten const wireframeModel = this.state.wireframeModel!; const {fillVertexCount, edgeDistance} = this.state; + this._disableFillIndexBuffer(); + const columnProps: Omit = { radius, angle: (angle / 180) * Math.PI, diff --git a/test/modules/layers/column-layer.spec.ts b/test/modules/layers/column-layer.spec.ts new file mode 100644 index 00000000000..b31f6a94074 --- /dev/null +++ b/test/modules/layers/column-layer.spec.ts @@ -0,0 +1,53 @@ +// deck.gl +// SPDX-License-Identifier: MIT +// Copyright (c) vis.gl contributors + +import test from 'tape-promise/tape'; + +import {ColumnLayer} from '@deck.gl/layers'; +import {testLayer} from '@deck.gl/test-utils'; + +test('ColumnLayer - binary fill model clears wireframe indices', t => { + testLayer({ + Layer: ColumnLayer, + testCases: [ + { + title: 'binary data', + props: { + data: { + length: 3, + attributes: { + getPosition: {value: new Float64Array([37, 122, 37.1, 122, 37, 122.8]), size: 2}, + getFillColor: { + value: new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255]), + size: 4 + }, + getElevation: {value: new Float32Array([100, 200, 300]), size: 1} + } + }, + radius: 10, + extruded: true + }, + onAfterUpdate: ({layer}) => { + const fillModel = layer.state.fillModel!; + const wireframeModel = layer.state.wireframeModel!; + + t.ok(wireframeModel.vertexArray.indexBuffer, 'wireframe model keeps geometry indices'); + + fillModel.setIndexBuffer(wireframeModel.vertexArray.indexBuffer); + t.ok(fillModel.vertexArray.indexBuffer, 'sanity check: fill model has leaked indices'); + + layer.draw({uniforms: {}} as any); + + t.notOk( + fillModel.vertexArray.indexBuffer, + 'fill model disables wireframe indices before drawing fill geometry' + ); + } + } + ], + onError: t.notOk + }); + + t.end(); +}); diff --git a/test/modules/layers/index.ts b/test/modules/layers/index.ts index 1ff75685b41..36bf322f38c 100644 --- a/test/modules/layers/index.ts +++ b/test/modules/layers/index.ts @@ -18,5 +18,6 @@ import './text-layer/lru-cache.spec'; import './text-layer/text-layer.spec'; import './text-layer/font-atlas.spec'; import './column-geometry.spec'; +import './column-layer.spec'; import './utils.spec'; import './scatterplot-layer.spec';