threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324
  1. import {ILoader, Importer} from '../../assetmanager'
  2. import {PLYLoader} from 'three/examples/jsm/loaders/PLYLoader.js'
  3. import {AnyOptions} from 'ts-browser-helpers'
  4. import {BufferGeometry, Color, Mesh} from 'three'
  5. import {PhysicalMaterial} from '../../core'
  6. import {BaseImporterPlugin} from '../base/BaseImporterPlugin'
  7. /**
  8. * Adds support for loading `.ply`, `text/plain+ply` files and data uris
  9. * @category Plugins
  10. */
  11. export class PLYLoadPlugin extends BaseImporterPlugin {
  12. public static readonly PluginType = 'PLYLoadPlugin'
  13. protected _importer = new Importer(class extends PLYLoader implements ILoader {
  14. transform(res: BufferGeometry, _: AnyOptions): Mesh|undefined {
  15. if (!res.attributes?.normal) res.computeVertexNormals()
  16. // todo set mesh name from options/path
  17. return res ? new Mesh(res, new PhysicalMaterial({
  18. color: new Color(1, 1, 1),
  19. vertexColors: res.hasAttribute('color'),
  20. })) : undefined
  21. }
  22. }, ['ply'], ['text/plain+ply'], false)
  23. }