-
Notifications
You must be signed in to change notification settings - Fork 150
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
Changing objects upon click #142
Comments
You just need to change the value of the |
This may be more of a React thing but when I use useMemo (as used in the satellites example) my default satellite octahedron doesn't work using this method. But when I use a standard function to create a mesh, it works but this creates significant performance issues. I can make
|
I think using <Globe ... onObjectClick={handleSatelliteClick} objectThreeObject={objRepresent} /> |
Hey, I've actually done this in my app. Here's a minimal example. |
Thanks for this, however this is basically where I got to and doesn't resolve the issue i'm having. See edited example here: https://codesandbox.io/s/dreamy-marco-y2r69m?file=/src/Globe.tsx Basically if I use the useMemo hook to memoize the defaultSat mesh, I can use this for all objects by putting it into objectThreeObject directly. However when I use it in objectRepresent and choose to return a "selected" mesh object, or the memoized defaultSat mesh, it only returns 2 objects. When I return non-memoized meshes, i'm experiencing performance issues |
Hello, I just checked your codesandbox and have some feedback, hope it might help
useEffect(() => {
setInterval(() => {
setTime((time) => new Date(+time + TIME_STEP));
}, 100);
}, []); |
These sections were all just copied and pasted from the satellites example to demonstrate my issue with useMemo on optional rendering of satellites but thanks for the tips |
Hello @rickid123, Yeah, I just forked yours and replaced the |
@BangNguyen1992 using setInterval seems to either break or rapidly speed up the animation, therefore harming performance. I'm not really sure what's being changed here, or to what end. |
Hello @MichaelBonnet, I dont think using useEffect(() => {
const interval = setInterval(() => {
setTime((time) => new Date(+time + TIME_STEP));
}, 100);
return () => {
clearInterval(interval);
}
}, []); Or if you dont want to use setInterval and keep the The |
How do I change an object when it is clicked on? I want satellites to be octahedrons by default then load a glb file to display for the clicked on object once clicked whilst the rest remain as octahedrons.
The text was updated successfully, but these errors were encountered: