Hi everyone,
I’m working on a Three.js project where I need to dynamically change the width of a geometry. I have a function that modifies the width successfully, but I’m encountering an issue where the texture applied to the geometry gets stretched when the width changes.
`
Here’s the function I’m using to change the width:
function setGeometryWidth(widthChange, pos, geometry) {
const position = geometry.getAttribute("position");
const vertex = new THREE.Vector3();
for (let i = 0; i < position.count; i++) {
vertex.fromBufferAttribute(position, i);
if (vertex.x < pos) {
vertex.x -= widthChange;
position.setXYZ(i, vertex.x, vertex.y, vertex.z);
}
}
position.needsUpdate = true;
}
While this works for changing the width, the texture mapped onto the geometry stretches, which is not the desired effect.
Does anyone know how I can modify the geometry’s width without stretching the texture? Any advice or pointers would be greatly appreciated!
Thanks in advance for your help!`