How can I correctly define types for Mesh Vertices and Faces?
In my initial attempt, I decided to create a new Mesh object. However, when attempting to access Vertices and Faces from the geometry property, I encountered a few errors:
const material = new THREE.MeshLambertMaterial({color: 0x00ff00});
const geometry = new THREE.Geometry();
const newMesh = new THREE.Mesh(geometry, material);
scene.add(newMesh);
const { vertices, faces } = newMesh.geometry;
// Issue: Property 'vertices' is missing on type 'BufferGeometry | Geometry'
// Issue: Property 'faces' is missing on type 'Geometry | BufferGeometry'.
newMesh.geometry.colorsNeedUpdate = true;
// Problem: Property 'colorsNeedUpdate' does not exist on type 'Geometry | BufferGeometry'.
In a different scenario, I obtained a Mesh object from the Scene but faced a new error:
const mesh = scene.getObjectByName('boxMesh');
const geometry = mesh.geometry;
// Error: Property 'geometry' does not exist on type 'Object3D'.