SphereGeometry创建时仅使用半径参数,没有内置的方法来改变它,需要手动修改几何顶点,或使用新的半径创建新的SphereGeometry或者缩放球体
缩放球体的方法:
gui.add第一个参数只能是对象,第二个参数是属性,三四是变换范围,第五个是步进
let controlsOBJ = {scaleNum: 1}
//创建球体
sphere = new THREE.Mesh(
new THREE.SphereGeometry(controlsOBJ.radius),
new THREE.MeshNormalMaterial({
wireframe: true
})
)
scene.add(sphere)
//轨道中添加控制半径的滑块,并控制倍数大小
let folder2 = gui.addFolder('球')
folder2.add(controlsOBJ, 'scaleNum', 0.1, 3,0.01).name('缩放倍数')
在render渲染函数中,改变缩放倍数
sphere.scale.x = controlsOBJ.scaleNum;
sphere.scale.y = controlsOBJ.scaleNum;
sphere.scale.z = controlsOBJ.scaleNum;