I'm using THREE.OBJLoader to load a 3D model into my scene. It works fine.
However, after adding it to the scene, I need to scale it by 10, then retrieve its vertices position.
I know that THREE.OBJLoader
gives me a BufferGeometry
, and I know how to access its vertices using position
attribute.
My problem is: the Float32Array
storing these vertices doesn't seem to be updated after scaling my mesh, whether I do it before or after adding it to the scene.
I use this snippet to scale the mesh just after I got it from the loader:
myMesh = new THREE.Mesh(loadedMesh.geometry, new THREE.MeshBasicMaterial({color: 0xff0000}));
myMesh.scale.set(10, 10, 10);
Then I get the vertices using:
var myMeshVertices = myMesh.geometry.attributes.position.array;
Doing that, my mesh is added to the scene with the proper (scaled) dimensions, but its BufferGeometry
doesn't want to update the vertices values.
I did a lot of tests involving myMesh.geometry.attributes.position.needsUpdate = true;
or myMesh.updateMatrix();
, and I've seen a lot of SO questions around this subject (here or here), but I couldn't find a solution...
Could you tell me if I misunderstand something here? (keeping in mind that I just began with Three.js and WebGL, so I most certainly lack knowledge about this).