After creating a shape in Three.Js by combining a curved plane and two flat planes, I encountered an issue. While the vertical plane and curved plane blend seamlessly, there is a noticeable harsh line where the horizontal plane meets the curve. The lighting appears misaligned, and I'm aiming for the three planes to present themselves as a single object with smooth shading. Could I be making an error in my approach?
addShape() {
var radius =58, height=100, startAngle=THREE.Math.degToRad(0), endAngle=THREE.Math.degToRad(90), horizontalSegments=25, verticalSegments=25;
var width = radius * 2 * Math.PI;
var plane = new THREE.PlaneGeometry(width, height, horizontalSegments, verticalSegments);
var index = 0;
for(var i=0; i<=verticalSegments; i++) {
for(var j=0; j<=horizontalSegments; j++) {
var angle = startAngle + (j/horizontalSegments)*(endAngle - startAngle);
plane.vertices[index].z = radius * Math.cos(angle);
plane.vertices[index].x = radius * Math.sin(angle);
index++;
}
}
var material = new THREE.MeshLambertMaterial({color: 0xa2cddd, side: THREE.DoubleSide});
var mesh = new THREE.Object3D();
var curve = new THREE.Mesh(plane, material);
curve.rotation.z = THREE.Math.degToRad(-90)
var plane1 = new THREE.PlaneGeometry(height, height, horizontalSegments, verticalSegments);
var side1 = new THREE.Mesh(plane1, material);
side1.rotation.z = THREE.Math.degToRad(270)
side1.position.z = radius;
side1.position.x = -radius * 0.85;
var plane2 = new THREE.PlaneGeometry(height, height, 1, 1);
var side2 = new THREE.Mesh(plane2);
side2.rotation.y = THREE.Math.degToRad(90)
side2.position.x = radius * 1.0
side2.position.z = -radius * 0.8;
plane.mergeMesh(side1);
plane.mergeMesh(side2);
mesh.rotation.y = THREE.Math.degToRad(180);
mesh.add(curve);
this.mesh = mesh;
this.scene.add(mesh);
}
addLight() {
let light1 = new THREE.PointLight(0xffffff, 1, 200);
light1.position.set(0, 20, 10);
this.scene.add(light1);
let light2 = new THREE.AmbientLight(0x404040); // soft white light
this.scene.add(light2);
}