我在r68上,我试图找到一个创建矩形金字塔的例子我可以应用THREE.MeshFaceMaterial(),大多数示例看起来已经过时并且抛出错误用我目前的版本。
我只需要能够
提前致谢!
答案 0 :(得分:8)
上述答案仅适用于基座具有相等边的金字塔。如果你想要一个带有矩形脚的金字塔,你可以这样做:
var geometry = new THREE.Geometry();
geometry.vertices = [
new THREE.Vector3( 0, 0, 0 ),
new THREE.Vector3( 0, 1, 0 ),
new THREE.Vector3( 1, 1, 0 ),
new THREE.Vector3( 1, 0, 0 ),
new THREE.Vector3( 0.5, 0.5, 1 )
];
geometry.faces = [
new THREE.Face3( 0, 1, 2 ),
new THREE.Face3( 0, 2, 3 ),
new THREE.Face3( 1, 0, 4 ),
new THREE.Face3( 2, 1, 4 ),
new THREE.Face3( 3, 2, 4 ),
new THREE.Face3( 0, 3, 4 )
];
现在您有一个金字塔几何图形,其方形底部为1 x 1
,高度为1
。通过应用缩放矩阵,我们可以将此金字塔设置为任意期望的width
/ length
/ height
组合:
var transformation = new THREE.Matrix4().makeScale( width, length, height );
geometry.applyMatrix( transformation );
这也可以包装在自定义Pyramid
几何类中,以便您可以像这样使用它:
new THREE.Pyramid( width, length, height );
答案 1 :(得分:5)
正如@WestLangley所说,使用THREE.CylinderGeometry()
来做这件事是正确的方法,这就是我的做法
var geometry = new THREE.CylinderGeometry( 1, TILE_SIZE*3, TILE_SIZE*3, 4 );
var material = new THREE.MeshBasicMaterial( {color: 0xffff00 , wireframe:true} );
var cylinder = new THREE.Mesh( geometry, material );
this.scene.add( cylinder );
完美无缺!
答案 2 :(得分:0)
使用ConeBufferGeometry几何并将radialSegments更改为4
BufferGeometry比普通Geometry快
您可以调整的其他参数:
ConeBufferGeometry(radius : Float, height : Float, radialSegments : Integer, heightSegments : Integer, openEnded : Boolean, thetaStart : Float, thetaLength : Float)
结果:
实时演示:
https://threejs.org/docs/#api/en/geometries/ConeBufferGeometry