Skip to content
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

useRenderLoop().onLoop ticks before the renderer can meaningfully render #595

Open
5 tasks done
andretchen0 opened this issue Mar 21, 2024 · 2 comments
Open
5 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) PR welcome

Comments

@andretchen0
Copy link
Contributor

Describe the bug

Problem

useRenderLoop().onLoop ticks before the renderer can meaningfully render.

When onLoop is initially called, e.g.:

  • camera.aspect has its default value of 1, regardless of screen aspect
  • renderer.domElement.width has a value of 0
  • sizes.width has a value of 0

These values change on the subsequent frame, making coding/debugging more difficult than necessary.

Solution

  • useRenderLoop() should be dependent on the context's renderer.
  • The system shouldn't tick onLoop until the renderer is ready.

Context

Reproduction

https://stackblitz.com/edit/tresjs-basic-t6zfd2?file=src%2Fcomponents%2FUseRenderer.vue

Steps to reproduce

See StackBlitz.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm
  npmPackages:
    @tresjs/cientos: ^3.5.1 => 3.5.1 
    @tresjs/core: ^3.4.1 => 3.4.1 
    @tresjs/eslint-config-vue: ^0.2.1 => 0.2.1 
    vite: ^4.5.0 => 4.5.0

Used Package Manager

npm

Code of Conduct

@andretchen0 andretchen0 added the p2-to-be-discussed Enhancement under consideration (priority) label Mar 30, 2024
@andretchen0
Copy link
Contributor Author

Hey @alvarosabu !

I saw that you labelled this as PR welcome. Great! I'll be happy to submit a PR eventually.

For now, I'm trying to submit issues highlighting rough spots encountered while building things with Tres.

My hope is that in assembling the issues, we'll be able to knock all (or most) of them out at once.

@andretchen0 andretchen0 added p3-minor-bug An edge case that only affects very specific usage (priority) and removed p2-to-be-discussed Enhancement under consideration (priority) labels Apr 4, 2024
@andretchen0
Copy link
Contributor Author

Related?

This issue maybe pops up with custom shaders and HMR.

When doing off-screen rendering using a custom shader, this error is thrown on HMR:

Screenshot 2024-04-04 at 15 13 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) PR welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants