To obtain the position of the center vertex for all faces in BoxGeometry using threejs, you can use the following method:
const box = new THREE.BoxGeometry();
for (let i = 0; i < box.faces.length; i++) {
const face = box.faces[i];
const v1 = box.vertices[face.a];
const v2 = box.vertices[face.b];
const v3 = box.vertices[face.c];
// Calculate the centroid of the face
const center = new THREE.Vector3();
center.add(v1).add(v2).add(v3).divideScalar(3);
console.log(center);
}
This code loops through all the faces of the BoxGeometry and calculates the centroid of each face using the three vertices that make up the face. The centroid is calculated by adding the three vertices together and dividing by three. The resulting center vector represents the position of the center vertex for that particular face. The center vector is then logged to the console for each face.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-01-13 11:00:00 +0000
Seen: 18 times
Last updated: Nov 01 '21
In SCSS, what is the method for grouping and reusing a set of classes and styles?
What is the method to distinguish the presence of a json field in an array using presto?
What is Nextflow for genomics in AWS?
What are the differences between TREEFROG, CROW, and the CPPCMS C++ framework?
What does "waiting for handler commit" mean in relation to the slow writes experienced in MySQL 8?
What is the best way to arrange the file structure for both the backend and frontend in MERN?