Three JS - How to cut off a 3D object using the Y plane?
Is it possible, with three JS, to cut a mesh or an object with a plane (mostly with a Y-axis) that we can move? I need the same functionality as in this image:
The goal is to maintain the integrity of the mesh so that the user can move the plane and see the mesh as a function of the Y plane.
+3
source to share
1 answer
Based on WestLangley's comment, the following code from the example link he posted seems to be the appropriate bit for what you are trying to achieve:
// ***** Clipping planes: *****
var localPlane = new THREE.Plane(new THREE.Vector3(0, -1, 0), 0.8);
// Geometry
var material = new THREE.MeshPhongMaterial({
color: 0x80ee10,
shininess: 100,
side: THREE.DoubleSide,
// ***** Clipping setup (material): *****
clippingPlanes: [ localPlane ],
clipShadows: true
});
var geometry = new THREE.TorusKnotBufferGeometry(0.4, 0.08, 95, 20);
var mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
scene.add(mesh);
+2
source to share