私は、曲面と2つの平面をマージしてThree.Jsで図形を作成しました。私は材料にMeshLambertMaterialを使用しました。垂直面と曲面は完全に結合します。しかし、水平面がカーブと結合するところには目立つような硬い線があります。照明は整列していないようです。私は3つの平面が滑らかな陰影を持つ1つのオブジェクトとして現れるようにしたい。私は何か間違っているのですか?Three.js平面上のマテリアルが照明と一致しない
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);
}
あなたの法線を更新していないように見えます。カーブに沿った法線は、カーブの中心に向かうように更新して、必要な効果を達成する必要があります。 – TheJim01