gpt4 book ai didi

javascript - Three.js:如何创建多边形/多面体?

转载 作者:行者123 更新时间:2023-11-28 07:40:24 26 4
gpt4 key购买 nike

除了这个之外,还有其他方法可以在 Three.js 中创建多边形/多面体吗?

	var polyhedronPts = [];
polyhedronPts.push( new THREE.Vector2 ( -100, 600 ) );
polyhedronPts.push( new THREE.Vector2 ( 300, 600 ) );
polyhedronPts.push( new THREE.Vector2 ( 600, -100 ) );

polyhedronShape = new THREE.Shape( polyhedronPts );

var extrudeSettings = {amount: 20}; // bevelSegments: 2, steps: 2 , bevelSegments: 5, bevelSize: 8, bevelThickness:5

var geometry = new THREE.ExtrudeGeometry( polyhedronShape, extrudeSettings );

mesh = THREE.SceneUtils.createMultiMaterialObject( geometry, [ new THREE.MeshBasicMaterial( { color: 0x00cc00 } ), new THREE.MeshBasicMaterial( { color: 0xff3333, wireframe: true, transparent: true } ) ] );
scene.add( mesh );

最佳答案

为什么不使用 http://threejs.org/docs/#Reference/Extras.Geometries/PolyhedronGeometry

var 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,
];

var 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
];

var geometry = new THREE.PolyhedronGeometry( verticesOfCube, indicesOfFaces, 6, 2 );

关于javascript - Three.js:如何创建多边形/多面体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28109706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com