# renderer.setSize() inside Worker

**URL:** <https://discourse.threejs.org/t/renderer-setsize-inside-worker/66566>\
**Category:** Questions\
**Tags:** web-worker\
**Created:** [June 8, 2024, 3:21am UTC](https://discourse.threejs.org/t/renderer-setsize-inside-worker/66566 "2024-06-08T03:21:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mentive](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mentive](https://discourse.threejs.org/u/mentive)\
**Post date:** [June 8, 2024, 3:21am UTC](https://discourse.threejs.org/t/renderer-setsize-inside-worker/66566/1 "2024-06-08T03:21:46Z")

</div>

Today I was working on implementing parallel processing to animate from a worker, and have everything working (including resizing, orbit controls, etc.) however, this one I’m a little puzzled on. Is there a better way to go about this?

canvas.style = {} // Offscreen Canvas does not have a Style!  
renderer.setPixelRatio( devicePixelRatio )  
renderer.setSize(width, height)  
renderer.setClearColor( 0x000000, 0 )

Resorted to setting .style on the Offscreen Canvas to an empty object. Width / Height are being set from a Vue component on main thread as it resizes by styling and all appropriate settings are sent to the worker. Everything seems to be working flawless, including a column drag / drop which resizes the canvas. Chat GPT couldn’t answer why it was throwing errors, and google searches yielded nothing as to a how you’d do this “properly.” Soo, this was the fix.

Or perhaps I should submit a bug: Three.js should be updated to check if the Canvas has a .Style when setting the Width / Height to canvas.style?

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [June 8, 2024, 9:09am UTC](https://discourse.threejs.org/t/renderer-setsize-inside-worker/66566/2 "2024-06-08T09:09:56Z")

</div>

> [@mentive](#):
>
> renderer.setSize(width, height)

You are supposed to call this method in workers like so:

```js
renderer.setSize(width, height, false);

```

The third parameter controls whether the `style` attribute of the renderer’s canvas gets updated or not. Default is `true`.

---

<div class="post-metadata">

**Author:** ![mentive](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mentive](https://discourse.threejs.org/u/mentive)\
**Post date:** [June 8, 2024, 3:14pm UTC](https://discourse.threejs.org/t/renderer-setsize-inside-worker/66566/3 "2024-06-08T15:14:21Z")

</div>

Well sh\*\*!! Could’ve sworn I checked the documentation, but, there it is… Funny how I got all of the more difficult stuff sorted out, and then this 😃

Kids, don’t drink and code.

Thank you for pointing out the simplest of solutions.
