How to stop drawing?

good day everybody

I tried many ways to use the code to cancel drawing after getting several number of points but not working i don’t know how to do that :thinking: :thinking: :thinking:

function handleClick(event) {
        const x = (event.clientX / window.innerWidth) * 2 - 1;
        const y = -(event.clientY / window.innerHeight) * 2 + 1;
        const vector = new THREE.Vector3(x, y, y);
        vector.unproject(camera);
        const dir = vector.sub(camera.position).normalize();
        const distance = -camera.position.y / dir.y;
        const pos = camera.position.clone().add(dir.multiplyScalar(distance));
        vertice.push(pos);
console.log(pos)
        const customGeometry = new THREE.BufferGeometry().setFromPoints(vertice);
        points.geometry.dispose(), points.geometry = customGeometry;
        if (vertice.length >= 3) {
          const curve = new THREE.CatmullRomCurve3(vertice);
          const po = curve.getSpacedPoints(50);
          const geometry = new THREE.BufferGeometry().setFromPoints(po);
          const material = new THREE.LineBasicMaterial({ color: 0xff0000,size:5 });
          curveObject.geometry.dispose(), curveObject.geometry = geometry, curveObject.material = material;
}
      }
      function init() {
        scene.add(points);
        scene.add(curveObject);
        window.addEventListener('click', handleClick);
 window.addEventListener('contextmenu', function(){
document.onclick=null;
});

anybody to fix this.
Thank you

There’s no drawing in the code you’ve shared - it’s just a click event, which fires only once when the mouse is clicked.

I used This code To draw splines as shown in the picture below
See the spline
What I Wants is how to stop click Event after drawing splines.

But that event is called only once :eyes: it stops immediately after it’s called (and will be called again only after mouse clicks again - but once again, it’ll run and stop right away, it’s not continuous.)