@loaders.gl/ply 3.4.0-alpha.2 → 3.4.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +142 -70
- package/dist/es5/index.js +17 -13
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/get-ply-schema.js +0 -1
- package/dist/es5/lib/get-ply-schema.js.map +1 -1
- package/dist/es5/lib/normalize-ply.js +47 -25
- package/dist/es5/lib/normalize-ply.js.map +1 -1
- package/dist/es5/lib/parse-ply-in-batches.js +162 -172
- package/dist/es5/lib/parse-ply-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-ply.js +114 -54
- package/dist/es5/lib/parse-ply.js.map +1 -1
- package/dist/es5/lib/ply-types.js.map +1 -1
- package/dist/es5/ply-loader.js +1 -3
- package/dist/es5/ply-loader.js.map +1 -1
- package/dist/es5/workers/ply-worker.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +6 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/get-ply-schema.js +0 -1
- package/dist/esm/lib/get-ply-schema.js.map +1 -1
- package/dist/esm/lib/normalize-ply.js +46 -26
- package/dist/esm/lib/normalize-ply.js.map +1 -1
- package/dist/esm/lib/parse-ply-in-batches.js +18 -27
- package/dist/esm/lib/parse-ply-in-batches.js.map +1 -1
- package/dist/esm/lib/parse-ply.js +92 -56
- package/dist/esm/lib/parse-ply.js.map +1 -1
- package/dist/esm/lib/ply-types.js.map +1 -1
- package/dist/esm/ply-loader.js +1 -4
- package/dist/esm/ply-loader.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -9
- package/dist/lib/normalize-ply.js +33 -11
- package/dist/lib/parse-ply-in-batches.d.ts +1 -1
- package/dist/lib/parse-ply-in-batches.d.ts.map +1 -1
- package/dist/lib/parse-ply-in-batches.js +19 -18
- package/dist/lib/parse-ply.d.ts +4 -1
- package/dist/lib/parse-ply.d.ts.map +1 -1
- package/dist/lib/parse-ply.js +103 -47
- package/dist/lib/ply-types.d.ts +19 -11
- package/dist/lib/ply-types.d.ts.map +1 -1
- package/dist/ply-worker.js +143 -71
- package/package.json +4 -4
- package/src/index.ts +6 -6
- package/src/lib/normalize-ply.ts +34 -12
- package/src/lib/parse-ply-in-batches.ts +20 -22
- package/src/lib/parse-ply.ts +114 -55
- package/src/lib/ply-types.ts +21 -12
package/dist/ply-worker.js
CHANGED
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// src/ply-loader.ts
|
|
225
|
-
var VERSION = true ? "3.4.0-alpha.
|
|
225
|
+
var VERSION = true ? "3.4.0-alpha.4" : "latest";
|
|
226
226
|
var PLYLoader = {
|
|
227
227
|
name: "PLY",
|
|
228
228
|
id: "ply",
|
|
@@ -821,15 +821,36 @@
|
|
|
821
821
|
}
|
|
822
822
|
function getMeshAttributes(attributes) {
|
|
823
823
|
const accessors = {};
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
824
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
825
|
+
switch (attributeName) {
|
|
826
|
+
case "vertices":
|
|
827
|
+
if (attributes.vertices.length > 0) {
|
|
828
|
+
accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };
|
|
829
|
+
}
|
|
830
|
+
break;
|
|
831
|
+
case "normals":
|
|
832
|
+
if (attributes.normals.length > 0) {
|
|
833
|
+
accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };
|
|
834
|
+
}
|
|
835
|
+
break;
|
|
836
|
+
case "uvs":
|
|
837
|
+
if (attributes.uvs.length > 0) {
|
|
838
|
+
accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };
|
|
839
|
+
}
|
|
840
|
+
break;
|
|
841
|
+
case "colors":
|
|
842
|
+
if (attributes.colors.length > 0) {
|
|
843
|
+
accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };
|
|
844
|
+
}
|
|
845
|
+
break;
|
|
846
|
+
case "indices":
|
|
847
|
+
break;
|
|
848
|
+
default:
|
|
849
|
+
if (attributes[attributeName].length > 0) {
|
|
850
|
+
accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
833
854
|
}
|
|
834
855
|
return accessors;
|
|
835
856
|
}
|
|
@@ -898,35 +919,72 @@
|
|
|
898
919
|
};
|
|
899
920
|
break;
|
|
900
921
|
case "property":
|
|
901
|
-
if (
|
|
902
|
-
|
|
922
|
+
if (currentElement2) {
|
|
923
|
+
const property = makePLYElementProperty(lineValues);
|
|
924
|
+
if (options?.propertyNameMapping && property.name in options?.propertyNameMapping) {
|
|
925
|
+
property.name = options?.propertyNameMapping[property.name];
|
|
926
|
+
}
|
|
927
|
+
currentElement2.properties.push(property);
|
|
903
928
|
}
|
|
904
|
-
currentElement2.properties.push(makePLYElementProperty(lineValues, options.propertyNameMapping));
|
|
905
929
|
break;
|
|
906
930
|
default:
|
|
907
931
|
console.log("unhandled", lineType, lineValues);
|
|
908
932
|
}
|
|
909
933
|
}
|
|
910
|
-
if (currentElement2
|
|
934
|
+
if (currentElement2) {
|
|
911
935
|
header.elements.push(currentElement2);
|
|
912
936
|
}
|
|
913
937
|
return header;
|
|
914
938
|
}
|
|
915
|
-
function
|
|
916
|
-
const
|
|
917
|
-
|
|
939
|
+
function getPLYAttributes(header) {
|
|
940
|
+
const attributes = {
|
|
941
|
+
indices: [],
|
|
942
|
+
vertices: [],
|
|
943
|
+
normals: [],
|
|
944
|
+
uvs: [],
|
|
945
|
+
colors: []
|
|
918
946
|
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
947
|
+
for (const element of header.elements) {
|
|
948
|
+
if (element.name === "vertex") {
|
|
949
|
+
for (const property of element.properties) {
|
|
950
|
+
switch (property.name) {
|
|
951
|
+
case "x":
|
|
952
|
+
case "y":
|
|
953
|
+
case "z":
|
|
954
|
+
case "nx":
|
|
955
|
+
case "ny":
|
|
956
|
+
case "nz":
|
|
957
|
+
case "s":
|
|
958
|
+
case "t":
|
|
959
|
+
case "red":
|
|
960
|
+
case "green":
|
|
961
|
+
case "blue":
|
|
962
|
+
break;
|
|
963
|
+
default:
|
|
964
|
+
attributes[property.name] = [];
|
|
965
|
+
break;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
925
969
|
}
|
|
926
|
-
|
|
927
|
-
|
|
970
|
+
return attributes;
|
|
971
|
+
}
|
|
972
|
+
function makePLYElementProperty(propertyValues) {
|
|
973
|
+
const type = propertyValues[0];
|
|
974
|
+
switch (type) {
|
|
975
|
+
case "list":
|
|
976
|
+
return {
|
|
977
|
+
type,
|
|
978
|
+
name: propertyValues[3],
|
|
979
|
+
countType: propertyValues[1],
|
|
980
|
+
itemType: propertyValues[2]
|
|
981
|
+
};
|
|
982
|
+
default:
|
|
983
|
+
return {
|
|
984
|
+
type,
|
|
985
|
+
name: propertyValues[1]
|
|
986
|
+
};
|
|
928
987
|
}
|
|
929
|
-
return property;
|
|
930
988
|
}
|
|
931
989
|
function parseASCIINumber(n, type) {
|
|
932
990
|
switch (type) {
|
|
@@ -952,7 +1010,7 @@
|
|
|
952
1010
|
throw new Error(type);
|
|
953
1011
|
}
|
|
954
1012
|
}
|
|
955
|
-
function
|
|
1013
|
+
function parsePLYElement(properties, line) {
|
|
956
1014
|
const values = line.split(/\s+/);
|
|
957
1015
|
const element = {};
|
|
958
1016
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -970,13 +1028,7 @@
|
|
|
970
1028
|
return element;
|
|
971
1029
|
}
|
|
972
1030
|
function parseASCII(data, header) {
|
|
973
|
-
const attributes =
|
|
974
|
-
indices: [],
|
|
975
|
-
vertices: [],
|
|
976
|
-
normals: [],
|
|
977
|
-
uvs: [],
|
|
978
|
-
colors: []
|
|
979
|
-
};
|
|
1031
|
+
const attributes = getPLYAttributes(header);
|
|
980
1032
|
let result;
|
|
981
1033
|
const patternBody = /end_header\s([\s\S]*)$/;
|
|
982
1034
|
let body = "";
|
|
@@ -994,7 +1046,7 @@
|
|
|
994
1046
|
currentElement2++;
|
|
995
1047
|
currentElementCount = 0;
|
|
996
1048
|
}
|
|
997
|
-
const element =
|
|
1049
|
+
const element = parsePLYElement(header.elements[currentElement2].properties, line);
|
|
998
1050
|
handleElement(attributes, header.elements[currentElement2].name, element);
|
|
999
1051
|
currentElementCount++;
|
|
1000
1052
|
}
|
|
@@ -1003,15 +1055,40 @@
|
|
|
1003
1055
|
}
|
|
1004
1056
|
function handleElement(buffer, elementName, element = {}) {
|
|
1005
1057
|
if (elementName === "vertex") {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1058
|
+
for (const propertyName of Object.keys(element)) {
|
|
1059
|
+
switch (propertyName) {
|
|
1060
|
+
case "x":
|
|
1061
|
+
buffer.vertices.push(element.x, element.y, element.z);
|
|
1062
|
+
break;
|
|
1063
|
+
case "y":
|
|
1064
|
+
case "z":
|
|
1065
|
+
break;
|
|
1066
|
+
case "nx":
|
|
1067
|
+
if ("nx" in element && "ny" in element && "nz" in element) {
|
|
1068
|
+
buffer.normals.push(element.nx, element.ny, element.nz);
|
|
1069
|
+
}
|
|
1070
|
+
break;
|
|
1071
|
+
case "ny":
|
|
1072
|
+
case "nz":
|
|
1073
|
+
break;
|
|
1074
|
+
case "s":
|
|
1075
|
+
if ("s" in element && "t" in element) {
|
|
1076
|
+
buffer.uvs.push(element.s, element.t);
|
|
1077
|
+
}
|
|
1078
|
+
break;
|
|
1079
|
+
case "t":
|
|
1080
|
+
break;
|
|
1081
|
+
case "red":
|
|
1082
|
+
if ("red" in element && "green" in element && "blue" in element) {
|
|
1083
|
+
buffer.colors.push(element.red, element.green, element.blue);
|
|
1084
|
+
}
|
|
1085
|
+
break;
|
|
1086
|
+
case "green":
|
|
1087
|
+
case "blue":
|
|
1088
|
+
break;
|
|
1089
|
+
default:
|
|
1090
|
+
buffer[propertyName].push(element[propertyName]);
|
|
1091
|
+
}
|
|
1015
1092
|
}
|
|
1016
1093
|
} else if (elementName === "face") {
|
|
1017
1094
|
const vertexIndices = element.vertex_indices || element.vertex_index;
|
|
@@ -1078,13 +1155,7 @@
|
|
|
1078
1155
|
return [element, read];
|
|
1079
1156
|
}
|
|
1080
1157
|
function parseBinary(data, header) {
|
|
1081
|
-
const attributes =
|
|
1082
|
-
indices: [],
|
|
1083
|
-
vertices: [],
|
|
1084
|
-
normals: [],
|
|
1085
|
-
uvs: [],
|
|
1086
|
-
colors: []
|
|
1087
|
-
};
|
|
1158
|
+
const attributes = getPLYAttributes(header);
|
|
1088
1159
|
const littleEndian = header.format === "binary_little_endian";
|
|
1089
1160
|
const body = new DataView(data, header.headerLength);
|
|
1090
1161
|
let result;
|
|
@@ -1166,21 +1237,22 @@
|
|
|
1166
1237
|
}
|
|
1167
1238
|
return header;
|
|
1168
1239
|
}
|
|
1169
|
-
function makePLYElementProperty2(
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1240
|
+
function makePLYElementProperty2(propertyValues, propertyNameMapping) {
|
|
1241
|
+
const type = propertyValues[0];
|
|
1242
|
+
switch (type) {
|
|
1243
|
+
case "list":
|
|
1244
|
+
return {
|
|
1245
|
+
type,
|
|
1246
|
+
name: propertyValues[3],
|
|
1247
|
+
countType: propertyValues[1],
|
|
1248
|
+
itemType: propertyValues[2]
|
|
1249
|
+
};
|
|
1250
|
+
default:
|
|
1251
|
+
return {
|
|
1252
|
+
type,
|
|
1253
|
+
name: propertyValues[1]
|
|
1254
|
+
};
|
|
1182
1255
|
}
|
|
1183
|
-
return property;
|
|
1184
1256
|
}
|
|
1185
1257
|
async function parseASCII2(lineIterator, header) {
|
|
1186
1258
|
const attributes = {
|
|
@@ -1199,7 +1271,7 @@
|
|
|
1199
1271
|
currentElement2++;
|
|
1200
1272
|
currentElementCount = 0;
|
|
1201
1273
|
}
|
|
1202
|
-
const element =
|
|
1274
|
+
const element = parsePLYElement2(header.elements[currentElement2].properties, line);
|
|
1203
1275
|
handleElement2(attributes, header.elements[currentElement2].name, element);
|
|
1204
1276
|
currentElementCount++;
|
|
1205
1277
|
}
|
|
@@ -1230,7 +1302,7 @@
|
|
|
1230
1302
|
throw new Error(type);
|
|
1231
1303
|
}
|
|
1232
1304
|
}
|
|
1233
|
-
function
|
|
1305
|
+
function parsePLYElement2(properties, line) {
|
|
1234
1306
|
const values = line.split(/\s+/);
|
|
1235
1307
|
const element = {};
|
|
1236
1308
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -1278,10 +1350,10 @@
|
|
|
1278
1350
|
// src/index.ts
|
|
1279
1351
|
var PLYLoader2 = {
|
|
1280
1352
|
...PLYLoader,
|
|
1281
|
-
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options),
|
|
1282
|
-
parseTextSync: parsePLY,
|
|
1283
|
-
parseSync: parsePLY,
|
|
1284
|
-
parseInBatches: parsePLYInBatches
|
|
1353
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
1354
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
1355
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
1356
|
+
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
1285
1357
|
};
|
|
1286
1358
|
|
|
1287
1359
|
// src/workers/ply-worker.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/ply",
|
|
3
|
-
"version": "3.4.0-alpha.
|
|
3
|
+
"version": "3.4.0-alpha.4",
|
|
4
4
|
"description": "Framework-independent loader for the PLY format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.3.1",
|
|
37
|
-
"@loaders.gl/loader-utils": "3.4.0-alpha.
|
|
38
|
-
"@loaders.gl/schema": "3.4.0-alpha.
|
|
37
|
+
"@loaders.gl/loader-utils": "3.4.0-alpha.4",
|
|
38
|
+
"@loaders.gl/schema": "3.4.0-alpha.4"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "f039a523df8b908a91f26c5ba8c4cfc1924b6140"
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
2
2
|
import {PLYLoader as PLYWorkerLoader} from './ply-loader';
|
|
3
|
-
import parsePLY from './lib/parse-ply';
|
|
4
|
-
import parsePLYInBatches from './lib/parse-ply-in-batches';
|
|
3
|
+
import {parsePLY} from './lib/parse-ply';
|
|
4
|
+
import {parsePLYInBatches} from './lib/parse-ply-in-batches';
|
|
5
5
|
|
|
6
6
|
// PLYLoader
|
|
7
7
|
|
|
@@ -13,10 +13,10 @@ export {PLYWorkerLoader};
|
|
|
13
13
|
export const PLYLoader = {
|
|
14
14
|
...PLYWorkerLoader,
|
|
15
15
|
// Note: parsePLY supports both text and binary
|
|
16
|
-
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options), // TODO - this may not detect text correctly?
|
|
17
|
-
parseTextSync: parsePLY,
|
|
18
|
-
parseSync: parsePLY,
|
|
19
|
-
parseInBatches: parsePLYInBatches
|
|
16
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?
|
|
17
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
18
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
19
|
+
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const _typecheckPLYLoader: LoaderWithParser = PLYLoader;
|
package/src/lib/normalize-ply.ts
CHANGED
|
@@ -50,25 +50,47 @@ export default function normalizePLY(
|
|
|
50
50
|
* @param attributes
|
|
51
51
|
* @returns accessors []
|
|
52
52
|
*/
|
|
53
|
+
// eslint-disable-next-line complexity
|
|
53
54
|
function getMeshAttributes(attributes: PLYAttributes): MeshAttributes {
|
|
54
55
|
const accessors: MeshAttributes = {};
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
58
|
+
switch (attributeName) {
|
|
59
|
+
case 'vertices':
|
|
60
|
+
if (attributes.vertices.length > 0) {
|
|
61
|
+
accessors.POSITION = {value: new Float32Array(attributes.vertices), size: 3};
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
// optional attributes data
|
|
66
|
+
case 'normals':
|
|
67
|
+
if (attributes.normals.length > 0) {
|
|
68
|
+
accessors.NORMAL = {value: new Float32Array(attributes.normals), size: 3};
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
case 'uvs':
|
|
73
|
+
if (attributes.uvs.length > 0) {
|
|
74
|
+
accessors.TEXCOORD_0 = {value: new Float32Array(attributes.uvs), size: 2};
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
63
77
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
case 'colors':
|
|
79
|
+
if (attributes.colors.length > 0) {
|
|
80
|
+
// TODO - normalized shoud be based on `uchar` flag in source data?
|
|
81
|
+
accessors.COLOR_0 = {value: new Uint8Array(attributes.colors), size: 3, normalized: true};
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
67
84
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
accessors.COLOR_0 = {value: new Uint8Array(attributes.colors), size: 3, normalized: true};
|
|
71
|
-
}
|
|
85
|
+
case 'indices':
|
|
86
|
+
break;
|
|
72
87
|
|
|
88
|
+
default:
|
|
89
|
+
if (attributes[attributeName].length > 0) {
|
|
90
|
+
accessors[attributeName] = {value: new Float32Array(attributes[attributeName]), size: 1};
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
73
95
|
return accessors;
|
|
74
96
|
}
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
import {makeLineIterator, makeTextDecoderIterator, forEach} from '@loaders.gl/loader-utils';
|
|
25
25
|
import normalizePLY from './normalize-ply';
|
|
26
|
-
import {PLYMesh, PLYHeader,
|
|
26
|
+
import {PLYMesh, PLYHeader, PLYElement, PLYProperty, PLYAttributes} from './ply-types';
|
|
27
27
|
|
|
28
|
-
let currentElement:
|
|
28
|
+
let currentElement: PLYElement;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* PARSER
|
|
32
32
|
* @param iterator
|
|
33
33
|
* @param options
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export async function* parsePLYInBatches(
|
|
36
36
|
iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,
|
|
37
37
|
options: any
|
|
38
38
|
): AsyncIterable<PLYMesh> {
|
|
@@ -134,24 +134,22 @@ async function parsePLYHeader(
|
|
|
134
134
|
return header;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
function makePLYElementProperty(
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
function makePLYElementProperty(propertyValues: string[], propertyNameMapping: []): PLYProperty {
|
|
138
|
+
const type = propertyValues[0];
|
|
139
|
+
switch (type) {
|
|
140
|
+
case 'list':
|
|
141
|
+
return {
|
|
142
|
+
type,
|
|
143
|
+
name: propertyValues[3],
|
|
144
|
+
countType: propertyValues[1],
|
|
145
|
+
itemType: propertyValues[2]
|
|
146
|
+
};
|
|
147
|
+
default:
|
|
148
|
+
return {
|
|
149
|
+
type,
|
|
150
|
+
name: propertyValues[1]
|
|
151
|
+
};
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
return property;
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
// ASCII PARSING
|
|
@@ -182,7 +180,7 @@ async function parseASCII(lineIterator: AsyncIterable<string>, header: PLYHeader
|
|
|
182
180
|
currentElementCount = 0;
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
const element =
|
|
183
|
+
const element = parsePLYElement(header.elements[currentElement].properties, line);
|
|
186
184
|
handleElement(attributes, header.elements[currentElement].name, element);
|
|
187
185
|
currentElementCount++;
|
|
188
186
|
}
|
|
@@ -229,7 +227,7 @@ function parseASCIINumber(n: string, type: string): number {
|
|
|
229
227
|
* @param line
|
|
230
228
|
* @returns element
|
|
231
229
|
*/
|
|
232
|
-
function
|
|
230
|
+
function parsePLYElement(properties: any[], line: string) {
|
|
233
231
|
const values: any = line.split(/\s+/);
|
|
234
232
|
|
|
235
233
|
const element = {};
|