@loaders.gl/pointclouds 5.0.0-beta.1 → 5.0.0-beta.2
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/README.md +4 -0
- package/dist/dist.dev.js +39 -15
- package/dist/dist.min.js +19 -19
- package/dist/las/las-copc-loader-types.cjs +1 -1
- package/dist/las/las-copc-loader-types.cjs.map +2 -2
- package/dist/las/las-copc-loader-types.js +1 -1
- package/dist/las/las-copc-loader-types.js.map +1 -1
- package/dist/las/las-loader-shared.cjs +1 -1
- package/dist/las/las-loader-shared.js +1 -1
- package/dist/las/las-loader-types.cjs +1 -1
- package/dist/las/las-loader-types.cjs.map +2 -2
- package/dist/las/las-loader-types.js +1 -1
- package/dist/las/las-loader-types.js.map +1 -1
- package/dist/las/las-writer.cjs +1 -1
- package/dist/las/las-writer.js +1 -1
- package/dist/las/laz-rs-loader-types.cjs +1 -1
- package/dist/las/laz-rs-loader-types.cjs.map +2 -2
- package/dist/las/laz-rs-loader-types.js +1 -1
- package/dist/las/laz-rs-loader-types.js.map +1 -1
- package/dist/las/lazperf-loader-types.cjs +1 -1
- package/dist/las/lazperf-loader-types.cjs.map +2 -2
- package/dist/las/lazperf-loader-types.js +1 -1
- package/dist/las/lazperf-loader-types.js.map +1 -1
- package/dist/las-copc-loader-types.cjs +51 -0
- package/dist/las-copc-loader-types.cjs.map +7 -0
- package/dist/las-copc-loader-types.d.ts +2 -0
- package/dist/las-copc-loader-types.d.ts.map +1 -0
- package/dist/las-copc-loader-types.js +2 -0
- package/dist/las-copc-loader-types.js.map +1 -0
- package/dist/las-copc-loader.cjs +59 -0
- package/dist/las-copc-loader.cjs.map +7 -0
- package/dist/las-copc-loader.d.ts +2 -0
- package/dist/las-copc-loader.d.ts.map +1 -0
- package/dist/las-copc-loader.js +2 -0
- package/dist/las-copc-loader.js.map +1 -0
- package/dist/las-loader-types.cjs +56 -0
- package/dist/las-loader-types.cjs.map +7 -0
- package/dist/las-loader-types.d.ts +2 -0
- package/dist/las-loader-types.d.ts.map +1 -0
- package/dist/las-loader-types.js +2 -0
- package/dist/las-loader-types.js.map +1 -0
- package/dist/las-loader.cjs +82 -0
- package/dist/las-loader.cjs.map +7 -0
- package/dist/las-loader.d.ts +2 -0
- package/dist/las-loader.d.ts.map +1 -0
- package/dist/las-loader.js +2 -0
- package/dist/las-loader.js.map +1 -0
- package/dist/las-worker.js +170 -59
- package/dist/las-writer.cjs +1056 -0
- package/dist/las-writer.cjs.map +7 -0
- package/dist/las-writer.d.ts +2 -0
- package/dist/las-writer.d.ts.map +1 -0
- package/dist/las-writer.js +2 -0
- package/dist/las-writer.js.map +1 -0
- package/dist/laz-rs-loader-types.cjs +51 -0
- package/dist/laz-rs-loader-types.cjs.map +7 -0
- package/dist/laz-rs-loader-types.d.ts +2 -0
- package/dist/laz-rs-loader-types.d.ts.map +1 -0
- package/dist/laz-rs-loader-types.js +2 -0
- package/dist/laz-rs-loader-types.js.map +1 -0
- package/dist/laz-rs-loader.cjs +274 -0
- package/dist/laz-rs-loader.cjs.map +7 -0
- package/dist/laz-rs-loader.d.ts +2 -0
- package/dist/laz-rs-loader.d.ts.map +1 -0
- package/dist/laz-rs-loader.js +2 -0
- package/dist/laz-rs-loader.js.map +1 -0
- package/dist/lazperf-loader-types.cjs +51 -0
- package/dist/lazperf-loader-types.cjs.map +7 -0
- package/dist/lazperf-loader-types.d.ts +2 -0
- package/dist/lazperf-loader-types.d.ts.map +1 -0
- package/dist/lazperf-loader-types.js +2 -0
- package/dist/lazperf-loader-types.js.map +1 -0
- package/dist/lazperf-loader.cjs +62 -0
- package/dist/lazperf-loader.cjs.map +7 -0
- package/dist/lazperf-loader.d.ts +2 -0
- package/dist/lazperf-loader.d.ts.map +1 -0
- package/dist/lazperf-loader.js +2 -0
- package/dist/lazperf-loader.js.map +1 -0
- package/dist/pcd/pcd-loader-types.cjs +2 -2
- package/dist/pcd/pcd-loader-types.cjs.map +2 -2
- package/dist/pcd/pcd-loader-types.js +2 -2
- package/dist/pcd/pcd-loader-types.js.map +1 -1
- package/dist/pcd/pcd-writer.cjs +1 -1
- package/dist/pcd/pcd-writer.js +1 -1
- package/dist/pcd-loader-types.cjs +66 -0
- package/dist/pcd-loader-types.cjs.map +7 -0
- package/dist/pcd-loader-types.d.ts +2 -0
- package/dist/pcd-loader-types.d.ts.map +1 -0
- package/dist/pcd-loader-types.js +2 -0
- package/dist/pcd-loader-types.js.map +1 -0
- package/dist/pcd-loader.cjs +146 -0
- package/dist/pcd-loader.cjs.map +7 -0
- package/dist/pcd-loader.d.ts +2 -0
- package/dist/pcd-loader.d.ts.map +1 -0
- package/dist/pcd-loader.js +2 -0
- package/dist/pcd-loader.js.map +1 -0
- package/dist/pcd-worker.js +204 -71
- package/dist/pcd-writer.cjs +136 -0
- package/dist/pcd-writer.cjs.map +7 -0
- package/dist/pcd-writer.d.ts +2 -0
- package/dist/pcd-writer.d.ts.map +1 -0
- package/dist/pcd-writer.js +2 -0
- package/dist/pcd-writer.js.map +1 -0
- package/dist/ply/ply-loader-types.cjs +2 -2
- package/dist/ply/ply-loader-types.cjs.map +2 -2
- package/dist/ply/ply-loader-types.js +2 -2
- package/dist/ply/ply-loader-types.js.map +1 -1
- package/dist/ply/ply-writer.cjs +1 -1
- package/dist/ply/ply-writer.js +1 -1
- package/dist/ply-loader-types.cjs +67 -0
- package/dist/ply-loader-types.cjs.map +7 -0
- package/dist/ply-loader-types.d.ts +2 -0
- package/dist/ply-loader-types.d.ts.map +1 -0
- package/dist/ply-loader-types.js +2 -0
- package/dist/ply-loader-types.js.map +1 -0
- package/dist/ply-loader.cjs +136 -0
- package/dist/ply-loader.cjs.map +7 -0
- package/dist/ply-loader.d.ts +2 -0
- package/dist/ply-loader.d.ts.map +1 -0
- package/dist/ply-loader.js +2 -0
- package/dist/ply-loader.js.map +1 -0
- package/dist/ply-worker.js +204 -71
- package/dist/ply-writer.cjs +177 -0
- package/dist/ply-writer.cjs.map +7 -0
- package/dist/ply-writer.d.ts +2 -0
- package/dist/ply-writer.d.ts.map +1 -0
- package/dist/ply-writer.js +2 -0
- package/dist/ply-writer.js.map +1 -0
- package/package.json +73 -70
- package/src/las/las-copc-loader-types.ts +1 -1
- package/src/las/las-loader-types.ts +1 -1
- package/src/las/laz-rs-loader-types.ts +1 -1
- package/src/las/lazperf-loader-types.ts +1 -1
- package/src/las/libs/laz-rs-wasm/README.md +5 -0
- package/src/las/libs/laz-rs-wasm/package.json +6 -0
- package/src/las-copc-loader-types.ts +1 -0
- package/src/las-copc-loader.ts +1 -0
- package/src/las-loader-types.ts +1 -0
- package/src/las-loader.ts +1 -0
- package/src/las-writer.ts +1 -0
- package/src/laz-rs-loader-types.ts +1 -0
- package/src/laz-rs-loader.ts +1 -0
- package/src/lazperf-loader-types.ts +1 -0
- package/src/lazperf-loader.ts +1 -0
- package/src/pcd/pcd-loader-types.ts +1 -1
- package/src/pcd-loader-types.ts +1 -0
- package/src/pcd-loader.ts +1 -0
- package/src/pcd-writer.ts +1 -0
- package/src/ply/ply-loader-types.ts +1 -1
- package/src/ply-loader-types.ts +1 -0
- package/src/ply-loader.ts +1 -0
- package/src/ply-writer.ts +1 -0
package/dist/ply-worker.js
CHANGED
|
@@ -15,29 +15,41 @@
|
|
|
15
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js
|
|
19
19
|
var parentPort;
|
|
20
20
|
var init_worker_threads_browser = __esm({
|
|
21
|
-
"
|
|
22
|
-
"use strict";
|
|
21
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/node/worker_threads-browser.js"() {
|
|
23
22
|
parentPort = null;
|
|
24
23
|
}
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
//
|
|
26
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js
|
|
28
27
|
function getTransferList(object, recursive = true, transfers) {
|
|
29
28
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30
|
+
function visit(value) {
|
|
31
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
32
|
+
return;
|
|
33
|
+
seen.add(value);
|
|
34
|
+
if (isTransferable(value))
|
|
35
|
+
transfersSet.add(value);
|
|
36
|
+
else if (ArrayBuffer.isView(value)) {
|
|
37
|
+
if (isTransferable(value.buffer))
|
|
38
|
+
transfersSet.add(value.buffer);
|
|
39
|
+
} else if (recursive && value instanceof Map) {
|
|
40
|
+
for (const [key, item] of value) {
|
|
41
|
+
visit(key);
|
|
42
|
+
visit(item);
|
|
43
|
+
}
|
|
44
|
+
} else if (recursive && value instanceof Set) {
|
|
45
|
+
for (const item of value)
|
|
46
|
+
visit(item);
|
|
47
|
+
} else if (recursive) {
|
|
48
|
+
for (const key of Object.keys(value))
|
|
49
|
+
visit(value[key]);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
52
|
+
visit(object);
|
|
41
53
|
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
42
54
|
}
|
|
43
55
|
function isTransferable(object) {
|
|
@@ -59,12 +71,11 @@
|
|
|
59
71
|
return false;
|
|
60
72
|
}
|
|
61
73
|
var init_get_transfer_list = __esm({
|
|
62
|
-
"
|
|
63
|
-
"use strict";
|
|
74
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-utils/get-transfer-list.js"() {
|
|
64
75
|
}
|
|
65
76
|
});
|
|
66
77
|
|
|
67
|
-
//
|
|
78
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js
|
|
68
79
|
async function getParentPort() {
|
|
69
80
|
return parentPort;
|
|
70
81
|
}
|
|
@@ -77,15 +88,15 @@
|
|
|
77
88
|
}
|
|
78
89
|
var onMessageWrapperMap, WorkerBody;
|
|
79
90
|
var init_worker_body = __esm({
|
|
80
|
-
"
|
|
81
|
-
"use strict";
|
|
91
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-farm/worker-body.js"() {
|
|
82
92
|
init_get_transfer_list();
|
|
83
93
|
init_worker_threads_browser();
|
|
84
94
|
onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
85
95
|
WorkerBody = class {
|
|
86
96
|
/** Check that we are actually in a worker thread */
|
|
87
97
|
static async inWorkerThread() {
|
|
88
|
-
|
|
98
|
+
const workerGlobalScope = globalThis.WorkerGlobalScope;
|
|
99
|
+
return typeof workerGlobalScope === "function" && globalThis instanceof workerGlobalScope || Boolean(await getParentPort());
|
|
89
100
|
}
|
|
90
101
|
/*
|
|
91
102
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
@@ -158,15 +169,11 @@
|
|
|
158
169
|
}
|
|
159
170
|
});
|
|
160
171
|
|
|
161
|
-
//
|
|
172
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js
|
|
162
173
|
var AsyncQueue;
|
|
163
174
|
var init_async_queue = __esm({
|
|
164
|
-
"
|
|
165
|
-
"use strict";
|
|
175
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/async-queue/async-queue.js"() {
|
|
166
176
|
AsyncQueue = class {
|
|
167
|
-
_values;
|
|
168
|
-
_settlers;
|
|
169
|
-
_closed;
|
|
170
177
|
constructor() {
|
|
171
178
|
this._values = [];
|
|
172
179
|
this._settlers = [];
|
|
@@ -234,7 +241,51 @@
|
|
|
234
241
|
}
|
|
235
242
|
});
|
|
236
243
|
|
|
237
|
-
//
|
|
244
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js
|
|
245
|
+
var SharedWorkerState;
|
|
246
|
+
var init_shared_state = __esm({
|
|
247
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/shared-state.js"() {
|
|
248
|
+
SharedWorkerState = class {
|
|
249
|
+
constructor(buffer) {
|
|
250
|
+
if (typeof SharedArrayBuffer === "undefined" || !(buffer instanceof SharedArrayBuffer) || buffer.byteLength !== 16)
|
|
251
|
+
throw new Error("Expected a 16-byte shared worker control buffer");
|
|
252
|
+
this.buffer = buffer;
|
|
253
|
+
this.values = new Int32Array(buffer);
|
|
254
|
+
}
|
|
255
|
+
get snapshot() {
|
|
256
|
+
return {
|
|
257
|
+
cancelled: Atomics.load(this.values, 0) !== 0,
|
|
258
|
+
completed: Atomics.load(this.values, 1),
|
|
259
|
+
total: Atomics.load(this.values, 2),
|
|
260
|
+
revision: Atomics.load(this.values, 3)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
cancel() {
|
|
264
|
+
Atomics.store(this.values, 0, 1);
|
|
265
|
+
Atomics.add(this.values, 3, 1);
|
|
266
|
+
Atomics.notify(this.values, 0);
|
|
267
|
+
}
|
|
268
|
+
throwIfCancelled() {
|
|
269
|
+
if (Atomics.load(this.values, 0) !== 0) {
|
|
270
|
+
const error = new Error("Shared worker task was cancelled");
|
|
271
|
+
error.name = "AbortError";
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/** Integer counters for application-defined work; messages still carry phase names and units. */
|
|
276
|
+
setProgress(completed, total = -1) {
|
|
277
|
+
if (!Number.isInteger(completed) || completed < 0 || completed > 2147483647 || !Number.isInteger(total) || total < -1 || total > 2147483647) {
|
|
278
|
+
throw new RangeError("Shared progress requires nonnegative int32 counts (or total -1)");
|
|
279
|
+
}
|
|
280
|
+
Atomics.store(this.values, 1, completed);
|
|
281
|
+
Atomics.store(this.values, 2, total);
|
|
282
|
+
Atomics.add(this.values, 3, 1);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js
|
|
238
289
|
async function createWorker(process, processInBatches) {
|
|
239
290
|
if (!await WorkerBody.inWorkerThread()) {
|
|
240
291
|
return;
|
|
@@ -243,27 +294,56 @@
|
|
|
243
294
|
process: processOnMainThread
|
|
244
295
|
};
|
|
245
296
|
WorkerBody.onmessage = async (type, payload) => {
|
|
297
|
+
if (type === "cancel") {
|
|
298
|
+
activeController?.abort();
|
|
299
|
+
activeInputBatches?.close();
|
|
300
|
+
activeOutputAcknowledgements?.close();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const controller = type === "process" || type === "process-in-batches" ? new AbortController() : void 0;
|
|
304
|
+
if (controller)
|
|
305
|
+
activeController = controller;
|
|
306
|
+
const startedAt = performance.now();
|
|
246
307
|
const reporter = type === "process" || type === "process-in-batches" ? createProgressReporter() : void 0;
|
|
247
|
-
|
|
308
|
+
let sharedState;
|
|
309
|
+
const throwIfAborted = () => {
|
|
310
|
+
controller?.signal.throwIfAborted();
|
|
311
|
+
sharedState?.throwIfCancelled();
|
|
312
|
+
};
|
|
313
|
+
const jobContext = {
|
|
314
|
+
...context,
|
|
315
|
+
signal: controller?.signal,
|
|
316
|
+
sharedState,
|
|
317
|
+
throwIfAborted,
|
|
318
|
+
reportProgress: (progress) => {
|
|
319
|
+
if (!controller?.signal.aborted && !sharedState?.snapshot.cancelled)
|
|
320
|
+
reporter?.report(progress);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
248
323
|
try {
|
|
324
|
+
if (controller && payload.options?.["sharedState"]) {
|
|
325
|
+
sharedState = new SharedWorkerState(payload.options["sharedState"]);
|
|
326
|
+
jobContext.sharedState = sharedState;
|
|
327
|
+
}
|
|
249
328
|
switch (type) {
|
|
250
329
|
case "preload":
|
|
251
330
|
WorkerBody.postMessage("done", {});
|
|
252
331
|
break;
|
|
253
332
|
case "process":
|
|
333
|
+
throwIfAborted();
|
|
254
334
|
if (!process) {
|
|
255
335
|
throw new Error("Worker does not support atomic processing");
|
|
256
336
|
}
|
|
257
|
-
const result = await process(
|
|
258
|
-
|
|
259
|
-
payload.options || {},
|
|
260
|
-
jobContext,
|
|
261
|
-
payload.context || {}
|
|
262
|
-
);
|
|
337
|
+
const result = await process(payload.input, payload.options || {}, jobContext, payload.context || {});
|
|
338
|
+
throwIfAborted();
|
|
263
339
|
reporter?.finish();
|
|
264
|
-
WorkerBody.postMessage("done", {
|
|
340
|
+
await WorkerBody.postMessage("done", {
|
|
341
|
+
result,
|
|
342
|
+
executionMs: performance.now() - startedAt
|
|
343
|
+
});
|
|
265
344
|
break;
|
|
266
345
|
case "process-in-batches":
|
|
346
|
+
throwIfAborted();
|
|
267
347
|
if (!processInBatches) {
|
|
268
348
|
throw new Error("Worker does not support batched processing");
|
|
269
349
|
}
|
|
@@ -272,18 +352,15 @@
|
|
|
272
352
|
activeInputBatches = inputBatches;
|
|
273
353
|
activeOutputAcknowledgements = outputAcknowledgements;
|
|
274
354
|
try {
|
|
275
|
-
const resultIterator = processInBatches(
|
|
276
|
-
createDemandDrivenIterator(inputBatches),
|
|
277
|
-
payload.options || {},
|
|
278
|
-
jobContext,
|
|
279
|
-
payload.context || {}
|
|
280
|
-
);
|
|
355
|
+
const resultIterator = processInBatches(createDemandDrivenIterator(inputBatches), payload.options || {}, jobContext, payload.context || {});
|
|
281
356
|
for await (const batch of resultIterator) {
|
|
357
|
+
throwIfAborted();
|
|
282
358
|
await WorkerBody.postMessage("output-batch", { result: batch });
|
|
283
359
|
await outputAcknowledgements.next();
|
|
284
360
|
}
|
|
361
|
+
throwIfAborted();
|
|
285
362
|
reporter?.finish();
|
|
286
|
-
await WorkerBody.postMessage("done", {});
|
|
363
|
+
await WorkerBody.postMessage("done", { executionMs: performance.now() - startedAt });
|
|
287
364
|
} finally {
|
|
288
365
|
activeInputBatches = null;
|
|
289
366
|
activeOutputAcknowledgements = null;
|
|
@@ -310,11 +387,18 @@
|
|
|
310
387
|
default:
|
|
311
388
|
}
|
|
312
389
|
} catch (error) {
|
|
313
|
-
reporter?.finish();
|
|
390
|
+
reporter?.finish(controller?.signal.aborted || sharedState?.snapshot.cancelled);
|
|
314
391
|
const message = error instanceof Error ? error.message : "";
|
|
315
|
-
WorkerBody.postMessage("error", {
|
|
392
|
+
await WorkerBody.postMessage("error", {
|
|
393
|
+
error: message,
|
|
394
|
+
errorName: error instanceof Error ? error.name : "Error"
|
|
395
|
+
});
|
|
396
|
+
} finally {
|
|
397
|
+
if (controller && activeController === controller)
|
|
398
|
+
activeController = null;
|
|
316
399
|
}
|
|
317
400
|
};
|
|
401
|
+
await WorkerBody.postMessage("ready", {});
|
|
318
402
|
}
|
|
319
403
|
async function* createDemandDrivenIterator(inputBatches) {
|
|
320
404
|
while (true) {
|
|
@@ -327,27 +411,45 @@
|
|
|
327
411
|
}
|
|
328
412
|
}
|
|
329
413
|
function processOnMainThread(arrayBuffer, options = {}, jobContext = {}) {
|
|
414
|
+
const signal = activeController?.signal;
|
|
415
|
+
signal?.throwIfAborted();
|
|
330
416
|
return new Promise((resolve, reject) => {
|
|
331
417
|
const id = requestId++;
|
|
332
|
-
const
|
|
333
|
-
|
|
418
|
+
const cleanup = () => {
|
|
419
|
+
signal?.removeEventListener("abort", abort);
|
|
420
|
+
void WorkerBody.removeEventListener(onMessage);
|
|
421
|
+
};
|
|
422
|
+
const abort = () => {
|
|
423
|
+
cleanup();
|
|
424
|
+
reject(signal?.reason);
|
|
425
|
+
};
|
|
426
|
+
const onMessage = (type, payload) => {
|
|
427
|
+
if (payload.id !== id)
|
|
334
428
|
return;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
case "error":
|
|
342
|
-
WorkerBody.removeEventListener(onMessage);
|
|
343
|
-
reject(payload2.error);
|
|
344
|
-
break;
|
|
345
|
-
default:
|
|
429
|
+
if (type === "done") {
|
|
430
|
+
cleanup();
|
|
431
|
+
resolve(payload.result);
|
|
432
|
+
} else if (type === "error") {
|
|
433
|
+
cleanup();
|
|
434
|
+
reject(payload.error);
|
|
346
435
|
}
|
|
347
436
|
};
|
|
348
|
-
WorkerBody.addEventListener(onMessage)
|
|
349
|
-
|
|
350
|
-
|
|
437
|
+
void WorkerBody.addEventListener(onMessage).then(async () => {
|
|
438
|
+
if (signal?.aborted) {
|
|
439
|
+
abort();
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
signal?.addEventListener("abort", abort, { once: true });
|
|
443
|
+
await WorkerBody.postMessage("process", {
|
|
444
|
+
id,
|
|
445
|
+
input: arrayBuffer,
|
|
446
|
+
options,
|
|
447
|
+
context: jobContext
|
|
448
|
+
});
|
|
449
|
+
}).catch((error) => {
|
|
450
|
+
cleanup();
|
|
451
|
+
reject(error);
|
|
452
|
+
});
|
|
351
453
|
});
|
|
352
454
|
}
|
|
353
455
|
function createProgressReporter() {
|
|
@@ -364,8 +466,10 @@
|
|
|
364
466
|
return {
|
|
365
467
|
/** Records progress while retaining phase transitions. */
|
|
366
468
|
report(progress) {
|
|
367
|
-
if (finished)
|
|
368
|
-
|
|
469
|
+
if (finished)
|
|
470
|
+
return;
|
|
471
|
+
if (pending && pending.phase !== progress.phase)
|
|
472
|
+
flush();
|
|
369
473
|
pending = { ...progress };
|
|
370
474
|
if (!scheduled) {
|
|
371
475
|
scheduled = true;
|
|
@@ -373,29 +477,58 @@
|
|
|
373
477
|
}
|
|
374
478
|
},
|
|
375
479
|
/** Flushes final progress and suppresses reports from stale callbacks. */
|
|
376
|
-
finish() {
|
|
480
|
+
finish(discard = false) {
|
|
481
|
+
if (discard)
|
|
482
|
+
pending = void 0;
|
|
377
483
|
flush();
|
|
378
484
|
finished = true;
|
|
379
485
|
}
|
|
380
486
|
};
|
|
381
487
|
}
|
|
382
|
-
var requestId, activeInputBatches, activeOutputAcknowledgements;
|
|
488
|
+
var requestId, activeController, activeInputBatches, activeOutputAcknowledgements;
|
|
383
489
|
var init_create_worker = __esm({
|
|
384
|
-
"
|
|
385
|
-
|
|
490
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/lib/worker-api/create-worker.js"() {
|
|
491
|
+
init_shared_state();
|
|
386
492
|
init_async_queue();
|
|
387
493
|
init_worker_body();
|
|
388
494
|
requestId = 0;
|
|
495
|
+
activeController = null;
|
|
389
496
|
activeInputBatches = null;
|
|
390
497
|
activeOutputAcknowledgements = null;
|
|
391
498
|
}
|
|
392
499
|
});
|
|
393
500
|
|
|
394
|
-
//
|
|
501
|
+
// ../../node_modules/@math.gl/core/dist/worker-utils/index.js
|
|
502
|
+
var import_meta, path, moduleUrl;
|
|
395
503
|
var init_worker_utils = __esm({
|
|
504
|
+
"../../node_modules/@math.gl/core/dist/worker-utils/index.js"() {
|
|
505
|
+
init_create_worker();
|
|
506
|
+
import_meta = {};
|
|
507
|
+
path = typeof __filename === "string" ? __filename.replace(/\\/g, "/") : "";
|
|
508
|
+
moduleUrl = path ? `file://${path.startsWith("/") ? "" : "/"}${encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F")}` : import_meta.url;
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// ../../node_modules/@math.gl/core/dist/tasks/index.js
|
|
513
|
+
var init_tasks = __esm({
|
|
514
|
+
"../../node_modules/@math.gl/core/dist/tasks/index.js"() {
|
|
515
|
+
init_worker_utils();
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// ../core/src/worker-utils/lib/worker-api/create-worker.ts
|
|
520
|
+
var init_create_worker2 = __esm({
|
|
521
|
+
"../core/src/worker-utils/lib/worker-api/create-worker.ts"() {
|
|
522
|
+
"use strict";
|
|
523
|
+
init_tasks();
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// ../core/src/worker-utils/index.ts
|
|
528
|
+
var init_worker_utils2 = __esm({
|
|
396
529
|
"../core/src/worker-utils/index.ts"() {
|
|
397
530
|
"use strict";
|
|
398
|
-
|
|
531
|
+
init_create_worker2();
|
|
399
532
|
}
|
|
400
533
|
});
|
|
401
534
|
|
|
@@ -539,7 +672,7 @@
|
|
|
539
672
|
var init_create_loader_worker = __esm({
|
|
540
673
|
"../core/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts"() {
|
|
541
674
|
"use strict";
|
|
542
|
-
|
|
675
|
+
init_worker_utils2();
|
|
543
676
|
}
|
|
544
677
|
});
|
|
545
678
|
|
|
@@ -13529,8 +13662,8 @@ return true;`);
|
|
|
13529
13662
|
});
|
|
13530
13663
|
|
|
13531
13664
|
// ../../node_modules/apache-arrow/ipc/reader.mjs
|
|
13532
|
-
function shouldAutoDestroy(
|
|
13533
|
-
return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] :
|
|
13665
|
+
function shouldAutoDestroy(self, options) {
|
|
13666
|
+
return options && typeof options["autoDestroy"] === "boolean" ? options["autoDestroy"] : self["autoDestroy"];
|
|
13534
13667
|
}
|
|
13535
13668
|
function* readAllSync(source) {
|
|
13536
13669
|
const reader = RecordBatchReader.from(source);
|
|
@@ -19006,7 +19139,7 @@ return true;`);
|
|
|
19006
19139
|
"use strict";
|
|
19007
19140
|
init_ply_format();
|
|
19008
19141
|
init_arrow_transport();
|
|
19009
|
-
VERSION = true ? "5.0.0-beta.
|
|
19142
|
+
VERSION = true ? "5.0.0-beta.2" : "latest";
|
|
19010
19143
|
PLYLoader = {
|
|
19011
19144
|
dataType: null,
|
|
19012
19145
|
batchType: null,
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/ply-writer.ts
|
|
21
|
+
var ply_writer_exports = {};
|
|
22
|
+
__export(ply_writer_exports, {
|
|
23
|
+
PLYWriter: () => PLYWriter
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ply_writer_exports);
|
|
26
|
+
|
|
27
|
+
// src/ply/ply-writer.ts
|
|
28
|
+
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
29
|
+
var import_ply_format = require("./ply-format.cjs");
|
|
30
|
+
var VERSION = true ? "5.0.0-beta.2" : "latest";
|
|
31
|
+
var PLYWriter = {
|
|
32
|
+
...import_ply_format.PLYFormat,
|
|
33
|
+
dataType: null,
|
|
34
|
+
batchType: null,
|
|
35
|
+
version: VERSION,
|
|
36
|
+
options: {
|
|
37
|
+
ply: {}
|
|
38
|
+
},
|
|
39
|
+
text: true,
|
|
40
|
+
encode: async (data, options) => encodePLYSync(data, options),
|
|
41
|
+
encodeSync: encodePLYSync,
|
|
42
|
+
encodeTextSync: encodePLY
|
|
43
|
+
};
|
|
44
|
+
function encodePLYSync(data, options) {
|
|
45
|
+
const text = encodePLY(data, options);
|
|
46
|
+
return new TextEncoder().encode(text).buffer;
|
|
47
|
+
}
|
|
48
|
+
function encodePLY(data, options) {
|
|
49
|
+
const mesh = (0, import_schema_utils.convertTableToMesh)(normalizeMeshArrowTable(data));
|
|
50
|
+
const positionAttribute = getRequiredAttribute(mesh, "POSITION");
|
|
51
|
+
const normalAttribute = mesh.attributes.NORMAL;
|
|
52
|
+
const textureCoordinateAttribute = mesh.attributes.TEXCOORD_0;
|
|
53
|
+
const colorAttribute = mesh.attributes.COLOR_0;
|
|
54
|
+
const customScalarAttributes = getCustomScalarAttributes(mesh);
|
|
55
|
+
const vertexCount = positionAttribute.value.length / positionAttribute.size;
|
|
56
|
+
const triangleIndices = getTriangleIndices(mesh, vertexCount);
|
|
57
|
+
const header = getPLYHeader(
|
|
58
|
+
vertexCount,
|
|
59
|
+
triangleIndices.length / 3,
|
|
60
|
+
Boolean(normalAttribute),
|
|
61
|
+
Boolean(textureCoordinateAttribute),
|
|
62
|
+
Boolean(colorAttribute),
|
|
63
|
+
customScalarAttributes
|
|
64
|
+
);
|
|
65
|
+
const rows = [];
|
|
66
|
+
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
|
|
67
|
+
const row = [
|
|
68
|
+
getComponent(positionAttribute, vertexIndex, 0),
|
|
69
|
+
getComponent(positionAttribute, vertexIndex, 1),
|
|
70
|
+
getComponent(positionAttribute, vertexIndex, 2)
|
|
71
|
+
];
|
|
72
|
+
if (normalAttribute) {
|
|
73
|
+
row.push(
|
|
74
|
+
getComponent(normalAttribute, vertexIndex, 0),
|
|
75
|
+
getComponent(normalAttribute, vertexIndex, 1),
|
|
76
|
+
getComponent(normalAttribute, vertexIndex, 2)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (textureCoordinateAttribute) {
|
|
80
|
+
row.push(
|
|
81
|
+
getComponent(textureCoordinateAttribute, vertexIndex, 0),
|
|
82
|
+
getComponent(textureCoordinateAttribute, vertexIndex, 1)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (colorAttribute) {
|
|
86
|
+
row.push(
|
|
87
|
+
getColorByte(colorAttribute, vertexIndex, 0),
|
|
88
|
+
getColorByte(colorAttribute, vertexIndex, 1),
|
|
89
|
+
getColorByte(colorAttribute, vertexIndex, 2)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
for (const [, attribute] of customScalarAttributes) {
|
|
93
|
+
row.push(getComponent(attribute, vertexIndex, 0));
|
|
94
|
+
}
|
|
95
|
+
rows.push(row.join(" "));
|
|
96
|
+
}
|
|
97
|
+
for (let triangleIndex = 0; triangleIndex < triangleIndices.length; triangleIndex += 3) {
|
|
98
|
+
rows.push(
|
|
99
|
+
`3 ${triangleIndices[triangleIndex]} ${triangleIndices[triangleIndex + 1]} ${triangleIndices[triangleIndex + 2]}`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return `${header.concat(rows).join("\n")}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
function normalizeMeshArrowTable(data) {
|
|
106
|
+
if ("shape" in data && data.shape === "arrow-table") {
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
return (0, import_schema_utils.convertMeshToTable)(data, "arrow-table");
|
|
110
|
+
}
|
|
111
|
+
function getRequiredAttribute(mesh, attributeName) {
|
|
112
|
+
const attribute = mesh.attributes[attributeName];
|
|
113
|
+
if (!attribute) {
|
|
114
|
+
throw new Error(`PLYWriter: ${attributeName} attribute is required`);
|
|
115
|
+
}
|
|
116
|
+
return attribute;
|
|
117
|
+
}
|
|
118
|
+
function getPLYHeader(vertexCount, faceCount, hasNormals, hasTextureCoordinates, hasColors, customScalarAttributes) {
|
|
119
|
+
const header = [
|
|
120
|
+
"ply",
|
|
121
|
+
"format ascii 1.0",
|
|
122
|
+
"comment generated by loaders.gl",
|
|
123
|
+
`element vertex ${vertexCount}`,
|
|
124
|
+
"property float x",
|
|
125
|
+
"property float y",
|
|
126
|
+
"property float z"
|
|
127
|
+
];
|
|
128
|
+
if (hasNormals) {
|
|
129
|
+
header.push("property float nx", "property float ny", "property float nz");
|
|
130
|
+
}
|
|
131
|
+
if (hasTextureCoordinates) {
|
|
132
|
+
header.push("property float s", "property float t");
|
|
133
|
+
}
|
|
134
|
+
if (hasColors) {
|
|
135
|
+
header.push("property uchar red", "property uchar green", "property uchar blue");
|
|
136
|
+
}
|
|
137
|
+
for (const [attributeName] of customScalarAttributes) {
|
|
138
|
+
header.push(`property float ${attributeName}`);
|
|
139
|
+
}
|
|
140
|
+
if (faceCount > 0) {
|
|
141
|
+
header.push(`element face ${faceCount}`, "property list uchar int vertex_indices");
|
|
142
|
+
}
|
|
143
|
+
header.push("end_header");
|
|
144
|
+
return header;
|
|
145
|
+
}
|
|
146
|
+
function getCustomScalarAttributes(mesh) {
|
|
147
|
+
const reservedAttributeNames = /* @__PURE__ */ new Set(["POSITION", "NORMAL", "TEXCOORD_0", "COLOR_0"]);
|
|
148
|
+
return Object.entries(mesh.attributes).filter(
|
|
149
|
+
([attributeName, attribute]) => !reservedAttributeNames.has(attributeName) && attribute.size === 1
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
function getComponent(attribute, vertexIndex, componentIndex) {
|
|
153
|
+
return attribute.value[vertexIndex * attribute.size + componentIndex] || 0;
|
|
154
|
+
}
|
|
155
|
+
function getColorByte(attribute, vertexIndex, componentIndex) {
|
|
156
|
+
const value = getComponent(attribute, vertexIndex, componentIndex);
|
|
157
|
+
const byteValue = attribute.normalized || value <= 1 ? value * 255 : value;
|
|
158
|
+
return Math.max(0, Math.min(255, Math.round(byteValue)));
|
|
159
|
+
}
|
|
160
|
+
function getTriangleIndices(mesh, vertexCount) {
|
|
161
|
+
if (mesh.indices?.value?.length) {
|
|
162
|
+
return Array.from(mesh.indices.value);
|
|
163
|
+
}
|
|
164
|
+
if (mesh.mode !== 4 && mesh.topology !== "triangle-list") {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
const triangleIndices = [];
|
|
168
|
+
for (let vertexIndex = 0; vertexIndex + 2 < vertexCount; vertexIndex += 3) {
|
|
169
|
+
triangleIndices.push(vertexIndex, vertexIndex + 1, vertexIndex + 2);
|
|
170
|
+
}
|
|
171
|
+
return triangleIndices;
|
|
172
|
+
}
|
|
173
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
174
|
+
0 && (module.exports = {
|
|
175
|
+
PLYWriter
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=ply-writer.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ply-writer.ts", "../src/ply/ply-writer.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './ply/ply-writer.js';\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {WriterOptions, WriterWithEncoder} from '@loaders.gl/core/loader-utils';\nimport type {Mesh, MeshArrowTable, MeshAttribute} from '@loaders.gl/core/schema';\nimport {convertMeshToTable, convertTableToMesh} from '@loaders.gl/core/schema-utils';\nimport {PLYFormat} from './ply-format';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Options for `PLYWriter`. */\nexport type PLYWriterOptions = WriterOptions & {\n /** Reserved for future PLY writer options. */\n ply?: Record<string, never>;\n};\n\n/**\n * Writer for the PLY geometry format.\n */\nexport const PLYWriter = {\n ...PLYFormat,\n dataType: null as unknown as Mesh | MeshArrowTable,\n batchType: null as never,\n version: VERSION,\n options: {\n ply: {}\n },\n text: true,\n encode: async (data, options) => encodePLYSync(data, options),\n encodeSync: encodePLYSync,\n encodeTextSync: encodePLY\n} as const satisfies WriterWithEncoder<Mesh | MeshArrowTable, never, PLYWriterOptions>;\n\n/** Encode mesh category data as PLY bytes. */\nfunction encodePLYSync(data: Mesh | MeshArrowTable, options?: PLYWriterOptions): ArrayBuffer {\n const text = encodePLY(data, options);\n return new TextEncoder().encode(text).buffer;\n}\n\n/** Encode mesh category data as ASCII PLY text. */\nfunction encodePLY(data: Mesh | MeshArrowTable, options?: PLYWriterOptions): string {\n const mesh = convertTableToMesh(normalizeMeshArrowTable(data));\n const positionAttribute = getRequiredAttribute(mesh, 'POSITION');\n const normalAttribute = mesh.attributes.NORMAL;\n const textureCoordinateAttribute = mesh.attributes.TEXCOORD_0;\n const colorAttribute = mesh.attributes.COLOR_0;\n const customScalarAttributes = getCustomScalarAttributes(mesh);\n const vertexCount = positionAttribute.value.length / positionAttribute.size;\n const triangleIndices = getTriangleIndices(mesh, vertexCount);\n const header = getPLYHeader(\n vertexCount,\n triangleIndices.length / 3,\n Boolean(normalAttribute),\n Boolean(textureCoordinateAttribute),\n Boolean(colorAttribute),\n customScalarAttributes\n );\n const rows: string[] = [];\n\n for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {\n const row = [\n getComponent(positionAttribute, vertexIndex, 0),\n getComponent(positionAttribute, vertexIndex, 1),\n getComponent(positionAttribute, vertexIndex, 2)\n ];\n\n if (normalAttribute) {\n row.push(\n getComponent(normalAttribute, vertexIndex, 0),\n getComponent(normalAttribute, vertexIndex, 1),\n getComponent(normalAttribute, vertexIndex, 2)\n );\n }\n\n if (textureCoordinateAttribute) {\n row.push(\n getComponent(textureCoordinateAttribute, vertexIndex, 0),\n getComponent(textureCoordinateAttribute, vertexIndex, 1)\n );\n }\n\n if (colorAttribute) {\n row.push(\n getColorByte(colorAttribute, vertexIndex, 0),\n getColorByte(colorAttribute, vertexIndex, 1),\n getColorByte(colorAttribute, vertexIndex, 2)\n );\n }\n\n for (const [, attribute] of customScalarAttributes) {\n row.push(getComponent(attribute, vertexIndex, 0));\n }\n\n rows.push(row.join(' '));\n }\n\n for (let triangleIndex = 0; triangleIndex < triangleIndices.length; triangleIndex += 3) {\n rows.push(\n `3 ${triangleIndices[triangleIndex]} ${triangleIndices[triangleIndex + 1]} ${\n triangleIndices[triangleIndex + 2]\n }`\n );\n }\n\n return `${header.concat(rows).join('\\n')}\\n`;\n}\n\n/** Return mesh data as a MeshArrowTable, converting plain Mesh data first. */\nfunction normalizeMeshArrowTable(data: Mesh | MeshArrowTable): MeshArrowTable {\n if ('shape' in data && data.shape === 'arrow-table') {\n return data;\n }\n return convertMeshToTable(data as Mesh, 'arrow-table');\n}\n\n/** Return a required mesh attribute or throw a format-specific error. */\nfunction getRequiredAttribute(mesh: Mesh, attributeName: string): MeshAttribute {\n const attribute = mesh.attributes[attributeName];\n if (!attribute) {\n throw new Error(`PLYWriter: ${attributeName} attribute is required`);\n }\n return attribute;\n}\n\n/** Return the ASCII PLY header lines. */\nfunction getPLYHeader(\n vertexCount: number,\n faceCount: number,\n hasNormals: boolean,\n hasTextureCoordinates: boolean,\n hasColors: boolean,\n customScalarAttributes: [string, MeshAttribute][]\n): string[] {\n const header = [\n 'ply',\n 'format ascii 1.0',\n 'comment generated by loaders.gl',\n `element vertex ${vertexCount}`,\n 'property float x',\n 'property float y',\n 'property float z'\n ];\n\n if (hasNormals) {\n header.push('property float nx', 'property float ny', 'property float nz');\n }\n\n if (hasTextureCoordinates) {\n header.push('property float s', 'property float t');\n }\n\n if (hasColors) {\n header.push('property uchar red', 'property uchar green', 'property uchar blue');\n }\n\n for (const [attributeName] of customScalarAttributes) {\n header.push(`property float ${attributeName}`);\n }\n\n if (faceCount > 0) {\n header.push(`element face ${faceCount}`, 'property list uchar int vertex_indices');\n }\n\n header.push('end_header');\n return header;\n}\n\n/** Return additional one-component attributes that can be represented as scalar PLY properties. */\nfunction getCustomScalarAttributes(mesh: Mesh): [string, MeshAttribute][] {\n const reservedAttributeNames = new Set(['POSITION', 'NORMAL', 'TEXCOORD_0', 'COLOR_0']);\n return Object.entries(mesh.attributes).filter(\n ([attributeName, attribute]) =>\n !reservedAttributeNames.has(attributeName) && attribute.size === 1\n );\n}\n\n/** Return a single attribute component with 0 as the missing component fallback. */\nfunction getComponent(\n attribute: MeshAttribute,\n vertexIndex: number,\n componentIndex: number\n): number {\n return attribute.value[vertexIndex * attribute.size + componentIndex] || 0;\n}\n\n/** Return one color component as an unsigned byte. */\nfunction getColorByte(\n attribute: MeshAttribute,\n vertexIndex: number,\n componentIndex: number\n): number {\n const value = getComponent(attribute, vertexIndex, componentIndex);\n const byteValue = attribute.normalized || value <= 1 ? value * 255 : value;\n return Math.max(0, Math.min(255, Math.round(byteValue)));\n}\n\n/** Return triangle indices for indexed or sequential triangle-list meshes. */\nfunction getTriangleIndices(mesh: Mesh, vertexCount: number): number[] {\n if (mesh.indices?.value?.length) {\n return Array.from(mesh.indices.value);\n }\n\n if (mesh.mode !== 4 && mesh.topology !== 'triangle-list') {\n return [];\n }\n\n const triangleIndices: number[] = [];\n for (let vertexIndex = 0; vertexIndex + 2 < vertexCount; vertexIndex += 3) {\n triangleIndices.push(vertexIndex, vertexIndex + 1, vertexIndex + 2);\n }\n return triangleIndices;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-writer.d.ts","sourceRoot":"","sources":["../src/ply-writer.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-writer.js","sourceRoot":"","sources":["../src/ply-writer.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|