Utilizing the THREE.OBJLoader, I successfully loaded a 3D model into my scene.
Subsequently, I have the necessity to scale it by 10 and then extract its vertices position.
I am aware that the THREE.OBJLoader
provides a BufferGeometry
, allowing me to access its vertices through the position
attribute.
The issue arises when the Float32Array
storing these vertices does not seem to update after scaling my mesh, regardless of whether I do so before or after adding it to the scene.
To scale the mesh right after receiving it from the loader, I use the following code snippet:
myMesh = new THREE.Mesh(loadedMesh.geometry, new THREE.MeshBasicMaterial({color: 0xff0000}));
myMesh.scale.set(10, 10, 10);
Subsequently, I retrieve the vertices as follows:
var myMeshVertices = myMesh.geometry.attributes.position.array;
Upon execution, my mesh is added to the scene with the correct (scaled) dimensions, but the BufferGeometry
fails to update the vertices values accordingly.
Despite numerous attempts involving
myMesh.geometry.attributes.position.needsUpdate = true;
or myMesh.updateMatrix();
, I have stumbled upon various Stack Overflow queries on this issue (here or here), yet finding no definitive solution...
Could someone kindly clarify if I am missing something crucial here? (Given my limited experience with Three.js and WebGL, it is highly likely that gaps in my understanding exist).