025-几何造型-立方体

025-几何造型-立方体

在这里插入图片描述
生成顶点数据:

export default class BoxData {
  constructor({ width, height, depth }) {
    // 参数检查
    width = width || 1;
    height = height || 1;
    depth = depth || 1;

    // 顶点索引
    let indices = [
      // front
      0, 1, 2, 2, 3, 0,
      // back
      4, 5, 6, 6, 7, 4,
      // left
      0, 1, 6, 6, 7, 0,
      // right
      3, 2, 5, 5, 4, 3,
      // top
      0, 3, 4, 4, 7, 0,
      // bottom
      1, 2, 5, 5, 6, 1
    ]

    // 顶点坐标
    let vertices = [
      // front
      1, 1, 1,
      1, -1, 1,
      1, -1, -1,
      1, 1, -1,

      // back
      -1, 1, -1,
      - 1, -1, -1,
      -1, -1, 1,
      - 1, 1, 1,
    ];

    this.indices = indices
    this.position = vertices
  }

  getData() {
    return {
      indices: this.indices,
      position: this.position,
    }
  }
}

<全文结束>

发布了74 篇原创文章 · 获赞 6 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_21476953/article/details/104130693
今日推荐