【发布时间】:2012-01-13 15:10:53
【问题描述】:
我有一个立方体几何图形和一个网格,但我不知道如何更改宽度(或高度......虽然我可以更改 x、y 和 z)。 这是我现在拥有的sn-p:
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
// WebGL renderer here
function render(){
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render( scene, camera );
}
function changeStuff(){
mesh.geometry.width = 500; //Doesn't work.
mesh.width = 500; // Doesn't work.
geometry.width = 500; //Doesn't work.
mesh.position.x = 500// Works!!
render();
}
谢谢!
编辑
找到解决办法:
mesh.scale.x = 500;
【问题讨论】:
-
CubeGeometry 扩展了 Geometry,但它仅使用宽度、高度、深度属性作为构造函数参数,而不是属性,所以正如您提到的,mesh.scale 是您的解决方案