-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
Created a playground example with a toggle button that switches between two URL-s:
https://brianzinn.github.io/react-babylonjs/playground?snippetId=CTqBHrbd
But the image used by the texture is not updating.
This possibly happens because setting the url prop of a Texture does nothing. Instead one needs to call updateURL().
When I update the playground example with a code that calls updateURL() inside an effect, it works:
function MyMaterial({url}: {url: string}) {
const ref = useRef<StandardMaterial>(null);
useEffect(() => {
if (ref.current) {
ref.current.diffuseTexture.updateURL(url);
}
}, [url]);
return (
<standardMaterial ref={ref} name="mat">
<texture url={url} />
</standardMaterial>
)
}PS. I tried copying the whole code from playground to here as well, but for some reason the copy functionality doesn't quite work there.
Metadata
Metadata
Assignees
Labels
No labels