Giter Site home page Giter Site logo

Comments (6)

andretchen0 avatar andretchen0 commented on July 21, 2024 1

Hey @alvarosabu ,

The approach you mention would work for the render phase. But ideally here, this needs to keep a few other things from happening too early.

We should avoid at least one of these until the system is ready:

  • starting the loop
  • calling any loop callbacks

If we do either of those, there's no need to modify the render phase specifically.

I'm working on a fix.

from tres.

andretchen0 avatar andretchen0 commented on July 21, 2024

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.

from tres.

andretchen0 avatar andretchen0 commented on July 21, 2024

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

from tres.

alvarosabu avatar alvarosabu commented on July 21, 2024

This usecase is covered by the new useLoop composable available on v4 https://docs.tresjs.org/api/composables.html#useloop

from tres.

andretchen0 avatar andretchen0 commented on July 21, 2024

Hey @alvarosabu ,

This is still an issue with useLoop in the latest v4, as far as I can see. If you modify the code from the docs like this:

let logged = false
const { off } = render(({ renderer, scene, camera }) => {
  if (!logged) {
    logged = true
    console.log("canvas width/height:", renderer.domElement.width, renderer.domElement.height)
    console.log(`camera.aspect: ${camera.aspect}`);
  }
  renderer.render(scene, camera)
})

It will log this:

canvas width/height: 0 0
camera.aspect: 1

As with v3 these initial values will be changed on the next tick.

from tres.

alvarosabu avatar alvarosabu commented on July 21, 2024

OHHHH ok I see @andretchen0 we could add a check that if the size is !=0 it does render here:

if (camera.value && render.frames.value > 0) {
renderer.value.render(scene, camera.value)
emit('render', ctx.renderer.value)
}

from tres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.