BufferGeometry 是什么这是一个几何体 Buffer 生成类 能做什么
- 与BufferAttribute 组合 生成多边形几何体
- 对生成的几体何进行渲染优化
使用示例
const geometry = new THREE.BufferGeometry();
// 创建一个简单的矩形. 在这里我们左上和右下顶点被复制了两次。
// 创建顶点数据(4 个顶点,每个顶点有 3 个分量)
const vertices = new Float32Array([
-1.0, -1.0, 0.0, // 左下角
1.0, -1.0, 0.0, // 右下角
1.0, 1.0, 0.0, // 右上角
-1.0, 1.0, 0.0 // 左上角
]);
// 创建顶点索引数据(定义两个三角形组成一个四边形)
const indices = new Uint16Array([
0, 1, 2, // 第一个三角形
2, 3, 0 // 第二个三角形
]);
// itemSize = 3 因为每个顶点都是一个三元组。
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const mesh = new THREE.Mesh( geometry, material );
Clock 是什么
- Clock是一个获取时间的API
- 能够与 AnimationMixer 句柄中的 update 配合使用