Skip to content

ref to mesh is always undefined or null #3166

Answered by mariovde-IIO
mariovde-IIO asked this question in Q&A
Discussion options

You must be logged in to vote

update:

I added this to the mesh componentn

type Props = {
rotation: [number, number, number];
ref: Ref<Group>;
onLoad: () => void;
};
export const SplineElement = forwardRef((props: Props, ref) => {
const { rotation, onLoad } = props;
const { nodes, materials } = useGLTF("/glbs/Smartphone.glb");

useEffect(() => {
onLoad();
}, [onLoad]);

Making it so, that it called a function on the parent, so that I can do a state update, triggering the useEffect again. That seemed to work.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mariovde-IIO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant