regl icon indicating copy to clipboard operation
regl copied to clipboard

Property 'color' does not exist on type 'Framebuffer2D'

Open bergwerf opened this issue 3 years ago • 2 comments

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.

bergwerf avatar Nov 08 '22 11:11 bergwerf

This could be the line where the color property is assigned https://github.com/regl-project/regl/blob/master/lib/framebuffer.js#L635.

bergwerf avatar Nov 08 '22 11:11 bergwerf

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

bergwerf avatar Nov 08 '22 12:11 bergwerf