DracoLoader how to read custom attributes

I have a PLY file with a custom attribute of values, which I would like to load and use. Is there a way to do that?
In the PLYReader I saw there’s an option to map custom attributes to default attributes, is there a similar option for dracoLoader as well?

Here’s an example of a header:

ply
format binary_little_endian 1.0
element vertex 27549
property float x
property float y
property float z
property float Depth
property float Points
property float Direction
element face 54252
property list uchar uint vertex_indices
end_header

I would like to read the Depth attribute.

Can you please share the code that performs this mapping? AFAIK, PLYLoader just supports the mapping of custom property names to default names.

I was trying to use this code, but the mapping actually didn’t work for me, not sure why.

import { PLYLoader } from 'three/examples/jsm/loaders/PLYLoader';

.

this.plyLoader = new PLYLoader();
this.plyLoader.load(visualModel, (geometry) => {
geometry.computeVertexNormals();
this.plyLoader.setPropertyNameMapping({
Depth: 'position'
});      

  mesh = new THREE.Mesh( geometry, material );

  mesh.scale.set(2, 2, 2);

  this.scene.add(mesh);

  this.loading = false;

},

( xhr ) => {

  console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );

});

PLYLoader.setPropertyNameMapping() does not work like that. Consider vertex colors. You normally define them like so:

property uchar red
property uchar green
property uchar blue

However, you could have a PLY asset where the definition is:

property uchar diffuse_red
property uchar diffuse_green
property uchar diffuse_blue

You now have to define a property mapping otherwise PLYLoader is unable to load the asset:

loader.setPropertyNameMapping( {
    diffuse_red: 'red',
    diffuse_green: 'green',
    diffuse_blue: 'blue'
} );

That is required since PLYLoader looks for a fixed set of data/properties. If you have additional values in your asset (like Depth), it’s not possible to parse them without modifying the loader.

Oh, ok. Thanks for the clarification.
Is there a different loader that does support this functionality? Perhaps GltfLoader?

Not that I am aware of, sorry.

Ok. Do you know where I can find a list of the fixed set of properties the plyLoader (or better yet the dracoLoader) support?

I suggest you just look into the source code^^.

Thanks to @alankalb at GitHub, it will be possible with r147 to load custom attributes in PLY files with PLYLoader, see: