gpt4 book ai didi

javascript - 在三个js中用颜色填充线之间的区域

转载 作者:行者123 更新时间:2023-12-03 01:33:49 24 4
gpt4 key购买 nike

我有两个顶点数据集,第一个具有真实顶点,第二个具有相同顶点,但 y 为零。现在我希望它们能够连接起来并得到满足。我也使用 CatmullRomCurve3 和线路连接了它们,但没有运气填充它。

 for (var i = 0; i < data.real.length; i++) {
var o2 = i == data.real.length - 1 ? 0 : i + 1;
var rO1 = data.real[i];
var rO2 = data.real[o2];
var fO1 = data.zeroAxis[i];
var fO2 = data.zeroAxis[o2];

var curve = new THREE.CatmullRomCurve3([ rO1, rO2, fO1, fO2 ]);

var points = curve.getPoints(50);
var geometry = new THREE.BufferGeometry().setFromPoints(points);



var material = new THREE.LineBasicMaterial({
color : 0xff0000
});

// Create the final object to add to the scene
var curveObject = new THREE.Line(geometry, material);
console.log(curveObject)
this.tb.scene.add(curveObject);
this.tb.render();
}

enter image description here

最佳答案

经过多次尝试不同的几何形状后,我使用以下代码解决了该问题。

for (var i = 0; i < data.real.length; i++, f += 4) {
var o2 = i == data.real.length - 1 ? 0 : i + 1;
var tl = data.real[i];
var tr = data.real[o2];
var bl = data.zeroAxis[i];
var br = data.zeroAxis[o2];

geometry.vertices.push(tl, tr, br, bl);
var normal = new THREE.Vector3(0, 1, 0); // optional
var color = new THREE.Color(color); // optional
var materialIndex = 0; // optional
geometry.faces.push(new THREE.Face3(f, f + 1, f + 2, normal, color,
materialIndex));
geometry.faces.push(new THREE.Face3(f, f + 2, f + 3, normal, color,
materialIndex));

}
geometry.computeFaceNormals();
var material = new THREE.MeshPhongMaterial({
color : color,
side : THREE.DoubleSide,
transparent : true,
opacity : 1
});
var object = new THREE.Mesh(geometry, material);
object.position.set(0, a, 0);
this.plot = object;

var geo = new THREE.EdgesGeometry(object.geometry);
// or WireframeGeometry
var mat = new THREE.MeshPhongMaterial({
color : 0xffffff,
linewidth : 1,
side : THREE.DoubleSide,
transparent : true,
opacity : 0.75
});
var wireframe = new THREE.LineSegments(geo, mat);

object.add(wireframe);
this.tb.scene.add(object);

关于javascript - 在三个js中用颜色填充线之间的区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51170190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com