Skip to content

Add support for OffscreenCanvas #1189

Closed

Description

@vincesp

Description

As a TresJS developer, I want to be able to render a three scene into an OffscreenCanvas so that I can generate screenshots for downloading without having to add the scene to the DOM.

This is particularly interesting when using a library like h264-mp4-encoder to render several frames into a movie for downloading.

Suggested solution

three's WebGLRenderer which is used in useRendererManager.ts has support for both HTMLCanvasElement and OffscreenCanvas, see WebGLRenderer.js#L3424.

Suggested solution:

  • Implement a new TresOffscreenCanvas component that creates an OffscreenCanvas instead of a <canvas> element
  • Expose its instance methods so that developers can access the rendered image with convertToBlob(), getContext('2d').getImageData(), or transferToImageBitmap()
  • If an OffscreenCanvas is used, disable features related to auto-resizing or event handling throughout Tres that are not available nor meaningful for a canvas that is not part of the DOM

Alternative

No response

Additional context

We use three in Vue for our project to render image data. The tool has a screenshot feature that can either export the current frame as PNG or all frames (with the current view's settings) as MP4. This currently works well with three and an OffscreenCanvas. However, as complexity grows, our code would benefit from a transition to a declarative approach using Tres. But without support for an OffscreenCanvas, implementing the screenshot features will become cumbersome.

Validations

Activity

  1. alvarosabu commented on Oct 8, 2025

    @alvarosabu
    Member

    Hi @vincesp, this sounds quite interesting, since it's a feature request, I will convert it into a discussion so we can take it further

  2. locked and limited conversation to collaborators on Oct 8, 2025
  3. converted this issue into a discussion #1190 on Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions