Open satyajitghana opened 3 years ago
Initially i tried to convert the ply file using
node convert2xkt.js -s scanwall220.ply -o scanwall220.ply.xkt -l ─╯ [convert2xkt] Reading input file: scanwall220.ply [convert2xkt] Input file size: 3919.92 kB [convert2xkt] Converting... Error: TypeError: Cannot read property 'COLOR_0' of undefined
but COLOR_0 IS defined
COLOR_0
this is the output after parsing using @loaders.gl/ply
@loaders.gl/ply
{ loaderData: { header: { comments: [Array], elements: [Array], headerLength: 265, format: 'binary_little_endian', version: '1.0' } }, header: { vertexCount: 76856, boundingBox: [ [Array], [Array] ] }, mode: 0, attributes: { POSITION: { value: [Float32Array], size: 3 }, NORMAL: { value: [Float32Array], size: 3 }, COLOR_0: { value: [Uint8Array], size: 3, normalized: true } } }
So i tried to write the script to convert to XKT myself:
This is the code i am using to convert to XKT file
import { parse } from '@loaders.gl/core'; import { PLYLoader } from '@loaders.gl/ply'; import { XKTModel } from './src/XKTModel/XKTModel.js'; import fs from 'fs'; const metaModelFileData = fs.readFileSync('scanwall220.ply'); const parsedData = await parse(metaModelFileData, PLYLoader) console.log(parsedData) const attributes = parsedData.attributes; const colorsValue = attributes.COLOR_0.value; const colorsCompressed = []; for (let i = 0, len = colorsValue.length; i < len; i += 4) { colorsCompressed.push(colorsValue[i]); colorsCompressed.push(colorsValue[i + 1]); colorsCompressed.push(colorsValue[i + 2]); } const xktModel = new XKTModel(); xktModel.createGeometry({ geometryId: "plyGeometry", primitiveType: "triangles", positions: attributes.POSITION.value, colorsCompressed: colorsCompressed });
which throws the error
internal/process/esm_loader.js:74 internalBinding('errors').triggerUncaughtException( ^ Parameter expected for 'triangles' primitive: params.indices Thrown at: at loadESM (internal/process/esm_loader.js:74:31)
Initially i tried to convert the ply file using
but
COLOR_0
IS definedthis is the output after parsing using
@loaders.gl/ply
So i tried to write the script to convert to XKT myself:
This is the code i am using to convert to XKT file
which throws the error