@loaders.gl/ply 4.3.4 → 4.4.0-alpha.10
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.dev.js +12057 -41
- package/dist/dist.min.js +13 -4
- package/dist/index.cjs +48 -21
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -15
- package/dist/index.js.map +1 -0
- package/dist/lib/get-ply-schema.d.ts +1 -1
- package/dist/lib/get-ply-schema.d.ts.map +1 -1
- package/dist/lib/get-ply-schema.js +5 -1
- package/dist/lib/get-ply-schema.js.map +1 -0
- package/dist/lib/normalize-ply.d.ts.map +1 -1
- package/dist/lib/normalize-ply.js +5 -1
- package/dist/lib/normalize-ply.js.map +1 -0
- 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 +6 -2
- package/dist/lib/parse-ply-in-batches.js.map +1 -0
- package/dist/lib/parse-ply.d.ts.map +1 -1
- package/dist/lib/parse-ply.js +4 -0
- package/dist/lib/parse-ply.js.map +1 -0
- package/dist/lib/ply-types.js +1 -0
- package/dist/lib/ply-types.js.map +1 -0
- package/dist/ply-arrow-loader.d.ts +23 -0
- package/dist/ply-arrow-loader.d.ts.map +1 -0
- package/dist/ply-arrow-loader.js +21 -0
- package/dist/ply-arrow-loader.js.map +1 -0
- package/dist/ply-format.d.ts +16 -0
- package/dist/ply-format.d.ts.map +1 -0
- package/dist/ply-format.js +20 -0
- package/dist/ply-format.js.map +1 -0
- package/dist/ply-loader.d.ts +25 -1
- package/dist/ply-loader.d.ts.map +1 -1
- package/dist/ply-loader.js +19 -2
- package/dist/ply-loader.js.map +1 -0
- package/dist/ply-worker.js +85 -31
- package/dist/workers/ply-worker.js +1 -0
- package/dist/workers/ply-worker.js.map +1 -0
- package/package.json +9 -5
- package/src/index.ts +4 -22
- package/src/lib/get-ply-schema.ts +6 -1
- package/src/lib/normalize-ply.ts +5 -1
- package/src/lib/parse-ply-in-batches.ts +14 -3
- package/src/lib/parse-ply.ts +4 -0
- package/src/ply-arrow-loader.ts +25 -0
- package/src/ply-format.ts +22 -0
- package/src/ply-loader.ts +26 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { PLYWorkerLoader } from "./ply-loader.js";
|
|
5
|
+
import { convertMeshToTable } from '@loaders.gl/schema-utils';
|
|
6
|
+
import { parsePLY } from "./lib/parse-ply.js";
|
|
7
|
+
/**
|
|
8
|
+
* Worker loader for PLY -
|
|
9
|
+
*/
|
|
10
|
+
export const PLYArrowLoader = {
|
|
11
|
+
...PLYWorkerLoader,
|
|
12
|
+
dataType: null,
|
|
13
|
+
batchType: null,
|
|
14
|
+
worker: false,
|
|
15
|
+
parse: async (arrayBuffer) => {
|
|
16
|
+
const mesh = parsePLY(arrayBuffer);
|
|
17
|
+
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
|
|
18
|
+
return arrowTable;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=ply-arrow-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-arrow-loader.js","sourceRoot":"","sources":["../src/ply-arrow-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAmB,eAAe,EAAC,wBAAqB;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,eAAe;IAClB,QAAQ,EAAE,IAA6B;IACvC,SAAS,EAAE,IAAa;IACxB,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK,EAAE,WAAwB,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC3D,OAAO,UAAU,CAAC;IACpB,CAAC;CACuE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PLY - Polygon File Format (aka Stanford Triangle Format)
|
|
3
|
+
* @see http://paulbourke.net/dataformats/ply/,
|
|
4
|
+
* @see https://en.wikipedia.org/wiki/PLY_(file_format)
|
|
5
|
+
*/
|
|
6
|
+
export declare const PLYFormat: {
|
|
7
|
+
readonly name: "PLY";
|
|
8
|
+
readonly id: "ply";
|
|
9
|
+
readonly module: "ply";
|
|
10
|
+
readonly extensions: ["ply"];
|
|
11
|
+
readonly mimeTypes: ["text/plain", "application/octet-stream"];
|
|
12
|
+
readonly text: true;
|
|
13
|
+
readonly binary: true;
|
|
14
|
+
readonly tests: ["ply"];
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=ply-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-format.d.ts","sourceRoot":"","sources":["../src/ply-format.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CAUK,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* PLY - Polygon File Format (aka Stanford Triangle Format)
|
|
6
|
+
* @see http://paulbourke.net/dataformats/ply/,
|
|
7
|
+
* @see https://en.wikipedia.org/wiki/PLY_(file_format)
|
|
8
|
+
*/
|
|
9
|
+
export const PLYFormat = {
|
|
10
|
+
name: 'PLY',
|
|
11
|
+
id: 'ply',
|
|
12
|
+
module: 'ply',
|
|
13
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
14
|
+
extensions: ['ply'],
|
|
15
|
+
mimeTypes: ['text/plain', 'application/octet-stream'],
|
|
16
|
+
text: true,
|
|
17
|
+
binary: true,
|
|
18
|
+
tests: ['ply']
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ply-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-format.js","sourceRoot":"","sources":["../src/ply-format.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;IACb,8CAA8C;IAC9C,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,YAAY,EAAE,0BAA0B,CAAC;IACrD,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,CAAC,KAAK,CAAC;CACW,CAAC"}
|
package/dist/ply-loader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { PLYMesh } from "./lib/ply-types.js";
|
|
2
|
+
import type { PLYMesh } from "./lib/ply-types.js";
|
|
3
3
|
import type { ParsePLYOptions } from "./lib/parse-ply.js";
|
|
4
4
|
export type PLYLoaderOptions = LoaderOptions & {
|
|
5
5
|
ply?: ParsePLYOptions & {
|
|
@@ -12,7 +12,31 @@ export type PLYLoaderOptions = LoaderOptions & {
|
|
|
12
12
|
* links: ['http://paulbourke.net/dataformats/ply/',
|
|
13
13
|
* 'https://en.wikipedia.org/wiki/PLY_(file_format)']
|
|
14
14
|
*/
|
|
15
|
+
export declare const PLYWorkerLoader: {
|
|
16
|
+
readonly dataType: PLYMesh;
|
|
17
|
+
readonly batchType: never;
|
|
18
|
+
readonly name: "PLY";
|
|
19
|
+
readonly id: "ply";
|
|
20
|
+
readonly module: "ply";
|
|
21
|
+
readonly version: any;
|
|
22
|
+
readonly worker: true;
|
|
23
|
+
readonly extensions: ["ply"];
|
|
24
|
+
readonly mimeTypes: ["text/plain", "application/octet-stream"];
|
|
25
|
+
readonly text: true;
|
|
26
|
+
readonly binary: true;
|
|
27
|
+
readonly tests: ["ply"];
|
|
28
|
+
readonly options: {
|
|
29
|
+
readonly ply: {};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Loader for PLY - Polygon File Format
|
|
34
|
+
*/
|
|
15
35
|
export declare const PLYLoader: {
|
|
36
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options: PLYLoaderOptions | undefined) => Promise<PLYMesh>;
|
|
37
|
+
readonly parseTextSync: (arrayBuffer: string, options: PLYLoaderOptions | undefined) => PLYMesh;
|
|
38
|
+
readonly parseSync: (arrayBuffer: ArrayBuffer, options: PLYLoaderOptions | undefined) => PLYMesh;
|
|
39
|
+
readonly parseInBatches: (arrayBuffer: AsyncIterable<ArrayBufferLike | ArrayBufferView> | Iterable<ArrayBufferLike | ArrayBufferView>, options: PLYLoaderOptions | undefined) => AsyncIterable<PLYMesh>;
|
|
16
40
|
readonly dataType: PLYMesh;
|
|
17
41
|
readonly batchType: never;
|
|
18
42
|
readonly name: "PLY";
|
package/dist/ply-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ply-loader.d.ts","sourceRoot":"","sources":["../src/ply-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ply-loader.d.ts","sourceRoot":"","sources":["../src/ply-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAA2B,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAC,OAAO,EAAC,2BAAwB;AAC7C,OAAO,KAAK,EAAC,eAAe,EAAC,2BAAwB;AAQrD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,GAAG;QACtB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe;uBACG,OAAO;wBACjB,KAAK;;;;;;;;;;;;;;CAgBgC,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,SAAS;;;;2CAQd,aAAa,CAAC,eAAe,GAAG,eAAe,CAAC,GAChD,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC;uBA/BpB,OAAO;wBACjB,KAAK;;;;;;;;;;;;;;CAiC2C,CAAC"}
|
package/dist/ply-loader.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { parsePLY } from "./lib/parse-ply.js";
|
|
5
|
+
import { parsePLYInBatches } from "./lib/parse-ply-in-batches.js";
|
|
1
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
2
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
3
|
-
const VERSION = typeof "4.
|
|
8
|
+
const VERSION = typeof "4.4.0-alpha.10" !== 'undefined' ? "4.4.0-alpha.10" : 'latest';
|
|
4
9
|
/**
|
|
5
10
|
* Worker loader for PLY - Polygon File Format (aka Stanford Triangle Format)'
|
|
6
11
|
* links: ['http://paulbourke.net/dataformats/ply/',
|
|
7
12
|
* 'https://en.wikipedia.org/wiki/PLY_(file_format)']
|
|
8
13
|
*/
|
|
9
|
-
export const
|
|
14
|
+
export const PLYWorkerLoader = {
|
|
10
15
|
dataType: null,
|
|
11
16
|
batchType: null,
|
|
12
17
|
name: 'PLY',
|
|
@@ -24,3 +29,15 @@ export const PLYLoader = {
|
|
|
24
29
|
ply: {}
|
|
25
30
|
}
|
|
26
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Loader for PLY - Polygon File Format
|
|
34
|
+
*/
|
|
35
|
+
export const PLYLoader = {
|
|
36
|
+
...PLYWorkerLoader,
|
|
37
|
+
// Note: parsePLY supports both text and binary
|
|
38
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?
|
|
39
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
40
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
41
|
+
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ply-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-loader.js","sourceRoot":"","sources":["../src/ply-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAMpC,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EAAC,iBAAiB,EAAC,sCAAmC;AAE7D,yDAAyD;AACzD,qDAAqD;AACrD,MAAM,OAAO,GAAG,uBAAkB,KAAK,WAAW,CAAC,CAAC,kBAAa,CAAC,CAAC,QAAQ,CAAC;AAS5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,IAA0B;IACpC,SAAS,EAAE,IAAa;IAExB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;IACb,8CAA8C;IAC9C,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,IAAI;IACZ,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,YAAY,EAAE,0BAA0B,CAAC;IACrD,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,CAAC,KAAK,CAAC;IACd,OAAO,EAAE;QACP,GAAG,EAAE,EAAE;KACR;CACuD,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,eAAe;IAClB,+CAA+C;IAC/C,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,6CAA6C;IACzH,aAAa,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC;IAC5E,SAAS,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC;IACxE,cAAc,EAAE,CACd,WAE+C,EAC/C,OAAO,EACP,EAAE,CAAC,iBAAiB,CAAC,WAAW,EAAE,OAAO,EAAE,GAAG,CAAC;CACkB,CAAC"}
|
package/dist/ply-worker.js
CHANGED
|
@@ -194,7 +194,10 @@
|
|
|
194
194
|
options = {
|
|
195
195
|
...options,
|
|
196
196
|
modules: loader && loader.options && loader.options.modules || {},
|
|
197
|
-
|
|
197
|
+
core: {
|
|
198
|
+
...options.core,
|
|
199
|
+
worker: false
|
|
200
|
+
}
|
|
198
201
|
};
|
|
199
202
|
return await parser(data, { ...options }, context, loader);
|
|
200
203
|
}
|
|
@@ -223,11 +226,14 @@
|
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
226
|
-
async function forEach(
|
|
229
|
+
async function forEach(iterable, visitor) {
|
|
230
|
+
const iterator = toAsyncIterator(iterable);
|
|
227
231
|
while (true) {
|
|
228
232
|
const { done, value } = await iterator.next();
|
|
229
233
|
if (done) {
|
|
230
|
-
iterator.return
|
|
234
|
+
if (iterator.return) {
|
|
235
|
+
iterator.return();
|
|
236
|
+
}
|
|
231
237
|
return;
|
|
232
238
|
}
|
|
233
239
|
const cancel = visitor(value);
|
|
@@ -236,29 +242,58 @@
|
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
var PLYLoader = {
|
|
243
|
-
dataType: null,
|
|
244
|
-
batchType: null,
|
|
245
|
-
name: "PLY",
|
|
246
|
-
id: "ply",
|
|
247
|
-
module: "ply",
|
|
248
|
-
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
249
|
-
version: VERSION,
|
|
250
|
-
worker: true,
|
|
251
|
-
extensions: ["ply"],
|
|
252
|
-
mimeTypes: ["text/plain", "application/octet-stream"],
|
|
253
|
-
text: true,
|
|
254
|
-
binary: true,
|
|
255
|
-
tests: ["ply"],
|
|
256
|
-
options: {
|
|
257
|
-
ply: {}
|
|
245
|
+
async function* toArrayBufferIterator(asyncIterator) {
|
|
246
|
+
for await (const chunk of asyncIterator) {
|
|
247
|
+
yield copyToArrayBuffer(chunk);
|
|
258
248
|
}
|
|
259
|
-
}
|
|
249
|
+
}
|
|
250
|
+
function copyToArrayBuffer(chunk) {
|
|
251
|
+
if (chunk instanceof ArrayBuffer) {
|
|
252
|
+
return chunk;
|
|
253
|
+
}
|
|
254
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
255
|
+
const { buffer, byteOffset, byteLength } = chunk;
|
|
256
|
+
return copyFromBuffer(buffer, byteOffset, byteLength);
|
|
257
|
+
}
|
|
258
|
+
return copyFromBuffer(chunk);
|
|
259
|
+
}
|
|
260
|
+
function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
261
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
262
|
+
const copy = new Uint8Array(view.length);
|
|
263
|
+
copy.set(view);
|
|
264
|
+
return copy.buffer;
|
|
265
|
+
}
|
|
266
|
+
function toAsyncIterator(iterable) {
|
|
267
|
+
if (typeof iterable[Symbol.asyncIterator] === "function") {
|
|
268
|
+
return iterable[Symbol.asyncIterator]();
|
|
269
|
+
}
|
|
270
|
+
if (typeof iterable[Symbol.iterator] === "function") {
|
|
271
|
+
const iterator = iterable[Symbol.iterator]();
|
|
272
|
+
return iteratorToAsyncIterator(iterator);
|
|
273
|
+
}
|
|
274
|
+
return iterable;
|
|
275
|
+
}
|
|
276
|
+
function iteratorToAsyncIterator(iterator) {
|
|
277
|
+
return {
|
|
278
|
+
next(value) {
|
|
279
|
+
return Promise.resolve(iterator.next(value));
|
|
280
|
+
},
|
|
281
|
+
return(value) {
|
|
282
|
+
if (typeof iterator.return === "function") {
|
|
283
|
+
return Promise.resolve(iterator.return(value));
|
|
284
|
+
}
|
|
285
|
+
return Promise.resolve({ done: true, value });
|
|
286
|
+
},
|
|
287
|
+
throw(error) {
|
|
288
|
+
if (typeof iterator.throw === "function") {
|
|
289
|
+
return Promise.resolve(iterator.throw(error));
|
|
290
|
+
}
|
|
291
|
+
return Promise.reject(error);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
260
295
|
|
|
261
|
-
// ../schema/src/lib/
|
|
296
|
+
// ../schema-utils/src/lib/schema/data-type.ts
|
|
262
297
|
function getDataTypeFromTypedArray(array) {
|
|
263
298
|
switch (array.constructor) {
|
|
264
299
|
case Int8Array:
|
|
@@ -283,7 +318,7 @@
|
|
|
283
318
|
}
|
|
284
319
|
}
|
|
285
320
|
|
|
286
|
-
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
321
|
+
// ../schema-utils/src/lib/mesh/mesh-utils.ts
|
|
287
322
|
function getMeshBoundingBox(attributes) {
|
|
288
323
|
let minX = Infinity;
|
|
289
324
|
let minY = Infinity;
|
|
@@ -310,7 +345,7 @@
|
|
|
310
345
|
];
|
|
311
346
|
}
|
|
312
347
|
|
|
313
|
-
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
348
|
+
// ../schema-utils/src/lib/mesh/deduce-mesh-schema.ts
|
|
314
349
|
function deduceMeshSchema(attributes, metadata = {}) {
|
|
315
350
|
const fields = deduceMeshFields(attributes);
|
|
316
351
|
return { fields, metadata };
|
|
@@ -757,7 +792,7 @@
|
|
|
757
792
|
// src/lib/parse-ply-in-batches.ts
|
|
758
793
|
var currentElement;
|
|
759
794
|
async function* parsePLYInBatches(iterator, options) {
|
|
760
|
-
const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));
|
|
795
|
+
const lineIterator = makeLineIterator(makeTextDecoderIterator(toArrayBufferIterator(iterator)));
|
|
761
796
|
const header = await parsePLYHeader(lineIterator, options);
|
|
762
797
|
let attributes;
|
|
763
798
|
switch (header.format) {
|
|
@@ -930,9 +965,28 @@
|
|
|
930
965
|
}
|
|
931
966
|
}
|
|
932
967
|
|
|
933
|
-
// src/
|
|
934
|
-
var
|
|
935
|
-
|
|
968
|
+
// src/ply-loader.ts
|
|
969
|
+
var VERSION = true ? "4.4.0-alpha.10" : "latest";
|
|
970
|
+
var PLYWorkerLoader = {
|
|
971
|
+
dataType: null,
|
|
972
|
+
batchType: null,
|
|
973
|
+
name: "PLY",
|
|
974
|
+
id: "ply",
|
|
975
|
+
module: "ply",
|
|
976
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
977
|
+
version: VERSION,
|
|
978
|
+
worker: true,
|
|
979
|
+
extensions: ["ply"],
|
|
980
|
+
mimeTypes: ["text/plain", "application/octet-stream"],
|
|
981
|
+
text: true,
|
|
982
|
+
binary: true,
|
|
983
|
+
tests: ["ply"],
|
|
984
|
+
options: {
|
|
985
|
+
ply: {}
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
var PLYLoader = {
|
|
989
|
+
...PLYWorkerLoader,
|
|
936
990
|
// Note: parsePLY supports both text and binary
|
|
937
991
|
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
938
992
|
// TODO - this may not detect text correctly?
|
|
@@ -942,5 +996,5 @@
|
|
|
942
996
|
};
|
|
943
997
|
|
|
944
998
|
// src/workers/ply-worker.ts
|
|
945
|
-
createLoaderWorker(
|
|
999
|
+
createLoaderWorker(PLYLoader);
|
|
946
1000
|
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ply-worker.js","sourceRoot":"","sources":["../../src/workers/ply-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAC,SAAS,EAAC,oBAAiB;AAEnC,kBAAkB,CAAC,SAAS,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/ply",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.10",
|
|
4
4
|
"description": "Framework-independent loader for the PLY format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
28
|
"import": "./dist/index.js",
|
|
29
29
|
"require": "./dist/index.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./ply-worker.js": {
|
|
32
|
+
"import": "./dist/ply-worker.js"
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
35
|
"sideEffects": false,
|
|
@@ -42,11 +45,12 @@
|
|
|
42
45
|
"build-worker": "esbuild src/workers/ply-worker.ts --bundle --outfile=dist/ply-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
43
46
|
},
|
|
44
47
|
"dependencies": {
|
|
45
|
-
"@loaders.gl/loader-utils": "4.
|
|
46
|
-
"@loaders.gl/schema": "4.
|
|
48
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.10",
|
|
49
|
+
"@loaders.gl/schema": "4.4.0-alpha.10",
|
|
50
|
+
"@loaders.gl/schema-utils": "4.4.0-alpha.10"
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
49
|
-
"@loaders.gl/core": "
|
|
53
|
+
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
50
54
|
},
|
|
51
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "7b4dc3fdbaed20a2597c70c57efdcda5c404147f"
|
|
52
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,27 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
-
import type {PLYMesh} from './lib/ply-types';
|
|
7
|
-
import type {PLYLoaderOptions} from './ply-loader';
|
|
8
|
-
import {PLYLoader as PLYWorkerLoader} from './ply-loader';
|
|
9
|
-
import {parsePLY} from './lib/parse-ply';
|
|
10
|
-
import {parsePLYInBatches} from './lib/parse-ply-in-batches';
|
|
11
|
-
|
|
12
5
|
// PLYLoader
|
|
6
|
+
export {PLYFormat} from './ply-format';
|
|
13
7
|
|
|
14
|
-
export type {PLYLoaderOptions};
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Loader for PLY - Polygon File Format
|
|
20
|
-
*/
|
|
21
|
-
export const PLYLoader = {
|
|
22
|
-
...PLYWorkerLoader,
|
|
23
|
-
// Note: parsePLY supports both text and binary
|
|
24
|
-
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?
|
|
25
|
-
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
26
|
-
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
27
|
-
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
28
|
-
} as const satisfies LoaderWithParser<PLYMesh, any, PLYLoaderOptions>;
|
|
8
|
+
export type {PLYLoaderOptions} from './ply-loader';
|
|
9
|
+
export {PLYWorkerLoader, PLYLoader} from './ply-loader';
|
|
10
|
+
export {PLYArrowLoader} from './ply-arrow-loader';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Schema, MeshAttributes} from '@loaders.gl/schema';
|
|
6
|
+
import {deduceMeshSchema} from '@loaders.gl/schema-utils';
|
|
2
7
|
import type {PLYHeader} from './ply-types';
|
|
3
8
|
|
|
4
9
|
/**
|
package/src/lib/normalize-ply.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import type {MeshAttributes} from '@loaders.gl/schema';
|
|
2
|
-
import {getMeshBoundingBox} from '@loaders.gl/schema';
|
|
6
|
+
import {getMeshBoundingBox} from '@loaders.gl/schema-utils';
|
|
3
7
|
import type {PLYMesh, PLYHeader, PLYAttributes, MeshHeader} from './ply-types';
|
|
4
8
|
import {getPLYSchema} from './get-ply-schema';
|
|
5
9
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// PLY Loader, adapted from THREE.js (MIT license)
|
|
2
6
|
//
|
|
3
7
|
// Attributions per original THREE.js source file:
|
|
@@ -21,7 +25,12 @@
|
|
|
21
25
|
// }
|
|
22
26
|
// });
|
|
23
27
|
|
|
24
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
makeLineIterator,
|
|
30
|
+
makeTextDecoderIterator,
|
|
31
|
+
forEach,
|
|
32
|
+
toArrayBufferIterator
|
|
33
|
+
} from '@loaders.gl/loader-utils';
|
|
25
34
|
import normalizePLY from './normalize-ply';
|
|
26
35
|
import {PLYMesh, PLYHeader, PLYElement, PLYProperty, PLYAttributes} from './ply-types';
|
|
27
36
|
|
|
@@ -33,10 +42,12 @@ let currentElement: PLYElement;
|
|
|
33
42
|
* @param options
|
|
34
43
|
*/
|
|
35
44
|
export async function* parsePLYInBatches(
|
|
36
|
-
iterator:
|
|
45
|
+
iterator:
|
|
46
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
47
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
37
48
|
options: any
|
|
38
49
|
): AsyncIterable<PLYMesh> {
|
|
39
|
-
const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));
|
|
50
|
+
const lineIterator = makeLineIterator(makeTextDecoderIterator(toArrayBufferIterator(iterator)));
|
|
40
51
|
const header = await parsePLYHeader(lineIterator, options);
|
|
41
52
|
|
|
42
53
|
let attributes: PLYAttributes;
|
package/src/lib/parse-ply.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {ArrowTable} from '@loaders.gl/schema';
|
|
7
|
+
|
|
8
|
+
import {PLYLoaderOptions, PLYWorkerLoader} from './ply-loader';
|
|
9
|
+
import {convertMeshToTable} from '@loaders.gl/schema-utils';
|
|
10
|
+
import {parsePLY} from './lib/parse-ply';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Worker loader for PLY -
|
|
14
|
+
*/
|
|
15
|
+
export const PLYArrowLoader = {
|
|
16
|
+
...PLYWorkerLoader,
|
|
17
|
+
dataType: null as unknown as ArrowTable,
|
|
18
|
+
batchType: null as never,
|
|
19
|
+
worker: false,
|
|
20
|
+
parse: async (arrayBuffer: ArrayBuffer) => {
|
|
21
|
+
const mesh = parsePLY(arrayBuffer);
|
|
22
|
+
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
|
|
23
|
+
return arrowTable;
|
|
24
|
+
}
|
|
25
|
+
} as const satisfies LoaderWithParser<ArrowTable, never, PLYLoaderOptions>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Format} from '@loaders.gl/loader-utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* PLY - Polygon File Format (aka Stanford Triangle Format)
|
|
9
|
+
* @see http://paulbourke.net/dataformats/ply/,
|
|
10
|
+
* @see https://en.wikipedia.org/wiki/PLY_(file_format)
|
|
11
|
+
*/
|
|
12
|
+
export const PLYFormat = {
|
|
13
|
+
name: 'PLY',
|
|
14
|
+
id: 'ply',
|
|
15
|
+
module: 'ply',
|
|
16
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
17
|
+
extensions: ['ply'],
|
|
18
|
+
mimeTypes: ['text/plain', 'application/octet-stream'],
|
|
19
|
+
text: true,
|
|
20
|
+
binary: true,
|
|
21
|
+
tests: ['ply']
|
|
22
|
+
} as const satisfies Format;
|
package/src/ply-loader.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// PLY Loader
|
|
2
|
-
import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
3
|
-
import {PLYMesh} from './lib/ply-types';
|
|
6
|
+
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
7
|
+
import type {PLYMesh} from './lib/ply-types';
|
|
4
8
|
import type {ParsePLYOptions} from './lib/parse-ply';
|
|
9
|
+
import {parsePLY} from './lib/parse-ply';
|
|
10
|
+
import {parsePLYInBatches} from './lib/parse-ply-in-batches';
|
|
5
11
|
|
|
6
12
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
13
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
@@ -19,7 +25,7 @@ export type PLYLoaderOptions = LoaderOptions & {
|
|
|
19
25
|
* links: ['http://paulbourke.net/dataformats/ply/',
|
|
20
26
|
* 'https://en.wikipedia.org/wiki/PLY_(file_format)']
|
|
21
27
|
*/
|
|
22
|
-
export const
|
|
28
|
+
export const PLYWorkerLoader = {
|
|
23
29
|
dataType: null as unknown as PLYMesh,
|
|
24
30
|
batchType: null as never,
|
|
25
31
|
|
|
@@ -38,3 +44,20 @@ export const PLYLoader = {
|
|
|
38
44
|
ply: {}
|
|
39
45
|
}
|
|
40
46
|
} as const satisfies Loader<PLYMesh, never, LoaderOptions>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Loader for PLY - Polygon File Format
|
|
50
|
+
*/
|
|
51
|
+
export const PLYLoader = {
|
|
52
|
+
...PLYWorkerLoader,
|
|
53
|
+
// Note: parsePLY supports both text and binary
|
|
54
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply), // TODO - this may not detect text correctly?
|
|
55
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
56
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
57
|
+
parseInBatches: (
|
|
58
|
+
arrayBuffer:
|
|
59
|
+
| AsyncIterable<ArrayBufferLike | ArrayBufferView>
|
|
60
|
+
| Iterable<ArrayBufferLike | ArrayBufferView>,
|
|
61
|
+
options
|
|
62
|
+
) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
63
|
+
} as const satisfies LoaderWithParser<PLYMesh, any, PLYLoaderOptions>;
|