Skip to main content

PLY writer

Write common mesh data into a portable text format.

PLYWriter accepts legacy Mesh objects and Mesh Arrow tables, normalizes their common attributes, and writes ASCII Polygon File Format output for tools and pipelines that speak PLY.

The PLY writing path

Normalize the mesh. Emit a file other tools can read.

The writer keeps format delivery separate from the application’s mesh representation, carrying standard vertex attributes and faces into a simple PLY schema.

Input

Mesh or Mesh Arrow table

Attributes

Position, normal, UV, color, and custom scalars

Topology

Indexed or sequential triangle faces

Output

ASCII PLY text or encoded bytes

Detailed guide

PLY output details

The reference below covers accepted mesh shapes, written attributes, faces, and encoding entry points.

From-v5.0Status: Experimental

The PLYWriter writes Mesh or Mesh Arrow table data as ASCII Polygon File Format (PLY) text.

Usage​

import {encode} from '@loaders.gl/core';
import type {Mesh, MeshArrowTable} from '@loaders.gl/core/schema';
import {PLYWriter} from '@loaders.gl/pointclouds/ply';

declare const mesh: Mesh | MeshArrowTable;

const arrayBuffer = await encode(mesh, PLYWriter);
const text = PLYWriter.encodeTextSync(mesh);

Data Format​

PLYWriter accepts Mesh Arrow tables and legacy Mesh objects. Legacy Mesh input is normalized through the Mesh Arrow table conversion path before PLY text is encoded.

The writer requires a POSITION attribute. It writes NORMAL, TEXCOORD_0, and COLOR_0 attributes when present. One-component custom attributes are written as scalar vertex properties. Indexed meshes are written as PLY faces; non-indexed triangle-list meshes are written as sequential triangle faces.

Options​

PLYWriter does not currently define format-specific options.