Loader →

# PLYLoader

A loader for PLY the PLY format (known as the Polygon File Format or the Stanford Triangle Format).

Limitations:

- ASCII decoding assumes file is UTF-8.

## Code Example

    const loader = new PLYLoader();
    const geometry = await loader.loadAsync( './models/ply/ascii/dolphins.ply' );
    scene.add( new THREE.Mesh( geometry ) );

## Import

PLYLoader is an addon, and must be imported explicitly, see Installation#Addons.

    import { PLYLoader } from 'three/addons/loaders/PLYLoader.js';

## Constructor

### new PLYLoader ( manager : LoadingManager )

Constructs a new PLY loader.

manager | The loading manager.

## Methods

### .load ( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )

Starts loading from the given URL and passes the loaded PLY asset to the `onLoad()` callback.

url | The path/URL of the file to be loaded. This can also be a data URI.
onLoad | Executed when the loading process has been finished.
onProgress | Executed while the loading is in progress.
onError | Executed when errors occur.

Overrides: Loader#load

### .parse ( data : ArrayBuffer ) : BufferGeometry

Parses the given PLY data and returns the resulting geometry.

data | The raw PLY data as an array buffer.

Overrides: Loader#parse

Returns: The parsed geometry.

### .setCustomPropertyNameMapping ( mapping : Object )

Custom properties outside of the defaults for position, uv, normal and color attributes can be added using the setCustomPropertyNameMapping method. For example, the following maps the element properties “custom_property_a” and “custom_property_b” to an attribute “customAttribute” with an item size of 2. Attribute item sizes are set from the number of element properties in the property array.

    loader.setCustomPropertyNameMapping( {
    	customAttribute: ['custom_property_a', 'custom_property_b'],
    } );

mapping | The mapping dictionary.

### .setPropertyNameMapping ( mapping : Object )

Sets a property name mapping that maps default property names to custom ones. For example, the following maps the properties “diffuse_(red|green|blue)” in the file to standard color names.

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

mapping | The mapping dictionary.

## Source

examples/jsm/loaders/PLYLoader.js