Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

threejs-ply-loader

lanceschi1.3kMIT2.0.2

Node.js wrapper for three.js PLYLoader

three.js, threejs, three, ply, PLYLoader, loader, loaders

readme

ci   npm publish   npm version   npm

Three.js PLY file format loader to use with Node.js

Description

Node.js wrapper for three.js PLYLoader (currently three.js v0.137.0).

Original PLYLoader source code can be found here.

Beside some minor edits, I added an additional helper function for converting Node Buffer to ArrayBuffer (convenience-wise) and I put in place tests.

This library was developed as a JavaScript Module. The recommended use with CommonJS files is through dynamic imports.

Usage

const fs = require("fs");
const { join } = require("path");
const THREE = require("three");

(async () => {
  // Import PLYLoader Factory
  const { PLYLoaderFactory } = await import("threejs-ply-loader");

  // Initialize PLYLoader Class
  const PLYLoader = PLYLoaderFactory(THREE);

  // Instantiate PLYLoader object
  const plyLoader = new PLYLoader();

  // Read 3D Model as PLY file format
  const sourceFilepath = join(__dirname, "assets/cube.ply");
  const fileBuffer = fs.readFileSync(sourceFilepath);

  // Convert node file Buffer to ArrayBuffer
  const fileArrayBuffer = plyLoader.bufferToArrayBuffer(fileBuffer);

  // Parse 3D model into THREE geometry
  const geometry = plyLoader.parse(fileArrayBuffer);
})();

Example

An example is present in the examples folder. It will load a PLY file model and output its rendering to a PNG file. It can be run from a shell:

npm install
npm run example:cube-to-png

The output image is going to located in examples/temp/vertex-colored-cube.png

Tests

They can be run from a shell:

npm install
npm test

Development notes

Developed with Node v16.13.2

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

[v2.0.2] - 2022-01-29

Changed

  • NPM package upgrades:
    • cross-blob ^3.0.0 → ^3.0.1
    • chai ^4.3.4 → ^4.3.6
    • eslint ^8.6.0 → ^8.8.0
    • mocha ^9.1.3 → ^9.2.0
    • three ^0.125.1 → ^0.137.5
  • .npmignore edits

[v2.0.1] - 2022-01-15

Added

  • Added .npmignore file

[v2.0.0] - 2022-01-13

Added

  • Added NPM packages:
    • cross-blob 3.0.0

Changed

  • Changed the library to a JavaScript Module
  • Node engine version is now set to >=12.0.0
  • Updated wrapped PLYLoader library to the latest: 0.136.0
  • Partial test rewrote
  • README.md edits
  • NPM package upgrades:
    • three ^0.125.0 → ^0.136.0

[v1.2.2] - 2022-01-13

Changed

  • Version bump

[v1.2.1] - 2022-01-13

Added

  • Added test coverage script in package.json
  • NPM devDependencies:
    • c8 ^7.11.0

[v1.2.0] - 2022-01-13

Changed

  • Upgraded Node binary reference from 12.16 to v16.13.2 in .nvmrc
  • LICENSE edits
  • README.md edits
  • Beautified src/helpers/index.js
  • Beautified src/index.js
  • Beautified examples/ply-model-to-png.js
  • NPM package upgrades:
    • chai ^4.2.0 → ^4.3.4
    • eslint ^7.1.0 → ^8.6.0
    • mocha ^7.2.0 → ^9.1.3
    • pngjs ^4.0.0 → ^6.0.0
    • three ^0.115.0 → ^0.125.0

[v1.1.10] - 2020-05-29

Changed

  • Node engine version is now set to >=10.0.0. Thanks to Kevin Li
  • eslint devDependency upgraded from ^6.8.0 to ^7.1.0
  • mocha devDependency upgraded from ^7.1.1 to ^7.2.0

[v1.1.9] - 2020-05-08

Changed

  • Node engine version is now set to >=10.0.0. Thanks to Kevin Li
  • eslint devDependency upgraded from ^6.8.0 to ^7.1.0
  • mocha devDependency upgraded from ^7.1.1 to ^7.2.0

[v1.1.9] - 2020-05-08

Changed

  • three peerDependency is now set to >=0.115.0. Thanks to vanillaike

[v1.1.8] - 2020-04-18

Changed

  • README.md edits

[v1.1.7] - 2020-04-13

Added

  • NPM version badge

[v1.1.6] - 2020-04-13

Changed

  • Automated Github NPM publish workflow edits
  • README.md edits

[v1.1.5] - 2020-04-13

Added

  • Automated Github NPM publish workflow

[v1.1.4] - 2020-04-13

Added

  • Automated Github test CI workflow
  • Contributing policy file

[v1.1.3] - 2020-04-13

Changed

  • pngjs NPM devDependeny update to v4.0.0

[v1.1.2] - 2020-03-29

Changed

  • README.md edits

[v1.1.1] - 2020-03-29

Changed

  • Upgraded three NPM dependency to 0.115.0

[v1.1.0] - 2020-01-06

Added

  • Added mocha NPM to devDependencies
  • Added chai NPM to devDependencies
  • Added eslint NPM to devDependencies
  • Added index.spec.js file and code to the tests folder
  • Added test and test:watch to scripts property of package.json file
  • Added example:cube-to-png to scripts property of package.json file

Changed

  • README.md edits

[v1.0.0] - 2020-01-03

Added

  • Added three NPM to devDependencies
  • Added three NPM to peerDependencies
  • Added CHANGELOG.md file a repo tracked file
  • Added LICENCE file a repo tracked file
  • Added .editorconfig file a repo tracked file
  • Added package.json as a repo tracked file
  • Added package-lock.json as a repo tracked file
  • Added engines property to package.json
  • Added .nvmrc in order to easily support node version manager
  • Added pngjs NPM to devDependencies for example source code support
  • Added PLYLoader.js source file taken from three.js/dev/examples/js/loaders/PLYLoader.js
  • Added bufferToArrayBuffer method to THREE.PLYLoader

Changed

  • PLYLoader.js edits in order to make it usable with Node.js