I want to change the size of a circle as I drag a lil gui slider. I have this code, which draws a circle with a blue line in a black screen, with an ortographic camera:
initGUI();
let radius = 0.6;
let vertices = [];
for(let i = 0; i <= 360; i++){
vertices.push(new THREE.Vector3(Math.sin(i*(Math.PI/180))*radius, Math.cos(i*(Math.PI/180))*radius, 0));
}
let geometry = new THREE.BufferGeometry().setFromPoints(vertices);
let material = new THREE.LineBasicMaterial({color:"blue"})
var lineStrip = new THREE.Line( geometry, material );
I also have this initGUI() function, which makes a slide that changes the value of controls.radius
function initGUI() {
controls = { radius : 0.6
};
gui.add( controls, 'radius', 0.1, 0.7).onChange(value => changeRadius(value));
gui.open();
};
the onChange method sends the new values of the radius to the function changeRadius, which is:
function changeRadius(value) {
radius = value;
var vertices = [];
for(let i = 0; i <= 360; i++){
vertices.push(new THREE.Vector3(Math.sin(i*(Math.PI/180))*radius, Math.cos(i*(Math.PI/180))*radius, 0));
}
renderer.clear();
renderer.render(scene, camera);
}
this doesn't work, though. It produces the error "renderer is not defined". I tried to pass the renderer as the function parameter, then it gave something similar to "scene and camera are not defined", then I also set scene and camera as parameters of the function and no errors were produced, but the circle didn't change its size.