SolidPolygonLayer fails when passing a luma `Buffer` for getPolygon: `Error: cannot read geometries`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 14.6k
- Forks
- 2.3k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 42
Description
Description
I have a composite layer whose renderLayers method is being implemented like this (as a contrived example):
renderLayers(): SolidPolygonLayer<D>[] {
const { gl } = this.context;
const positions = new Float32Array(
[
[400, 400, 500, 400, 500, 500, 400, 500, 400, 400],
[600, 600, 700, 600, 700, 700, 600, 700, 600, 600],
[800, 800, 900, 800, 900, 900, 800, 900, 800, 800],
].flat()
);
const startIndices = new Uint16Array([0, 5, 10]);
const buffer = new Buffer(gl, positions);
const getPolygon = { buffer, offset: 0, size: 2, type: GL.FLOAT };
return [
new SolidPolygonLayer(
this.getSubLayerProps<D>({
_normalize: false,
data: {
attributes: {
getPolygon,
},
length: 3,
startIndices,
},
getFillColor: [0, 100, 60, 160],
id: "test-layer",
})
),
];
}
Instead of rendering the polygons, I get this error (full trace below):
Error: cannot read geometries
If I just change this:
const buffer = new Buffer(gl, positions);
const getPolygon = { buffer, offset: 0, size: 2, type: GL.FLOAT };
to this:
const getPolygon = { size: 2, value: positions };
everything works!
The reason that I am expecting this to work with a Buffer is because that is what is demonstrated in this example:
https://github.com/visgl/deck.gl/blob/master/examples/experimental/interleaved-buffer/app.js
Expected Behavior
The data should render, regardless of whether it is passed as a typed array or as a luma buffer.
Repro Steps
I can provide a working demo if necessary.
Environment
- Framework Version: deck.gl 8.4.11
- Browser Version: Chrome 95.0.4638.69
- OS: Mac OS X 11.6.1
Logs
Error: cannot read geometries
at Object.assert [as default] (assert.js:6)
at PolygonTesselator2.getGeometryFromBuffer (tesselator.js:106)
at PolygonTesselator2.getGeometryFromBuffer (polygon-tesselator.js:99)
at PolygonTesselator2.updateGeometry (tesselator.js:66)
at PolygonTesselator2.updateGeometry (polygon-tesselator.js:57)
at SolidPolygonLayer2.updateGeometry (solid-polygon-layer.js:293)
at SolidPolygonLayer2.updateState (solid-polygon-layer.js:262)
at SolidPolygonLayer2._updateState (layer.js:670)
at SolidPolygonLayer2._initialize (layer.js:635)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the geometry-reading path in tesselator.js and polygon-tesselator.js, then inspect how SolidPolygonLayer.updateGeometry in solid-polygon-layer.js handles typed arrays versus luma Buffers. Reproduce the supplied example and verify that the Buffer form renders the same polygons without the “cannot read geometries” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- computer-graphics, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100