Usage
NPM
import * as PCL from 'pcl.js';async function main() { // Initialization const pcl = await PCL.init({ // Recommend, optional configuration, custom WebAssembly file link. url: 'https://cdn.jsdelivr.net/npm/pcl.js/dist/pcl-core.wasm', // You can also pass an ArrayBuffer of WebAssembly files. // arrayBuffer: ArrayBuffer });}main();
CDN
<script>async function main() { // Initialization, PCL is a global object. const pcl = await PCL.init(); // ...}main();</script>
TIP
It is recommended to use CDN to load pcl-core.wasm
Basic Usage Example
Filtering a PointCloud using a PassThrough filter.
See: https://pcl.readthedocs.io/projects/tutorials/en/master/passthrough.html#passthrough
// TypeScriptimport * as PCL from 'pcl.js';async function main() { const pcl = await PCL.init({ url: 'https://cdn.jsdelivr.net/npm/pcl.js/dist/pcl-core.wasm', }); // Get PCD file const data = await fetch('https://cdn.jsdelivr.net/gh/luoxuhai/pcl.js@master/data/rops_tutorial/points.pcd').then(res => res.arrayBuffer()); // Load PCD file data, return point cloud object const cloud = pcl.io.loadPCDData<PCL.PointXYZ>('data, PCL.PointXYZ); // Filtering a PointCloud using a PassThrough filter // See: https://pcl.readthedocs.io/projects/tutorials/en/master/passthrough.html#passthrough const pass = new pcl.filters.PassThrough<PCL.PointXYZ>(PCL.PointXYZ); pass.setInputCloud(cloud); pass.setFilterFieldName('z'); pass.setFilterLimits(0.0, 1.0); const cloudFiltered = pass.filter(); // Save filtered point cloud objects as PCD files, the content is ArrayBuffer const cloudFilteredData = pcl.io.savePCDDataASCII(cloudFiltered);}main();