0

Upon loading a Ply file with PLYLoader, I modify the mesh a little bit so it looks better:

loader.load(
  filename,
  function ( geometry ) {
    var material = new THREE.MeshStandardMaterial( { color: 0x0055ff } );
    geometry.dynamic = true;
    var mesh = new THREE.Mesh( geometry, material );
    mesh.position.set(x, y, z);
    mesh.rotation.set(angleX, 0, 0);
    mesh.scale.set( sFactor, sFactor, sFactor );
    //mesh.updateMatrix();
    //mesh.geometry.applyMatrix( mesh.matrix );
    //mesh.geometry.verticesNeedUpdate = true;
    scene.add( mesh );
});

This renders the mesh perfectly, but later on I need to access the vertices with the new values. I know that you have to update also the geometry, but I don't find the correct combination.

I have tried setting the geometry to "dynamic" and then applying the mesh.matrix, as shown in the commented code. That makes the mesh render incorrectly (it's like it applied twice the transformation).

I'm doing something wrong but I don't find what. Does someone know how can update the geometry?

questing
  • 162
  • 1
  • 10
  • 1
    See http://stackoverflow.com/questions/24531109/three-js-vertices-does-not-update/24536525#24536525 – WestLangley Oct 28 '16 at 01:10
  • That's what I do and what it's not working for me, see the commented code. – questing Oct 28 '16 at 07:37
  • 2
    I see. All you need to do is construct your desired matrix transform, and call geometry.applyMatrix( myMatrixTransform ). Do not modify the mesh's matrix. – WestLangley Oct 28 '16 at 14:15
  • Also you can rotate, scale and translate your geometry before applying it to the mesh. [jsfiddle](https://jsfiddle.net/prisoner849/enkdv7fk/) – prisoner849 Oct 28 '16 at 15:22
  • Hi, I got it working using geometry.applyMatrix( myMatrixTransform ), but after that I need to reset the mesh position, rotation and scale. I don't understand why, but it works now and I moved on :) – questing Nov 07 '16 at 21:24

0 Answers0