Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

threejs-ply-loader

1.1.10 • Public • Published

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.115.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.

Usage

const fs = require("fs");
const { join } = require("path");
const THREE = require("three");
 
// Require object constructor
const PLYLoader = require("threejs-ply-loader")(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 v12.16.2

Install

npm i threejs-ply-loader

DownloadsWeekly Downloads

110

Version

1.1.10

License

MIT

Unpacked Size

32.4 kB

Total Files

16

Last publish

Collaborators

  • avatar