pex-renderer icon indicating copy to clipboard operation
pex-renderer copied to clipboard

Add custom attributeMap

Open vorg opened this issue 2 years ago • 0 comments

Currently to add custom attribute you do the following which mixes data creation with ctx webgl commands.

const corners = [...]
const cornersBuffer = graph.ctx.vertexBuffer({ data: new Float32Array(1)})
graph.ctx.update(cornersBuffer, { data: new Float32Array(g.corners.flat() )})
g.attributes = {
  aCorner: {
    buffer: cornersBuffer,
    divisor: 1
  },
   aCoords: {
    buffer: coordsBuffer,
    divisor: 1
  }
}

Ideally sth like that would be possible and all buffers allocated for you in geometry system:

g.corners = [...]
g.customAttributesMap = {
  aCorner: 'corners'
}
g.customInstancedAttributes: ['aCorner']

alternatively

g.corners = [...]
g.customAttributes = {
  aCorner: {
    attribute: 'corners',
    divisor: 1
  }
}

vorg avatar Nov 08 '23 16:11 vorg