/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Schäfer, Marco * @author Alexander Rose */ import { RuntimeContext, Task } from 'mol-task'; import { addTriangle } from 'mol-geo/geometry/mesh/builder/triangle'; import { ShapeProvider } from 'mol-model/shape/provider'; import { Color } from 'mol-util/color'; import { PlyData, PlyFile } from 'mol-io/reader/ply/schema'; import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder'; import { Mesh } from 'mol-geo/geometry/mesh/mesh'; import { Shape } from 'mol-model/shape'; interface PlyShapeData { centers: number[], normals: number[], faces: number[], colors: Color[], labels: string[], } function collectData_for_Shape(parsedData: PlyData): PlyShapeData { // parsedData.data.PLY_File. to access So.format.Ply console.log('parsedData', parsedData) const { vertices, colors, faces, normals } = parsedData const data: PlyShapeData = { centers: vertices, normals: normals, faces: faces, colors: [], labels: [], } for (let i = 0; i) { const data = collectData_for_Shape(parsedData) await ctx.update('async creation of shape from myData') const { centers, normals, faces, colors, labels } = data const mesh = await getPlyMesh(ctx, centers, normals, faces, shape && shape.geometry) const groupCount = centers.length / 3 return shape || Shape.create( 'test', mesh, (groupId: number) => colors[groupId], // color: per group, same for instances () => 1, // size: constant (groupId: number, instanceId: number) => labels[instanceId * groupCount + groupId] // label: per group and instance ) } export const PlyShapeParams = { ...Mesh.Params } export type PlyShapeParams = typeof PlyShapeParams export function shapeFromPly(source: PlyFile, params?: {}) { return Task.create>('Parse Shape Data', async ctx => { console.log('source', source) return { label: 'Mesh', data: source.PLY_File, getShape, geometryUtils: Mesh.Utils } }) }