-1

I'm trying to show a 3d model with its respective texture, how could I load the texture for a ply model?

this is in an html file where I use three.js with the plyloader.js to load the model, but I have not managed to load the texture correctly, when I try to load it with the methods I found in the documentation it only loads the color to the texture but not the image.

I'm trying this:

 var loader = new THREE.PLYLoader();
            loader.load('head3d.ply', function (geometry) {

                geometry.computeVertexNormals();
                var texture = new THREE.TextureLoader().load('head3d.jpg');
                var material = new THREE.MeshStandardMaterial({ map: texture, flatShading: true });
                var mesh = new THREE.Mesh(geometry, material);

                mesh.position.x = 0;
                mesh.position.y = 0;
                mesh.position.z = 0;
                mesh.scale.multiplyScalar(0.006);

                mesh.castShadow = true;
                mesh.receiveShadow = true;

                scene.add(mesh);

            });

I hope you show me the model loaded with the texture but only shows me the model with the color that dominates the image

  • Can you please verify if your geometry has texture coordinates? You can do this by printing `geometry.attributes.uv` to the browser console. It should not be `undefined`. – Mugen87 Apr 30 '19 at 15:39
  • I already tried it and it said that it is not defined, some recommendation to place the coordinates? – Richi Richi Ramirez Apr 30 '19 at 16:26
  • Generating uvs on the fly is difficult. Maybe it's better to import the PLY file into Blender, author texture coordinates and then perform a new export. Consider to use `glTF` in this case (see https://threejs.org/docs/index.html#manual/en/introduction/Loading-3D-models). – Mugen87 Apr 30 '19 at 17:06

1 Answers1

0

Use THREE.MeshNormalMaterial. For some reason it seems to load the textures when MeshNormalMaterial is used.

Zain
  • 53
  • 8