I’m trying to apply a matcap, or really just any material to a mesh that is inside an Object3d (it’s a piece of rigged geometry from Blender).
const textureLoader = new THREE.TextureLoader();
const micTexture = textureLoader.load(‘/img/three/matcaps/1.jpg’);const blackMaterial = new THREE.MeshMatcapMaterial({
matcap: micTexture,
skinning: true,
side: THREE.DoubleSide
});let micCorpus = null;
const gltfLoader = new GLTFLoader();
gltfLoader.load(‘img/three/models/mic-rig-14.gltf’, (gltf) => {const micModel = gltf.scene;
micModel.traverse((object) => {
if (object.isMesh) {
object.frustumCulled = false;
object.material = blackMaterial;
}
});micCorpus = micModel.children[0];
// micCorpus.scale.set(1, 1, 1)
// micCorpus.position.y = 0;console.log(micModel)
let shaderTarget = micModel.children[0].children[2];
shaderTarget.material = new THREE.MeshBasicMaterial({
color: ‘#92ffd1’,
skinning: true,
side: THREE.DoubleSide,
});micModel.scale.set(0.025, 0.025, 0.025);
scene.add(micModel);
});
Once I apply object.material = blackMaterial; to the mesh, it’s position and scale a offset by quite a bit. There is not difference in the mesh object’s position and scale properties, but rather only in matrixWorld.
This only happens to the mesh inside Object3D. Applying the matcap to other mesh in the scene works as expected.
What am I missing here? What causes this offset?