project_threejs_ai
project_threejs_ai copied to clipboard
This is how to fix the issue with T-shirt color
Hello,
For those who have a problem with the T-shirt color pick up that doesn't change, the issue is coming from the T-shirt material. The aoMapIntensity (Ambient Occlusion Map Intensity) property controls the intensity of the ambient occlusion map (AO map) applied to the material. You can check it by console.log(materials.lambert1);
When aoMapIntensity is set to 1 (the default), ambient occlusion is applied with maximum intensity, which can result in more pronounced shadows and darker areas on the material.
Setting aoMapIntensity to 0 disables the ambient occlusion effect on the material, which can make the color more uniform and prevent soft shadows from applying.
Here is the Shirt convas updated :
import React, { useRef } from 'react';
import { easing } from 'maath';
import { useSnapshot } from 'valtio';
import { useFrame } from '@react-three/fiber';
import { Decal, useGLTF, useTexture } from '@react-three/drei';
import state from '../store';
const Shirt = () => {
const snap = useSnapshot(state);
const { nodes, materials } = useGLTF('/shirt_baked.glb');
// I added a reference "meshRef" to the mesh component that represents the t-shirt material
const meshRef = useRef();
const logoTexture = useTexture(snap.logoDecal);
const fullTexture = useTexture(snap.fullDecal);
useFrame((state, delta) => {
easing.dampC(materials.lambert1.color, snap.color, 0.25, delta);
// update the color to the material
meshRef.current.material.color = materials.lambert1.color;
meshRef.current.material.needsUpdate = true;
// Set aoMapIntensity to 0
materials.lambert1.aoMapIntensity=0;
});
const stateString = JSON.stringify(snap);
return (
<group>
<mesh
ref={meshRef}
castShadow
geometry={nodes.T_Shirt_male.geometry}
material={materials.lambert1}
material-roughness={1}
dispose={null}
>
// add the other properties
)}
</mesh>
</group>
)
}
export default Shirt
By changing aoMapIntensity to 0, you will able to resolve the color picking issue, as ambient occlusion no longer interfered with the color applied to the material.
As soon as i click on ai full or ai logo button my screen goes white and i can see errors on the server terminal and even in inspect console.

Can someone please help me out with this....?
You ur Api free trial of openai is expired, you need to subcribe to use the Api.
Thanks @r4dhwene,
I tried your solution and it works now 👍
Thank you so much!
Hi @r4dhwene, can I ask you a question? I want to make a t-shirt that can be viewed in 3D or 360 degrees. How can I do that?