threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
27 lines • 1.08 kB
JavaScript
import { Importer } from '../../assetmanager';
import { PLYLoader } from 'three/examples/jsm/loaders/PLYLoader.js';
import { Color, Mesh } from 'three';
import { PhysicalMaterial } from '../../core';
import { BaseImporterPlugin } from '../base/BaseImporterPlugin';
/**
* Adds support for loading `.ply`, `text/plain+ply` files and data uris
* @category Plugins
*/
export class PLYLoadPlugin extends BaseImporterPlugin {
constructor() {
super(...arguments);
this._importer = new Importer(class extends PLYLoader {
transform(res, _) {
if (!res.attributes?.normal)
res.computeVertexNormals();
// todo set mesh name from options/path
return res ? new Mesh(res, new PhysicalMaterial({
color: new Color(1, 1, 1),
vertexColors: res.hasAttribute('color'),
})) : undefined;
}
}, ['ply'], ['text/plain+ply'], false);
}
}
PLYLoadPlugin.PluginType = 'PLYLoadPlugin';
//# sourceMappingURL=PLYLoadPlugin.js.map