I would like to write correct types for the Mesh Vertices and Faces.
In the first example, I create a new Mesh, and when I want to access Vertices and Faces from geometry, I get 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;
// Error: Property 'vertices' does not exist on type 'BufferGeometry | Geometry'
// Error: Property 'faces' does not exist on type 'Geometry | BufferGeometry'.
newMesh.geometry.colorsNeedUpdate = true;
// Error: Property 'colorsNeedUpdate' does not exist on type 'Geometry | BufferGeometry'.
In the second example, I get Mesh from the Scene, and then I get the following error:
const mesh = scene.getObjectByName('boxMesh');
const geometry = mesh.geometry;
// Property 'geometry' does not exist on type 'Object3D'.