canvas.toDataURL() is not a function - error node-webGL wrapper

后端 未结 1 2024
心在旅途
心在旅途 2021-01-25 21:34

Currently I am trying to convert browser based client side volume rendering code to server side pure javascript based rendering.

I use node-webgl at server side. My main

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 22:05

    .toDataURL() function is not defined in node-webGL wrapper. An alternative method is to make use of gl.readPixels (suggested by a member of this group).

    Here is the way to use it.

    var pixels = new Uint8Array(canvas.width * canvas.height * 4);
    gl.readPixels(0, 0, canvas.width, canvas.height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
    

    after the execution of gl.readPixels, the buffer data is present in pixels. The data is of ImageData() format. With this data, further required process can be done.

    0 讨论(0)
提交回复
热议问题