useFBX primitive change color #843
-
const fbx = useFBX("models/kurvStrait.fbx"); const myColor = '#AB0000'; const BasicMaterial = new MeshBasicMaterial({ // Will not change color How do you change the color or Material of primitive object ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Primitive just links the object you already have. You can't change a material on a scene or group, only meshes have materials. I don't know what fbxloader returns but if it's a group it won't work like that. R3F is threejs, it doesn't introduce new rules - always refer to the three docs when in doubt. |
Beta Was this translation helpful? Give feedback.
-
You can how ever change the material on the first run:
But i can't seem to be able to update the material after the first run ! |
Beta Was this translation helpful? Give feedback.
You can how ever change the material on the first run:
const BasicMaterial = new MeshBasicMaterial({color: new THREE.Color("#520B3E")})
const fbx = useFBX("models/kurvStrait.fbx");
const model = useMemo(() => fbx.clone(true), []);
model.children.forEach((mesh, i) => { mesh.material = BasicMaterial; });
<primitive object={model} scale={[0.35,1,0.4]} />
But i can't seem to be able to update the material after the first run !