Three.js - How to preserve color information of input file

719 views Asked by At

How do you preserve the color information of a PLY file in Three.js?

I've the following colored point cloud input_model.ply which looks like this:

input_model_ply

I'm already aware of the following portion of code from https://threejs.org/examples/webgl_loader_ply.html

// PLY file

var loader = new THREE.PLYLoader();

loader.load( 'http://127.0.0.1:5000/static/input_model.ply', function ( geometry ) {

    var material = new THREE.MeshStandardMaterial( { color: 0x0055ff, flatShading: true } );
    var mesh = new THREE.Mesh( geometry, material );

    mesh.position.y = 0;
    mesh.position.z = - 1;
    mesh.rotation.x = - Math.PI / 20;
    mesh.scale.multiplyScalar( 0.05 );

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

    scene.add( mesh );

    } );

But when the scene is rendered I lose all my input_model.ply color information and the point cloud is displayed in a monochromatic way (and specifically in color: 0x0055ff)

How can I get this to work?

0

There are 0 answers