@loaders.gl/ply 4.0.0-alpha.1 → 4.0.0-alpha.11
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +833 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +51 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/get-ply-schema.js +28 -0
- package/dist/es5/lib/get-ply-schema.js.map +1 -0
- package/dist/es5/lib/normalize-ply.js +93 -0
- package/dist/es5/lib/normalize-ply.js.map +1 -0
- package/dist/es5/lib/parse-ply-in-batches.js +289 -0
- package/dist/es5/lib/parse-ply-in-batches.js.map +1 -0
- package/dist/es5/lib/parse-ply.js +348 -0
- package/dist/es5/lib/parse-ply.js.map +1 -0
- package/dist/es5/lib/ply-types.js +2 -0
- package/dist/es5/lib/ply-types.js.map +1 -0
- package/dist/es5/ply-loader.js +26 -0
- package/dist/es5/ply-loader.js.map +1 -0
- package/dist/es5/workers/ply-worker.js +6 -0
- package/dist/es5/workers/ply-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/get-ply-schema.js +22 -0
- package/dist/esm/lib/get-ply-schema.js.map +1 -0
- package/dist/esm/lib/normalize-ply.js +86 -0
- package/dist/esm/lib/normalize-ply.js.map +1 -0
- package/dist/esm/lib/parse-ply-in-batches.js +177 -0
- package/dist/esm/lib/parse-ply-in-batches.js.map +1 -0
- package/dist/esm/lib/parse-ply.js +319 -0
- package/dist/esm/lib/parse-ply.js.map +1 -0
- package/dist/esm/lib/ply-types.js +2 -0
- package/dist/esm/lib/ply-types.js.map +1 -0
- package/dist/esm/ply-loader.js +18 -0
- package/dist/esm/ply-loader.js.map +1 -0
- package/dist/esm/workers/ply-worker.js +4 -0
- package/dist/esm/workers/ply-worker.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -11
- package/dist/lib/get-ply-schema.d.ts +10 -0
- package/dist/lib/get-ply-schema.d.ts.map +1 -0
- package/dist/lib/get-ply-schema.js +34 -24
- package/dist/lib/normalize-ply.d.ts +8 -0
- package/dist/lib/normalize-ply.d.ts.map +1 -0
- package/dist/lib/normalize-ply.js +76 -65
- package/dist/lib/parse-ply-in-batches.d.ts +8 -0
- package/dist/lib/parse-ply-in-batches.d.ts.map +1 -0
- package/dist/lib/parse-ply-in-batches.js +237 -202
- package/dist/lib/parse-ply.d.ts +11 -0
- package/dist/lib/parse-ply.d.ts.map +1 -0
- package/dist/lib/parse-ply.js +378 -299
- package/dist/lib/ply-types.d.ts +37 -0
- package/dist/lib/ply-types.d.ts.map +1 -0
- package/dist/lib/ply-types.js +2 -2
- package/dist/ply-loader.d.ts +10 -0
- package/dist/ply-loader.d.ts.map +1 -0
- package/dist/ply-loader.js +27 -18
- package/dist/ply-worker.js +240 -578
- package/dist/workers/ply-worker.d.ts +2 -0
- package/dist/workers/ply-worker.d.ts.map +1 -0
- package/dist/workers/ply-worker.js +5 -4
- package/package.json +9 -12
- package/src/index.ts +15 -10
- package/src/lib/get-ply-schema.ts +11 -10
- package/src/lib/normalize-ply.ts +34 -12
- package/src/lib/parse-ply-in-batches.ts +23 -26
- package/src/lib/parse-ply.ts +114 -55
- package/src/lib/ply-types.ts +21 -12
- package/src/ply-loader.ts +4 -3
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/get-ply-schema.js.map +0 -1
- package/dist/lib/normalize-ply.js.map +0 -1
- package/dist/lib/parse-ply-in-batches.js.map +0 -1
- package/dist/lib/parse-ply.js.map +0 -1
- package/dist/lib/ply-types.js.map +0 -1
- package/dist/ply-loader.js.map +0 -1
- package/dist/workers/ply-worker.js.map +0 -1
package/dist/ply-worker.js
CHANGED
|
@@ -35,16 +35,33 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
function getParentPort() {
|
|
39
|
+
let parentPort;
|
|
40
|
+
try {
|
|
41
|
+
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
42
|
+
parentPort = globalThis.parentPort;
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
return parentPort;
|
|
46
|
+
}
|
|
38
47
|
var onMessageWrapperMap = new Map();
|
|
39
48
|
var WorkerBody = class {
|
|
49
|
+
static inWorkerThread() {
|
|
50
|
+
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
51
|
+
}
|
|
40
52
|
static set onmessage(onMessage) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const { type, payload } = message.data;
|
|
53
|
+
function handleMessage(message) {
|
|
54
|
+
const parentPort3 = getParentPort();
|
|
55
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
46
56
|
onMessage(type, payload);
|
|
47
|
-
}
|
|
57
|
+
}
|
|
58
|
+
const parentPort2 = getParentPort();
|
|
59
|
+
if (parentPort2) {
|
|
60
|
+
parentPort2.on("message", handleMessage);
|
|
61
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
62
|
+
} else {
|
|
63
|
+
globalThis.onmessage = handleMessage;
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
static addEventListener(onMessage) {
|
|
50
67
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
@@ -53,22 +70,36 @@
|
|
|
53
70
|
if (!isKnownMessage(message)) {
|
|
54
71
|
return;
|
|
55
72
|
}
|
|
56
|
-
const
|
|
73
|
+
const parentPort3 = getParentPort();
|
|
74
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
57
75
|
onMessage(type, payload);
|
|
58
76
|
};
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
const parentPort2 = getParentPort();
|
|
79
|
+
if (parentPort2) {
|
|
80
|
+
console.error("not implemented");
|
|
81
|
+
} else {
|
|
82
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
static removeEventListener(onMessage) {
|
|
63
86
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
87
|
onMessageWrapperMap.delete(onMessage);
|
|
65
|
-
|
|
88
|
+
const parentPort2 = getParentPort();
|
|
89
|
+
if (parentPort2) {
|
|
90
|
+
console.error("not implemented");
|
|
91
|
+
} else {
|
|
92
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
static postMessage(type, payload) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
const data = { source: "loaders.gl", type, payload };
|
|
97
|
+
const transferList = getTransferList(payload);
|
|
98
|
+
const parentPort2 = getParentPort();
|
|
99
|
+
if (parentPort2) {
|
|
100
|
+
parentPort2.postMessage(data, transferList);
|
|
101
|
+
} else {
|
|
102
|
+
globalThis.postMessage(data, transferList);
|
|
72
103
|
}
|
|
73
104
|
}
|
|
74
105
|
};
|
|
@@ -80,19 +111,20 @@
|
|
|
80
111
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
112
|
var requestId = 0;
|
|
82
113
|
function createLoaderWorker(loader) {
|
|
83
|
-
if (
|
|
114
|
+
if (!WorkerBody.inWorkerThread()) {
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
86
117
|
WorkerBody.onmessage = async (type, payload) => {
|
|
87
118
|
switch (type) {
|
|
88
119
|
case "process":
|
|
89
120
|
try {
|
|
90
|
-
const { input, options = {} } = payload;
|
|
121
|
+
const { input, options = {}, context = {} } = payload;
|
|
91
122
|
const result = await parseData({
|
|
92
123
|
loader,
|
|
93
124
|
arrayBuffer: input,
|
|
94
125
|
options,
|
|
95
126
|
context: {
|
|
127
|
+
...context,
|
|
96
128
|
parse: parseOnMainThread
|
|
97
129
|
}
|
|
98
130
|
});
|
|
@@ -190,12 +222,11 @@
|
|
|
190
222
|
}
|
|
191
223
|
|
|
192
224
|
// src/ply-loader.ts
|
|
193
|
-
var VERSION =
|
|
225
|
+
var VERSION = true ? "4.0.0-alpha.11" : "latest";
|
|
194
226
|
var PLYLoader = {
|
|
195
227
|
name: "PLY",
|
|
196
228
|
id: "ply",
|
|
197
229
|
module: "ply",
|
|
198
|
-
shapes: ["mesh", "gltf", "columnar-table"],
|
|
199
230
|
version: VERSION,
|
|
200
231
|
worker: true,
|
|
201
232
|
extensions: ["ply"],
|
|
@@ -208,7 +239,32 @@
|
|
|
208
239
|
}
|
|
209
240
|
};
|
|
210
241
|
|
|
211
|
-
// ../schema/src/
|
|
242
|
+
// ../schema/src/lib/table/simple-table/data-type.ts
|
|
243
|
+
function getDataTypeFromTypedArray(array) {
|
|
244
|
+
switch (array.constructor) {
|
|
245
|
+
case Int8Array:
|
|
246
|
+
return "int8";
|
|
247
|
+
case Uint8Array:
|
|
248
|
+
case Uint8ClampedArray:
|
|
249
|
+
return "uint8";
|
|
250
|
+
case Int16Array:
|
|
251
|
+
return "int16";
|
|
252
|
+
case Uint16Array:
|
|
253
|
+
return "uint16";
|
|
254
|
+
case Int32Array:
|
|
255
|
+
return "int32";
|
|
256
|
+
case Uint32Array:
|
|
257
|
+
return "uint32";
|
|
258
|
+
case Float32Array:
|
|
259
|
+
return "float32";
|
|
260
|
+
case Float64Array:
|
|
261
|
+
return "float64";
|
|
262
|
+
default:
|
|
263
|
+
return "null";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
212
268
|
function getMeshBoundingBox(attributes) {
|
|
213
269
|
let minX = Infinity;
|
|
214
270
|
let minY = Infinity;
|
|
@@ -235,486 +291,20 @@
|
|
|
235
291
|
];
|
|
236
292
|
}
|
|
237
293
|
|
|
238
|
-
// ../schema/src/lib/
|
|
239
|
-
function
|
|
240
|
-
if (!condition) {
|
|
241
|
-
throw new Error(message || "loader assertion failed.");
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// ../schema/src/lib/schema/impl/schema.ts
|
|
246
|
-
var Schema = class {
|
|
247
|
-
constructor(fields, metadata) {
|
|
248
|
-
assert(Array.isArray(fields));
|
|
249
|
-
checkNames(fields);
|
|
250
|
-
this.fields = fields;
|
|
251
|
-
this.metadata = metadata || new Map();
|
|
252
|
-
}
|
|
253
|
-
compareTo(other) {
|
|
254
|
-
if (this.metadata !== other.metadata) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
if (this.fields.length !== other.fields.length) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
for (let i = 0; i < this.fields.length; ++i) {
|
|
261
|
-
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
select(...columnNames) {
|
|
268
|
-
const nameMap = Object.create(null);
|
|
269
|
-
for (const name of columnNames) {
|
|
270
|
-
nameMap[name] = true;
|
|
271
|
-
}
|
|
272
|
-
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
273
|
-
return new Schema(selectedFields, this.metadata);
|
|
274
|
-
}
|
|
275
|
-
selectAt(...columnIndices) {
|
|
276
|
-
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
277
|
-
return new Schema(selectedFields, this.metadata);
|
|
278
|
-
}
|
|
279
|
-
assign(schemaOrFields) {
|
|
280
|
-
let fields;
|
|
281
|
-
let metadata = this.metadata;
|
|
282
|
-
if (schemaOrFields instanceof Schema) {
|
|
283
|
-
const otherSchema = schemaOrFields;
|
|
284
|
-
fields = otherSchema.fields;
|
|
285
|
-
metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
|
|
286
|
-
} else {
|
|
287
|
-
fields = schemaOrFields;
|
|
288
|
-
}
|
|
289
|
-
const fieldMap = Object.create(null);
|
|
290
|
-
for (const field of this.fields) {
|
|
291
|
-
fieldMap[field.name] = field;
|
|
292
|
-
}
|
|
293
|
-
for (const field of fields) {
|
|
294
|
-
fieldMap[field.name] = field;
|
|
295
|
-
}
|
|
296
|
-
const mergedFields = Object.values(fieldMap);
|
|
297
|
-
return new Schema(mergedFields, metadata);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
function checkNames(fields) {
|
|
301
|
-
const usedNames = {};
|
|
302
|
-
for (const field of fields) {
|
|
303
|
-
if (usedNames[field.name]) {
|
|
304
|
-
console.warn("Schema: duplicated field name", field.name, field);
|
|
305
|
-
}
|
|
306
|
-
usedNames[field.name] = true;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
function mergeMaps(m1, m2) {
|
|
310
|
-
return new Map([...m1 || new Map(), ...m2 || new Map()]);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// ../schema/src/lib/schema/impl/field.ts
|
|
314
|
-
var Field = class {
|
|
315
|
-
constructor(name, type, nullable = false, metadata = new Map()) {
|
|
316
|
-
this.name = name;
|
|
317
|
-
this.type = type;
|
|
318
|
-
this.nullable = nullable;
|
|
319
|
-
this.metadata = metadata;
|
|
320
|
-
}
|
|
321
|
-
get typeId() {
|
|
322
|
-
return this.type && this.type.typeId;
|
|
323
|
-
}
|
|
324
|
-
clone() {
|
|
325
|
-
return new Field(this.name, this.type, this.nullable, this.metadata);
|
|
326
|
-
}
|
|
327
|
-
compareTo(other) {
|
|
328
|
-
return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
|
|
329
|
-
}
|
|
330
|
-
toString() {
|
|
331
|
-
return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// ../schema/src/lib/schema/impl/enum.ts
|
|
336
|
-
var Type;
|
|
337
|
-
(function(Type2) {
|
|
338
|
-
Type2[Type2["NONE"] = 0] = "NONE";
|
|
339
|
-
Type2[Type2["Null"] = 1] = "Null";
|
|
340
|
-
Type2[Type2["Int"] = 2] = "Int";
|
|
341
|
-
Type2[Type2["Float"] = 3] = "Float";
|
|
342
|
-
Type2[Type2["Binary"] = 4] = "Binary";
|
|
343
|
-
Type2[Type2["Utf8"] = 5] = "Utf8";
|
|
344
|
-
Type2[Type2["Bool"] = 6] = "Bool";
|
|
345
|
-
Type2[Type2["Decimal"] = 7] = "Decimal";
|
|
346
|
-
Type2[Type2["Date"] = 8] = "Date";
|
|
347
|
-
Type2[Type2["Time"] = 9] = "Time";
|
|
348
|
-
Type2[Type2["Timestamp"] = 10] = "Timestamp";
|
|
349
|
-
Type2[Type2["Interval"] = 11] = "Interval";
|
|
350
|
-
Type2[Type2["List"] = 12] = "List";
|
|
351
|
-
Type2[Type2["Struct"] = 13] = "Struct";
|
|
352
|
-
Type2[Type2["Union"] = 14] = "Union";
|
|
353
|
-
Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
|
|
354
|
-
Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
|
|
355
|
-
Type2[Type2["Map"] = 17] = "Map";
|
|
356
|
-
Type2[Type2["Dictionary"] = -1] = "Dictionary";
|
|
357
|
-
Type2[Type2["Int8"] = -2] = "Int8";
|
|
358
|
-
Type2[Type2["Int16"] = -3] = "Int16";
|
|
359
|
-
Type2[Type2["Int32"] = -4] = "Int32";
|
|
360
|
-
Type2[Type2["Int64"] = -5] = "Int64";
|
|
361
|
-
Type2[Type2["Uint8"] = -6] = "Uint8";
|
|
362
|
-
Type2[Type2["Uint16"] = -7] = "Uint16";
|
|
363
|
-
Type2[Type2["Uint32"] = -8] = "Uint32";
|
|
364
|
-
Type2[Type2["Uint64"] = -9] = "Uint64";
|
|
365
|
-
Type2[Type2["Float16"] = -10] = "Float16";
|
|
366
|
-
Type2[Type2["Float32"] = -11] = "Float32";
|
|
367
|
-
Type2[Type2["Float64"] = -12] = "Float64";
|
|
368
|
-
Type2[Type2["DateDay"] = -13] = "DateDay";
|
|
369
|
-
Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
|
|
370
|
-
Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
|
|
371
|
-
Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
|
|
372
|
-
Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
|
|
373
|
-
Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
|
|
374
|
-
Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
|
|
375
|
-
Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
|
|
376
|
-
Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
|
|
377
|
-
Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
|
|
378
|
-
Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
|
|
379
|
-
Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
|
|
380
|
-
Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
|
|
381
|
-
Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
|
|
382
|
-
})(Type || (Type = {}));
|
|
383
|
-
|
|
384
|
-
// ../schema/src/lib/schema/impl/type.ts
|
|
385
|
-
var DataType = class {
|
|
386
|
-
static isNull(x) {
|
|
387
|
-
return x && x.typeId === Type.Null;
|
|
388
|
-
}
|
|
389
|
-
static isInt(x) {
|
|
390
|
-
return x && x.typeId === Type.Int;
|
|
391
|
-
}
|
|
392
|
-
static isFloat(x) {
|
|
393
|
-
return x && x.typeId === Type.Float;
|
|
394
|
-
}
|
|
395
|
-
static isBinary(x) {
|
|
396
|
-
return x && x.typeId === Type.Binary;
|
|
397
|
-
}
|
|
398
|
-
static isUtf8(x) {
|
|
399
|
-
return x && x.typeId === Type.Utf8;
|
|
400
|
-
}
|
|
401
|
-
static isBool(x) {
|
|
402
|
-
return x && x.typeId === Type.Bool;
|
|
403
|
-
}
|
|
404
|
-
static isDecimal(x) {
|
|
405
|
-
return x && x.typeId === Type.Decimal;
|
|
406
|
-
}
|
|
407
|
-
static isDate(x) {
|
|
408
|
-
return x && x.typeId === Type.Date;
|
|
409
|
-
}
|
|
410
|
-
static isTime(x) {
|
|
411
|
-
return x && x.typeId === Type.Time;
|
|
412
|
-
}
|
|
413
|
-
static isTimestamp(x) {
|
|
414
|
-
return x && x.typeId === Type.Timestamp;
|
|
415
|
-
}
|
|
416
|
-
static isInterval(x) {
|
|
417
|
-
return x && x.typeId === Type.Interval;
|
|
418
|
-
}
|
|
419
|
-
static isList(x) {
|
|
420
|
-
return x && x.typeId === Type.List;
|
|
421
|
-
}
|
|
422
|
-
static isStruct(x) {
|
|
423
|
-
return x && x.typeId === Type.Struct;
|
|
424
|
-
}
|
|
425
|
-
static isUnion(x) {
|
|
426
|
-
return x && x.typeId === Type.Union;
|
|
427
|
-
}
|
|
428
|
-
static isFixedSizeBinary(x) {
|
|
429
|
-
return x && x.typeId === Type.FixedSizeBinary;
|
|
430
|
-
}
|
|
431
|
-
static isFixedSizeList(x) {
|
|
432
|
-
return x && x.typeId === Type.FixedSizeList;
|
|
433
|
-
}
|
|
434
|
-
static isMap(x) {
|
|
435
|
-
return x && x.typeId === Type.Map;
|
|
436
|
-
}
|
|
437
|
-
static isDictionary(x) {
|
|
438
|
-
return x && x.typeId === Type.Dictionary;
|
|
439
|
-
}
|
|
440
|
-
get typeId() {
|
|
441
|
-
return Type.NONE;
|
|
442
|
-
}
|
|
443
|
-
compareTo(other) {
|
|
444
|
-
return this === other;
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
var Null = class extends DataType {
|
|
448
|
-
get typeId() {
|
|
449
|
-
return Type.Null;
|
|
450
|
-
}
|
|
451
|
-
get [Symbol.toStringTag]() {
|
|
452
|
-
return "Null";
|
|
453
|
-
}
|
|
454
|
-
toString() {
|
|
455
|
-
return "Null";
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
var Bool = class extends DataType {
|
|
459
|
-
get typeId() {
|
|
460
|
-
return Type.Bool;
|
|
461
|
-
}
|
|
462
|
-
get [Symbol.toStringTag]() {
|
|
463
|
-
return "Bool";
|
|
464
|
-
}
|
|
465
|
-
toString() {
|
|
466
|
-
return "Bool";
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
var Int = class extends DataType {
|
|
470
|
-
constructor(isSigned, bitWidth) {
|
|
471
|
-
super();
|
|
472
|
-
this.isSigned = isSigned;
|
|
473
|
-
this.bitWidth = bitWidth;
|
|
474
|
-
}
|
|
475
|
-
get typeId() {
|
|
476
|
-
return Type.Int;
|
|
477
|
-
}
|
|
478
|
-
get [Symbol.toStringTag]() {
|
|
479
|
-
return "Int";
|
|
480
|
-
}
|
|
481
|
-
toString() {
|
|
482
|
-
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
var Int8 = class extends Int {
|
|
486
|
-
constructor() {
|
|
487
|
-
super(true, 8);
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
var Int16 = class extends Int {
|
|
491
|
-
constructor() {
|
|
492
|
-
super(true, 16);
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
var Int32 = class extends Int {
|
|
496
|
-
constructor() {
|
|
497
|
-
super(true, 32);
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
var Uint8 = class extends Int {
|
|
501
|
-
constructor() {
|
|
502
|
-
super(false, 8);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
var Uint16 = class extends Int {
|
|
506
|
-
constructor() {
|
|
507
|
-
super(false, 16);
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
var Uint32 = class extends Int {
|
|
511
|
-
constructor() {
|
|
512
|
-
super(false, 32);
|
|
513
|
-
}
|
|
514
|
-
};
|
|
515
|
-
var Precision = {
|
|
516
|
-
HALF: 16,
|
|
517
|
-
SINGLE: 32,
|
|
518
|
-
DOUBLE: 64
|
|
519
|
-
};
|
|
520
|
-
var Float = class extends DataType {
|
|
521
|
-
constructor(precision) {
|
|
522
|
-
super();
|
|
523
|
-
this.precision = precision;
|
|
524
|
-
}
|
|
525
|
-
get typeId() {
|
|
526
|
-
return Type.Float;
|
|
527
|
-
}
|
|
528
|
-
get [Symbol.toStringTag]() {
|
|
529
|
-
return "Float";
|
|
530
|
-
}
|
|
531
|
-
toString() {
|
|
532
|
-
return `Float${this.precision}`;
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
var Float32 = class extends Float {
|
|
536
|
-
constructor() {
|
|
537
|
-
super(Precision.SINGLE);
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
var Float64 = class extends Float {
|
|
541
|
-
constructor() {
|
|
542
|
-
super(Precision.DOUBLE);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
var Binary = class extends DataType {
|
|
546
|
-
constructor() {
|
|
547
|
-
super();
|
|
548
|
-
}
|
|
549
|
-
get typeId() {
|
|
550
|
-
return Type.Binary;
|
|
551
|
-
}
|
|
552
|
-
toString() {
|
|
553
|
-
return "Binary";
|
|
554
|
-
}
|
|
555
|
-
get [Symbol.toStringTag]() {
|
|
556
|
-
return "Binary";
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
var Utf8 = class extends DataType {
|
|
560
|
-
get typeId() {
|
|
561
|
-
return Type.Utf8;
|
|
562
|
-
}
|
|
563
|
-
get [Symbol.toStringTag]() {
|
|
564
|
-
return "Utf8";
|
|
565
|
-
}
|
|
566
|
-
toString() {
|
|
567
|
-
return "Utf8";
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
var DateUnit = {
|
|
571
|
-
DAY: 0,
|
|
572
|
-
MILLISECOND: 1
|
|
573
|
-
};
|
|
574
|
-
var Date = class extends DataType {
|
|
575
|
-
constructor(unit) {
|
|
576
|
-
super();
|
|
577
|
-
this.unit = unit;
|
|
578
|
-
}
|
|
579
|
-
get typeId() {
|
|
580
|
-
return Type.Date;
|
|
581
|
-
}
|
|
582
|
-
get [Symbol.toStringTag]() {
|
|
583
|
-
return "Date";
|
|
584
|
-
}
|
|
585
|
-
toString() {
|
|
586
|
-
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
var TimeUnit = {
|
|
590
|
-
SECOND: 1,
|
|
591
|
-
MILLISECOND: 1e3,
|
|
592
|
-
MICROSECOND: 1e6,
|
|
593
|
-
NANOSECOND: 1e9
|
|
594
|
-
};
|
|
595
|
-
var Time = class extends DataType {
|
|
596
|
-
constructor(unit, bitWidth) {
|
|
597
|
-
super();
|
|
598
|
-
this.unit = unit;
|
|
599
|
-
this.bitWidth = bitWidth;
|
|
600
|
-
}
|
|
601
|
-
get typeId() {
|
|
602
|
-
return Type.Time;
|
|
603
|
-
}
|
|
604
|
-
toString() {
|
|
605
|
-
return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
|
|
606
|
-
}
|
|
607
|
-
get [Symbol.toStringTag]() {
|
|
608
|
-
return "Time";
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
var Timestamp = class extends DataType {
|
|
612
|
-
constructor(unit, timezone = null) {
|
|
613
|
-
super();
|
|
614
|
-
this.unit = unit;
|
|
615
|
-
this.timezone = timezone;
|
|
616
|
-
}
|
|
617
|
-
get typeId() {
|
|
618
|
-
return Type.Timestamp;
|
|
619
|
-
}
|
|
620
|
-
get [Symbol.toStringTag]() {
|
|
621
|
-
return "Timestamp";
|
|
622
|
-
}
|
|
623
|
-
toString() {
|
|
624
|
-
return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
var IntervalUnit = {
|
|
628
|
-
DAY_TIME: 0,
|
|
629
|
-
YEAR_MONTH: 1
|
|
630
|
-
};
|
|
631
|
-
var Interval = class extends DataType {
|
|
632
|
-
constructor(unit) {
|
|
633
|
-
super();
|
|
634
|
-
this.unit = unit;
|
|
635
|
-
}
|
|
636
|
-
get typeId() {
|
|
637
|
-
return Type.Interval;
|
|
638
|
-
}
|
|
639
|
-
get [Symbol.toStringTag]() {
|
|
640
|
-
return "Interval";
|
|
641
|
-
}
|
|
642
|
-
toString() {
|
|
643
|
-
return `Interval<${IntervalUnit[this.unit]}>`;
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
var FixedSizeList = class extends DataType {
|
|
647
|
-
constructor(listSize, child) {
|
|
648
|
-
super();
|
|
649
|
-
this.listSize = listSize;
|
|
650
|
-
this.children = [child];
|
|
651
|
-
}
|
|
652
|
-
get typeId() {
|
|
653
|
-
return Type.FixedSizeList;
|
|
654
|
-
}
|
|
655
|
-
get valueType() {
|
|
656
|
-
return this.children[0].type;
|
|
657
|
-
}
|
|
658
|
-
get valueField() {
|
|
659
|
-
return this.children[0];
|
|
660
|
-
}
|
|
661
|
-
get [Symbol.toStringTag]() {
|
|
662
|
-
return "FixedSizeList";
|
|
663
|
-
}
|
|
664
|
-
toString() {
|
|
665
|
-
return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
|
|
666
|
-
}
|
|
667
|
-
};
|
|
668
|
-
var Struct = class extends DataType {
|
|
669
|
-
constructor(children) {
|
|
670
|
-
super();
|
|
671
|
-
this.children = children;
|
|
672
|
-
}
|
|
673
|
-
get typeId() {
|
|
674
|
-
return Type.Struct;
|
|
675
|
-
}
|
|
676
|
-
toString() {
|
|
677
|
-
return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
|
|
678
|
-
}
|
|
679
|
-
get [Symbol.toStringTag]() {
|
|
680
|
-
return "Struct";
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
// ../schema/src/lib/arrow/arrow-like-type-utils.ts
|
|
685
|
-
function getArrowTypeFromTypedArray(array) {
|
|
686
|
-
switch (array.constructor) {
|
|
687
|
-
case Int8Array:
|
|
688
|
-
return new Int8();
|
|
689
|
-
case Uint8Array:
|
|
690
|
-
return new Uint8();
|
|
691
|
-
case Int16Array:
|
|
692
|
-
return new Int16();
|
|
693
|
-
case Uint16Array:
|
|
694
|
-
return new Uint16();
|
|
695
|
-
case Int32Array:
|
|
696
|
-
return new Int32();
|
|
697
|
-
case Uint32Array:
|
|
698
|
-
return new Uint32();
|
|
699
|
-
case Float32Array:
|
|
700
|
-
return new Float32();
|
|
701
|
-
case Float64Array:
|
|
702
|
-
return new Float64();
|
|
703
|
-
default:
|
|
704
|
-
throw new Error("array type not supported");
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// ../schema/src/category/mesh/deduce-mesh-schema.ts
|
|
709
|
-
function deduceMeshSchema(attributes, metadata) {
|
|
294
|
+
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
295
|
+
function deduceMeshSchema(attributes, metadata = {}) {
|
|
710
296
|
const fields = deduceMeshFields(attributes);
|
|
711
|
-
return
|
|
297
|
+
return { fields, metadata };
|
|
712
298
|
}
|
|
713
|
-
function deduceMeshField(
|
|
714
|
-
const type =
|
|
299
|
+
function deduceMeshField(name, attribute, optionalMetadata) {
|
|
300
|
+
const type = getDataTypeFromTypedArray(attribute.value);
|
|
715
301
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
716
|
-
|
|
717
|
-
|
|
302
|
+
return {
|
|
303
|
+
name,
|
|
304
|
+
type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] },
|
|
305
|
+
nullable: false,
|
|
306
|
+
metadata
|
|
307
|
+
};
|
|
718
308
|
}
|
|
719
309
|
function deduceMeshFields(attributes) {
|
|
720
310
|
const fields = [];
|
|
@@ -725,39 +315,39 @@
|
|
|
725
315
|
return fields;
|
|
726
316
|
}
|
|
727
317
|
function makeMeshAttributeMetadata(attribute) {
|
|
728
|
-
const result =
|
|
318
|
+
const result = {};
|
|
729
319
|
if ("byteOffset" in attribute) {
|
|
730
|
-
result.
|
|
320
|
+
result.byteOffset = attribute.byteOffset.toString(10);
|
|
731
321
|
}
|
|
732
322
|
if ("byteStride" in attribute) {
|
|
733
|
-
result.
|
|
323
|
+
result.byteStride = attribute.byteStride.toString(10);
|
|
734
324
|
}
|
|
735
325
|
if ("normalized" in attribute) {
|
|
736
|
-
result.
|
|
326
|
+
result.normalized = attribute.normalized.toString();
|
|
737
327
|
}
|
|
738
328
|
return result;
|
|
739
329
|
}
|
|
740
330
|
|
|
741
331
|
// src/lib/get-ply-schema.ts
|
|
742
332
|
function getPLYSchema(plyHeader, attributes) {
|
|
743
|
-
const
|
|
744
|
-
const schema = deduceMeshSchema(attributes,
|
|
333
|
+
const metadata = makeMetadataFromPlyHeader(plyHeader);
|
|
334
|
+
const schema = deduceMeshSchema(attributes, metadata);
|
|
745
335
|
return schema;
|
|
746
336
|
}
|
|
747
337
|
function makeMetadataFromPlyHeader(plyHeader) {
|
|
748
|
-
const
|
|
749
|
-
|
|
750
|
-
|
|
338
|
+
const metadata = {};
|
|
339
|
+
metadata.ply_comments = JSON.stringify(plyHeader.comments);
|
|
340
|
+
metadata.ply_elements = JSON.stringify(plyHeader.elements);
|
|
751
341
|
if (plyHeader.format !== void 0) {
|
|
752
|
-
|
|
342
|
+
metadata.ply_format = plyHeader.format;
|
|
753
343
|
}
|
|
754
344
|
if (plyHeader.version !== void 0) {
|
|
755
|
-
|
|
345
|
+
metadata.ply_version = plyHeader.version;
|
|
756
346
|
}
|
|
757
347
|
if (plyHeader.headerLength !== void 0) {
|
|
758
|
-
|
|
348
|
+
metadata.ply_headerLength = plyHeader.headerLength.toString(10);
|
|
759
349
|
}
|
|
760
|
-
return
|
|
350
|
+
return metadata;
|
|
761
351
|
}
|
|
762
352
|
|
|
763
353
|
// src/lib/normalize-ply.ts
|
|
@@ -789,15 +379,36 @@
|
|
|
789
379
|
}
|
|
790
380
|
function getMeshAttributes(attributes) {
|
|
791
381
|
const accessors = {};
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
382
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
383
|
+
switch (attributeName) {
|
|
384
|
+
case "vertices":
|
|
385
|
+
if (attributes.vertices.length > 0) {
|
|
386
|
+
accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };
|
|
387
|
+
}
|
|
388
|
+
break;
|
|
389
|
+
case "normals":
|
|
390
|
+
if (attributes.normals.length > 0) {
|
|
391
|
+
accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
case "uvs":
|
|
395
|
+
if (attributes.uvs.length > 0) {
|
|
396
|
+
accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };
|
|
397
|
+
}
|
|
398
|
+
break;
|
|
399
|
+
case "colors":
|
|
400
|
+
if (attributes.colors.length > 0) {
|
|
401
|
+
accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
case "indices":
|
|
405
|
+
break;
|
|
406
|
+
default:
|
|
407
|
+
if (attributes[attributeName].length > 0) {
|
|
408
|
+
accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
801
412
|
}
|
|
802
413
|
return accessors;
|
|
803
414
|
}
|
|
@@ -866,35 +477,72 @@
|
|
|
866
477
|
};
|
|
867
478
|
break;
|
|
868
479
|
case "property":
|
|
869
|
-
if (
|
|
870
|
-
|
|
480
|
+
if (currentElement2) {
|
|
481
|
+
const property = makePLYElementProperty(lineValues);
|
|
482
|
+
if (options?.propertyNameMapping && property.name in options?.propertyNameMapping) {
|
|
483
|
+
property.name = options?.propertyNameMapping[property.name];
|
|
484
|
+
}
|
|
485
|
+
currentElement2.properties.push(property);
|
|
871
486
|
}
|
|
872
|
-
currentElement2.properties.push(makePLYElementProperty(lineValues, options.propertyNameMapping));
|
|
873
487
|
break;
|
|
874
488
|
default:
|
|
875
489
|
console.log("unhandled", lineType, lineValues);
|
|
876
490
|
}
|
|
877
491
|
}
|
|
878
|
-
if (currentElement2
|
|
492
|
+
if (currentElement2) {
|
|
879
493
|
header.elements.push(currentElement2);
|
|
880
494
|
}
|
|
881
495
|
return header;
|
|
882
496
|
}
|
|
883
|
-
function
|
|
884
|
-
const
|
|
885
|
-
|
|
497
|
+
function getPLYAttributes(header) {
|
|
498
|
+
const attributes = {
|
|
499
|
+
indices: [],
|
|
500
|
+
vertices: [],
|
|
501
|
+
normals: [],
|
|
502
|
+
uvs: [],
|
|
503
|
+
colors: []
|
|
886
504
|
};
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
505
|
+
for (const element of header.elements) {
|
|
506
|
+
if (element.name === "vertex") {
|
|
507
|
+
for (const property of element.properties) {
|
|
508
|
+
switch (property.name) {
|
|
509
|
+
case "x":
|
|
510
|
+
case "y":
|
|
511
|
+
case "z":
|
|
512
|
+
case "nx":
|
|
513
|
+
case "ny":
|
|
514
|
+
case "nz":
|
|
515
|
+
case "s":
|
|
516
|
+
case "t":
|
|
517
|
+
case "red":
|
|
518
|
+
case "green":
|
|
519
|
+
case "blue":
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
attributes[property.name] = [];
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
893
527
|
}
|
|
894
|
-
|
|
895
|
-
|
|
528
|
+
return attributes;
|
|
529
|
+
}
|
|
530
|
+
function makePLYElementProperty(propertyValues) {
|
|
531
|
+
const type = propertyValues[0];
|
|
532
|
+
switch (type) {
|
|
533
|
+
case "list":
|
|
534
|
+
return {
|
|
535
|
+
type,
|
|
536
|
+
name: propertyValues[3],
|
|
537
|
+
countType: propertyValues[1],
|
|
538
|
+
itemType: propertyValues[2]
|
|
539
|
+
};
|
|
540
|
+
default:
|
|
541
|
+
return {
|
|
542
|
+
type,
|
|
543
|
+
name: propertyValues[1]
|
|
544
|
+
};
|
|
896
545
|
}
|
|
897
|
-
return property;
|
|
898
546
|
}
|
|
899
547
|
function parseASCIINumber(n, type) {
|
|
900
548
|
switch (type) {
|
|
@@ -920,7 +568,7 @@
|
|
|
920
568
|
throw new Error(type);
|
|
921
569
|
}
|
|
922
570
|
}
|
|
923
|
-
function
|
|
571
|
+
function parsePLYElement(properties, line) {
|
|
924
572
|
const values = line.split(/\s+/);
|
|
925
573
|
const element = {};
|
|
926
574
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -938,13 +586,7 @@
|
|
|
938
586
|
return element;
|
|
939
587
|
}
|
|
940
588
|
function parseASCII(data, header) {
|
|
941
|
-
const attributes =
|
|
942
|
-
indices: [],
|
|
943
|
-
vertices: [],
|
|
944
|
-
normals: [],
|
|
945
|
-
uvs: [],
|
|
946
|
-
colors: []
|
|
947
|
-
};
|
|
589
|
+
const attributes = getPLYAttributes(header);
|
|
948
590
|
let result;
|
|
949
591
|
const patternBody = /end_header\s([\s\S]*)$/;
|
|
950
592
|
let body = "";
|
|
@@ -962,7 +604,7 @@
|
|
|
962
604
|
currentElement2++;
|
|
963
605
|
currentElementCount = 0;
|
|
964
606
|
}
|
|
965
|
-
const element =
|
|
607
|
+
const element = parsePLYElement(header.elements[currentElement2].properties, line);
|
|
966
608
|
handleElement(attributes, header.elements[currentElement2].name, element);
|
|
967
609
|
currentElementCount++;
|
|
968
610
|
}
|
|
@@ -971,15 +613,40 @@
|
|
|
971
613
|
}
|
|
972
614
|
function handleElement(buffer, elementName, element = {}) {
|
|
973
615
|
if (elementName === "vertex") {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
616
|
+
for (const propertyName of Object.keys(element)) {
|
|
617
|
+
switch (propertyName) {
|
|
618
|
+
case "x":
|
|
619
|
+
buffer.vertices.push(element.x, element.y, element.z);
|
|
620
|
+
break;
|
|
621
|
+
case "y":
|
|
622
|
+
case "z":
|
|
623
|
+
break;
|
|
624
|
+
case "nx":
|
|
625
|
+
if ("nx" in element && "ny" in element && "nz" in element) {
|
|
626
|
+
buffer.normals.push(element.nx, element.ny, element.nz);
|
|
627
|
+
}
|
|
628
|
+
break;
|
|
629
|
+
case "ny":
|
|
630
|
+
case "nz":
|
|
631
|
+
break;
|
|
632
|
+
case "s":
|
|
633
|
+
if ("s" in element && "t" in element) {
|
|
634
|
+
buffer.uvs.push(element.s, element.t);
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
case "t":
|
|
638
|
+
break;
|
|
639
|
+
case "red":
|
|
640
|
+
if ("red" in element && "green" in element && "blue" in element) {
|
|
641
|
+
buffer.colors.push(element.red, element.green, element.blue);
|
|
642
|
+
}
|
|
643
|
+
break;
|
|
644
|
+
case "green":
|
|
645
|
+
case "blue":
|
|
646
|
+
break;
|
|
647
|
+
default:
|
|
648
|
+
buffer[propertyName].push(element[propertyName]);
|
|
649
|
+
}
|
|
983
650
|
}
|
|
984
651
|
} else if (elementName === "face") {
|
|
985
652
|
const vertexIndices = element.vertex_indices || element.vertex_index;
|
|
@@ -1046,13 +713,7 @@
|
|
|
1046
713
|
return [element, read];
|
|
1047
714
|
}
|
|
1048
715
|
function parseBinary(data, header) {
|
|
1049
|
-
const attributes =
|
|
1050
|
-
indices: [],
|
|
1051
|
-
vertices: [],
|
|
1052
|
-
normals: [],
|
|
1053
|
-
uvs: [],
|
|
1054
|
-
colors: []
|
|
1055
|
-
};
|
|
716
|
+
const attributes = getPLYAttributes(header);
|
|
1056
717
|
const littleEndian = header.format === "binary_little_endian";
|
|
1057
718
|
const body = new DataView(data, header.headerLength);
|
|
1058
719
|
let result;
|
|
@@ -1134,21 +795,22 @@
|
|
|
1134
795
|
}
|
|
1135
796
|
return header;
|
|
1136
797
|
}
|
|
1137
|
-
function makePLYElementProperty2(
|
|
1138
|
-
const
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
798
|
+
function makePLYElementProperty2(propertyValues, propertyNameMapping) {
|
|
799
|
+
const type = propertyValues[0];
|
|
800
|
+
switch (type) {
|
|
801
|
+
case "list":
|
|
802
|
+
return {
|
|
803
|
+
type,
|
|
804
|
+
name: propertyValues[3],
|
|
805
|
+
countType: propertyValues[1],
|
|
806
|
+
itemType: propertyValues[2]
|
|
807
|
+
};
|
|
808
|
+
default:
|
|
809
|
+
return {
|
|
810
|
+
type,
|
|
811
|
+
name: propertyValues[1]
|
|
812
|
+
};
|
|
1150
813
|
}
|
|
1151
|
-
return property;
|
|
1152
814
|
}
|
|
1153
815
|
async function parseASCII2(lineIterator, header) {
|
|
1154
816
|
const attributes = {
|
|
@@ -1167,7 +829,7 @@
|
|
|
1167
829
|
currentElement2++;
|
|
1168
830
|
currentElementCount = 0;
|
|
1169
831
|
}
|
|
1170
|
-
const element =
|
|
832
|
+
const element = parsePLYElement2(header.elements[currentElement2].properties, line);
|
|
1171
833
|
handleElement2(attributes, header.elements[currentElement2].name, element);
|
|
1172
834
|
currentElementCount++;
|
|
1173
835
|
}
|
|
@@ -1198,7 +860,7 @@
|
|
|
1198
860
|
throw new Error(type);
|
|
1199
861
|
}
|
|
1200
862
|
}
|
|
1201
|
-
function
|
|
863
|
+
function parsePLYElement2(properties, line) {
|
|
1202
864
|
const values = line.split(/\s+/);
|
|
1203
865
|
const element = {};
|
|
1204
866
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -1246,10 +908,10 @@
|
|
|
1246
908
|
// src/index.ts
|
|
1247
909
|
var PLYLoader2 = {
|
|
1248
910
|
...PLYLoader,
|
|
1249
|
-
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options),
|
|
1250
|
-
parseTextSync: parsePLY,
|
|
1251
|
-
parseSync: parsePLY,
|
|
1252
|
-
parseInBatches: parsePLYInBatches
|
|
911
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
912
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
913
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
914
|
+
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
1253
915
|
};
|
|
1254
916
|
|
|
1255
917
|
// src/workers/ply-worker.ts
|