Just starting out with three.js and my first task was to create a box geometry that could be increased from only one side.
Issue : When increasing the width or height of an object, both sides automatically expand.
Check out this jsFiddle Example
I wasted an hour trying to find the correct algorithm:
geometry = new THREE.BoxGeometry(strength, 200, 200);
material = new THREE.MeshBasicMaterial({
color: 0xff0000
});
mesh = new THREE.Mesh(geometry, material);
mesh.applyMatrix( new THREE.Matrix4().makeTranslation( - strength + strength / 2, 0, 0 ) );
Could someone explain to me what exactly - strength + strength / 2 means? (If I increase strength by 1, shouldn't the translation be -1 instead of -0.5?)
What is the term for this type of algorithm and where can I find good resources to learn more about it as a beginner?