PolyhedronGeometry
多面缓冲几何体
多面体在三维空间中具有一些平面的立体图形。这个类将一个顶点数组投射到一个球面上,之后将它们细分为所需的细节级别。
js
const geometry = new THREE.PolyhedronGeometry(
vertices : Array, i
ndices : Array,
radius : Float,
detail : Integer
)参数:
- vertices — 一个顶点Array(数组):[1,1,1, -1,-1,-1, ... ]。
- indices — 一个构成面的索引Array(数组), [0,1,2, 2,3,0, ... ]。
- radius — Float - 最终形状的半径。
- detail — Integer - 将对这个几何体细分多少个级别。细节越多,形状就越平滑。
代码示例
js
const verticesOfCube = [
-1,-1,-1,
1,-1,-1,
1, 1,-1,
-1, 1,-1,
-1,-1, 1,
1,-1, 1,
1, 1, 1,
-1, 1, 1,
];
const indicesOfFaces = [
2,1,0,
0,3,2,
0,4,7,
7,3,0,
0,1,5,
5,4,0,
1,2,6,
6,5,1,
2,3,7,
7,6,2,
4,5,6,
6,7,4
];
const geometry = new THREE.PolyhedronGeometry( verticesOfCube, indicesOfFaces, 6, 2 );