Currently, I am working on a project using three.js
where users have the ability to modify the dimensions of a 3D model dynamically. The issue I'm encountering is similar to a problem I previously posted about stacking cubes together, which you can find here. However, this time around, I am dealing with an extrusion of a planar shape instead. The section of code causing me trouble looks like this:
cubeY.onChange(function(value){
cube.scale.y = value;
cube.position.y = (cubeHeight * value) / 2;
roof.position.y = (roofHeight * roof.scale.y) / 2 + cube.position.y * 2 - roofHeight;});;
roofY.onChange(function(value){
roof.scale.y = value;
roof.position.y = ((roofHeight * value) + cube.position.y * 2) - value * roofHeight;
});
When I adjust roof.scale.y
, the object moves when it should remain fixed to the top of the cube. Can anyone help identify what I might be doing wrong? You can view the full code on this jsfiddle link.
Thank you in advance for any assistance provided!