regl
regl copied to clipboard
Property 'color' does not exist on type 'Framebuffer2D'
I am trying to convert the sprites.js example to TypeScript. The first issue I encountered is #602, and the second is that on line 159 it says SPRITES[(tick) % 2].color[0], but the Framebuffer2D class does not have a color property.
This could be the line where the color property is assigned https://github.com/regl-project/regl/blob/master/lib/framebuffer.js#L635.
My inelegant workaround is to add the following interface:
interface ExtendedFramebuffer2D extends REGL.Framebuffer2D {
color: REGL.Framebuffer2DAttachment[]
}
And then write:
const sprite_buffer = SPRITES[(tick) % 2] as ExtendedFramebuffer2D
(sprite_buffer.color[0] as REGL.Texture2D).subimage(
BLOCK, count % N, ((count / N) | 0) % N)
A working TypeScript version of the sprites.js demo: index.ts