更改网格顶点的坐标

问题描述

我正在尝试更改挤出形状的顶点。有两个问题:

  1. 在computeBoundingBox之后,BoundingBox出现在对象之外。如果你调用mesh.geometry.center(),那么几何会被移动(我想保留几何并将新的BoundingBox移动到新的几何中心)。改变顶点坐标之前 - http://prntscr.com/101pz11,之后 - http://prntscr.com/101pyen

  2. 纹理被破坏(分成三角形)http://prntscr.com/101pzwa

预先感谢您的帮助!

我的一些代码

    const shape = new Shape();
    points.forEach((p,i) =>
      {
        if (i === 0)
          shape.moveto(p[0],p[1]);
        else
          shape.lineto(p[0],p[1]);
      });
    const extrudeSettings =
      {
        steps: 1,depth: 0.1,bevelEnabled: false
      };
    const geometry = new ExtrudeGeometry(shape,extrudeSettings);
    geometry.vertices.forEach(vertex =>
      {
        vertex.z = parseFloat(vertex.z.toFixed(6));
        vertex.pointIndex = points.findindex(point => point[0] === vertex.x && point[1] === vertex.y);
      });
    const mesh = new Mesh(geometry,s3d._getMaterial(fill));
    const center = new Vector3();
    mesh.geometry.computeBoundingBox();
    mesh.geometry.boundingBox.getCenter(center);
    mesh.geometry.center();
    mesh.position.copy(center);
setPoint(index,x,y)
  {
    this.mesh.geometry.vertices.filter(vertex => vertex.pointIndex === index).forEach(vertex =>
      {
        vertex.x = x;
        vertex.y = y;
      });
    this.mesh.geometry.computeBoundingBox();
    this.bound.rebuild();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)