admin管理员组文章数量:1402367
I created a simple animation of some boxes arranging themselves into a wall with react-three/fiber + react-three/rapier. Unfortunately, it seems that whenever the computational requirements increases - that is: I add some postprocessing effects, reflections or increase the number of boxes - some of the boxes disappear or "teleport" to other places resulting in gaps is my constructed wall.
There are no extra re-renders of my components/canvas elements (they are all rendered just once and then malimulated through references). Since I have updates to the velocity of the boxes on each frame (with useFrame
) then I guess the strange behaviour is just the engine not keeping up with the updates and some boxes "disappear" by e.g. flying through the floor. I found that the boxes are more likely to disappear if the floor is thinner so this seems like a good explanation.
My question is - how could I ensure that the boxes don't disappear/teleport? I can't predict the specs of the machines on which my animation would be run - but I would want it to always run smoothly without any disappearing boxes even if the resolution/quality/effects are varied with the computing power available.
Here is a code sandbox:
To replicate: is App.jsx (at the top of the component definition) set
const numberOfRows
to, let's say, 5 and const screenPadding
to 5 or 10.
=> everything seems to work fine
Now if I increase the number of columns or rows to e.g. 6 and 20 some of the boxes go missing and create gaps in the "wall".
Some notes about the code:
- I added "MeshReflectorMatrial" everywhere just to make the engine work harder - to illustrate the problem - in the real code I have other effects that I need to use that create a similar strain on the processor/GPU
- I'm not sure if it is worth it to use Pytorch.js for calculations - it might be creating too much overhead - idk - but this is of course a secondary issue
本文标签: reactjsDisappearing elements in a reactthree animationStack Overflow
版权声明:本文标题:reactjs - Disappearing elements in a react-three animation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744349085a2601941.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论