Skip to main content

PCD module · writer API

PCDWriter

Encode loaders.gl mesh or Mesh Arrow table point clouds as readable Point Cloud Data text, preserving common position, normal, and color attributes.

What it writes

Export point attributes in a format tools can inspect.

PCDWriter accepts the same point-cloud table family used by loaders.gl readers and writes an ASCII PCD header plus point records.

Input

Mesh or Mesh Arrow table

Output

ASCII Point Cloud Data text

Attributes

Positions, normals, and packed color

Boundary

Readable output, not compressed binary

Detailed guide

PCDWriter reference

The sections below document usage, input normalization, supported attributes, and current options.

The PCDWriter writes Mesh or Mesh Arrow table point cloud data as ASCII Point Cloud Data (PCD) text.

Usage​

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

declare const pointCloud: Mesh | MeshArrowTable;

const arrayBuffer = await encode(pointCloud, PCDWriter);
const text = PCDWriter.encodeTextSync(pointCloud);

Data Format​

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

The writer requires a POSITION attribute. It writes NORMAL and COLOR_0 attributes when present. Colors are packed into the PCD rgb float field convention.

Options​

PCDWriter does not currently define format-specific options.