-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
troika-three-text: possible to use in a webworker? #323
Comments
How are you trying to use it in a worker? Rendering to an OffscreenCanvas? Gimme some context. |
Of course - sorry about that! Yes, I'm rendering to an OffscreenCanvas with a WebGLRendererer ( NOT webGPU ). |
It is something like... const canvas = document.getElementById('game-canvas') as any;
const offscreen = canvas.transferControlToOffscreen();
// const proxy = new ElementProxy(window as any, orbitalEventHandlers, orbitalExtraArgs, (data: any) => {
// gameHandle.handleProxiedEvent(data)
// });
gameHandle.setupGraphics(
offscreen,
window.innerWidth,
window.innerHeight,
window.devicePixelRatio
); Then in the worker I do: function createText() {
const text = new Text();
text.text = this.parent.name.toUpperCase();
text.fontSize = 1;
text.rotateX(Math.PI / 2);
text.scale.set(-1, 1, 1);
text.color = 0xffffff;
text.anchorX = 'center';
text.anchorY = 'top';
text.material.opacity = 0.5;
text.sync();
return text;
} and it fails. |
It looks like in:
We can replace |
Makes sense. If I recall, I originally tried using an That was a while ago, though, so if you try it out and it works then I'd definitely be open to merging it. |
Yeah unfortunately you have to set colorspaces a bit more consistently in the worker/offscreen world than in the main thread. It is a bit of a pain. I'll let you know if I figure it out. |
When attempting to get troika text to run in a webworker I get the following error:
Any interest in fixing this?
The text was updated successfully, but these errors were encountered: