Hi, again! I want to get position of edge of rotated plane . But I don’t know how to do it.
Code:
// I created plane
let geometry = new THREE.PlaneGeometry( 80, 80);
let material = new THREE.MeshBasicMaterial( {color: new THREE.Color('#FF0000'), side: THREE.DoubleSide} );
let plane = new THREE.Mesh( geometry, material);
//And rotated it
plane.rotateX(Math.PI / 4);
I want to get edge postion between two vertex. For example, edge between vertexes 0 and 1:
getEdgePosition = function (v1, v2) {
const geometry = this.geometry;
const positionAttribute = geometry.getAttribute( 'position' );
//Created vectors to save position of vertex
const firstVertex = new THREE.Vector3();
const secondVertex = new THREE.Vector3();
//Got vertex position
firstVertex.fromBufferAttribute( positionAttribute, v1);
secondVertex.fromBufferAttribute( positionAttribute, v2);
//Returning result
return new THREE.Vector3(
(firstVertex.x + secondVertex .x) / 2,
(firstVertex.y + secondVertex .y) / 2,
(firstVertex.z + secondVertex .z) / 2
)
}
plane.getEdgePosition(0, 1);
It returned right result, but with rotated planes it not works…
Yep, clear solution. You are awesome, thanks. Last question: Do you know any good tutorial about three.js? I reading only three.js documentation, but there are described only methods and props, and sometimes it’s not enough to solve problems like’s this