UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

27 lines 1.11 kB
import { Importer } from '../../assetmanager'; import { STLLoader } from 'three/examples/jsm/loaders/STLLoader.js'; import { Color, Mesh } from 'three'; import { PhysicalMaterial } from '../../core'; import { BaseImporterPlugin } from '../base/BaseImporterPlugin'; /** * Adds support for loading `.stl`, `model/stl` files and data uris. * @category Plugins */ export class STLLoadPlugin extends BaseImporterPlugin { constructor() { super(...arguments); this._importer = new Importer(class extends STLLoader { 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; } }, ['stl'], ['model/stl', 'model/x.stl-binary', 'model/x.stl-ascii'], false); } } STLLoadPlugin.PluginType = 'STLLoadPlugin'; //# sourceMappingURL=STLLoadPlugin.js.map