Possibly dumb question but here goes. Three.js geometries have ‘parameter’ feilds associated with them, see the box geometry here…
I am trying to update these parameters like this…
JavaScript
x
7
1
var nodeSize = 10;
2
var geometry = new THREE.CubeGeometry(nodeSize, nodeSize, nodeSize);
3
mesh = new THREE.Mesh(geometry, new THREE.MeshNormalMaterial({side:THREE.DoubleSide}));
4
5
scene.add(mesh);
6
mesh.geometry.parameters.depth=20;
7
But of course, the geometry remains unchanged. Is there a way of updating the geometry by editing these parameters?
fiddle here https://jsfiddle.net/kn3owveg/2/
Any help appreciated!
Advertisement
Answer
Gaitat is totally right, you can’t change geometry with changing of parameters
.
And there can be another solution. With scaling of your cube.
JavaScript
1
9
1
function setSize( myMesh, xSize, ySize, zSize){
2
scaleFactorX = xSize / myMesh.geometry.parameters.width;
3
scaleFactorY = ySize / myMesh.geometry.parameters.height;
4
scaleFactorZ = zSize / myMesh.geometry.parameters.depth;
5
myMesh.scale.set( scaleFactorX, scaleFactorY, scaleFactorZ );
6
}
7
8
setSize(mesh, 10, 10, 20);
9
jsfiddle example