Reputation: 659
Given 3 dynamic points, what is the best way to orientate a plane so that it intersects all 3 points?
I'm using Three.js
Upvotes: 3
Views: 1292
Reputation: 64174
To get the direction of the vector to orientate the plane, calculate the cross product of any of the 2 sides of the triangle
so, if your points are a, b, c
side1 = subVectors (a, b);
side2 = subVectors (a, c);
planeNormal = crossVectors (side1, side2);
Upvotes: 2
Reputation: 1284
Create a geometry. Add a vertice for each point, and create a face. For instance:
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0,0,0));
geometry.vertices.push(new THREE.Vector3(1,1,0));
geometry.vertices.push(new THREE.Vector3(1,-1,0));
geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
geometry.dynamic = true;
var shapeMesh = new THREE.Mesh(geometry, material);
scene.add(shapeMesh);
Everytime you change the geometry, be sure to let three.js know:
geometry.verticesNeedUpdate = true;
geometry.elementsNeedUpdate = true;
Upvotes: 4