Hello guys,
I want to slice a sphere according to the clipping plane normal. Everything looks normal when setting constant = 0. But when setting constant not 0, for example constant = 0.4, when rotating the clipping plane (set normal = [1,1,0]), the direction is Ok, but the clipping plane position is not right. I want to keep clipping plane at [0.4,0,0], I tried to set position at clipping plane to 0.4 , but it does not work. How could I get the right slicing sphere when constant is not 0, like yellow line labeled blow pictures. Thanks in advance.
my code snippet
function Sphere({ constant, normalx, normaly, normalz }) {
const mesh = useRef();
const plane = useRef();
return (
<mesh ref={mesh} castShadow position={[0, 0, 0]}>
{/* <boxGeometry attach="geometry" args={[1, 1, 1]} /> */}
<sphereGeometry attach="geometry" args={[1, 32, 16]} />
<meshPhongMaterial
color={0x80ee10}
shininess={100}
side={THREE.DoubleSide}
clipShadows
>
<plane
ref={plane}
attach="clippingPlanes-0"
normal={[normalx, normaly, normalz]}
constant={constant}
//position and translate do not work
// position={[-0.4, 0, 0]}
// translate={[-0.4, 0, 0]}
/>
</meshPhongMaterial>
</mesh>
);
}
CodeSandBox: crazy-jackson-18y593 - CodeSandbox