Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var planePointA = new THREE.Vector3(),
- planePointB = new THREE.Vector3(),
- planePointC = new THREE.Vector3();
- var mathPlane = new THREE.Plane();
- plane.localToWorld(planePointA.copy(plane.geometry.vertices[plane.geometry.faces[0].a]));
- plane.localToWorld(planePointB.copy(plane.geometry.vertices[plane.geometry.faces[0].b]));
- plane.localToWorld(planePointC.copy(plane.geometry.vertices[plane.geometry.faces[0].c]));
- mathPlane.setFromCoplanarPoints(planePointA, planePointB, planePointC);
- obj.geometry.faces.forEach(function(face) {
- obj.localToWorld(a.copy(obj.geometry.vertices[face.a]));
- obj.localToWorld(b.copy(obj.geometry.vertices[face.b]));
- obj.localToWorld(c.copy(obj.geometry.vertices[face.c]));
- lineAB = new THREE.Line3(a, b);
- lineBC = new THREE.Line3(b, c);
- lineCA = new THREE.Line3(c, a);
- setPointOfIntersection(lineAB, mathPlane);
- setPointOfIntersection(lineBC, mathPlane);
- setPointOfIntersection(lineCA, mathPlane);
- });
- var pointsOfIntersection = new THREE.Geometry();
- ...
- var pointOfIntersection = new THREE.Vector3();
- function setPointOfIntersection(line, plane) {
- pointOfIntersection = plane.intersectLine(line);
- if (pointOfIntersection) {
- pointsOfIntersection.vertices.push(pointOfIntersection.clone());
- };
- }
- var pointsMaterial = new THREE.PointsMaterial({
- size: .5,
- color: "yellow"
- });
- var points = new THREE.Points(pointsOfIntersection, pointsMaterial);
- scene.add(points);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement