@loaders.gl/ply 4.0.0-alpha.5 → 4.0.0-alpha.6
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.js +2 -2
- package/dist/dist.min.js +201 -609
- 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 +7 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -11
- package/dist/lib/get-ply-schema.js +34 -24
- package/dist/lib/normalize-ply.js +76 -65
- 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 +237 -202
- package/dist/lib/parse-ply.d.ts +4 -1
- package/dist/lib/parse-ply.d.ts.map +1 -1
- package/dist/lib/parse-ply.js +378 -299
- package/dist/lib/ply-types.d.ts +22 -14
- package/dist/lib/ply-types.d.ts.map +1 -1
- package/dist/lib/ply-types.js +2 -2
- package/dist/ply-loader.d.ts +3 -17
- package/dist/ply-loader.d.ts.map +1 -1
- package/dist/ply-loader.js +27 -18
- package/dist/ply-worker.js +240 -578
- package/dist/workers/ply-worker.js +5 -4
- package/package.json +6 -6
- 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 +20 -22
- 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/index.d.ts
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
import type { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
1
|
+
import type { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { PLYMesh } from './lib/ply-types';
|
|
2
3
|
import { PLYLoader as PLYWorkerLoader } from './ply-loader';
|
|
3
|
-
import
|
|
4
|
-
import parsePLYInBatches from './lib/parse-ply-in-batches';
|
|
4
|
+
import { ParsePLYOptions } from './lib/parse-ply';
|
|
5
5
|
export { PLYWorkerLoader };
|
|
6
|
+
export type PLYLoaderOptions = LoaderOptions & {
|
|
7
|
+
ply?: ParsePLYOptions;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* Loader for PLY - Polygon File Format
|
|
8
11
|
*/
|
|
9
|
-
export declare const PLYLoader:
|
|
10
|
-
parse: (arrayBuffer: any, options: any) => Promise<import("./lib/ply-types").PLYMesh>;
|
|
11
|
-
parseTextSync: typeof parsePLY;
|
|
12
|
-
parseSync: typeof parsePLY;
|
|
13
|
-
parseInBatches: typeof parsePLYInBatches;
|
|
14
|
-
name: string;
|
|
15
|
-
id: string;
|
|
16
|
-
module: string;
|
|
17
|
-
shapes: string[];
|
|
18
|
-
version: any;
|
|
19
|
-
worker: boolean;
|
|
20
|
-
extensions: string[];
|
|
21
|
-
mimeTypes: string[];
|
|
22
|
-
text: boolean;
|
|
23
|
-
binary: boolean;
|
|
24
|
-
tests: string[];
|
|
25
|
-
options: {
|
|
26
|
-
ply: {};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export declare const _typecheckPLYLoader: LoaderWithParser;
|
|
12
|
+
export declare const PLYLoader: LoaderWithParser<PLYMesh, any, PLYLoaderOptions>;
|
|
30
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,SAAS,IAAI,eAAe,EAAC,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAW,MAAM,iBAAiB,CAAC;AAK1D,OAAO,EAAC,eAAe,EAAC,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAOtE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.PLYLoader = exports.PLYWorkerLoader = void 0;
|
|
5
|
+
const ply_loader_1 = require("./ply-loader");
|
|
6
|
+
Object.defineProperty(exports, "PLYWorkerLoader", { enumerable: true, get: function () { return ply_loader_1.PLYLoader; } });
|
|
7
|
+
const parse_ply_1 = require("./lib/parse-ply");
|
|
8
|
+
const parse_ply_in_batches_1 = require("./lib/parse-ply-in-batches");
|
|
9
|
+
/**
|
|
10
|
+
* Loader for PLY - Polygon File Format
|
|
11
|
+
*/
|
|
12
|
+
exports.PLYLoader = {
|
|
13
|
+
...ply_loader_1.PLYLoader,
|
|
14
|
+
// Note: parsePLY supports both text and binary
|
|
15
|
+
parse: async (arrayBuffer, options) => (0, parse_ply_1.parsePLY)(arrayBuffer, options?.ply),
|
|
16
|
+
parseTextSync: (arrayBuffer, options) => (0, parse_ply_1.parsePLY)(arrayBuffer, options?.ply),
|
|
17
|
+
parseSync: (arrayBuffer, options) => (0, parse_ply_1.parsePLY)(arrayBuffer, options?.ply),
|
|
18
|
+
parseInBatches: (arrayBuffer, options) => (0, parse_ply_in_batches_1.parsePLYInBatches)(arrayBuffer, options?.ply)
|
|
10
19
|
};
|
|
11
|
-
export const _typecheckPLYLoader = PLYLoader;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPLYSchema = void 0;
|
|
4
|
+
const schema_1 = require("@loaders.gl/schema");
|
|
5
|
+
/**
|
|
6
|
+
* Gets schema from PLY header
|
|
7
|
+
* @param plyHeader
|
|
8
|
+
* @param metadata
|
|
9
|
+
* @returns Schema
|
|
10
|
+
*/
|
|
11
|
+
function getPLYSchema(plyHeader, attributes) {
|
|
12
|
+
const metadata = makeMetadataFromPlyHeader(plyHeader);
|
|
13
|
+
const schema = (0, schema_1.deduceMeshSchema)(attributes, metadata);
|
|
14
|
+
return schema;
|
|
6
15
|
}
|
|
7
|
-
|
|
16
|
+
exports.getPLYSchema = getPLYSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Make arrow like schema metadata by PlyHeader properties
|
|
19
|
+
* @param plyHeader
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
8
22
|
function makeMetadataFromPlyHeader(plyHeader) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return metadataMap;
|
|
23
|
+
/* eslint-disable camelcase */
|
|
24
|
+
const metadata = {};
|
|
25
|
+
metadata.ply_comments = JSON.stringify(plyHeader.comments);
|
|
26
|
+
metadata.ply_elements = JSON.stringify(plyHeader.elements);
|
|
27
|
+
if (plyHeader.format !== undefined) {
|
|
28
|
+
metadata.ply_format = plyHeader.format;
|
|
29
|
+
}
|
|
30
|
+
if (plyHeader.version !== undefined) {
|
|
31
|
+
metadata.ply_version = plyHeader.version;
|
|
32
|
+
}
|
|
33
|
+
if (plyHeader.headerLength !== undefined) {
|
|
34
|
+
metadata.ply_headerLength = plyHeader.headerLength.toString(10);
|
|
35
|
+
}
|
|
36
|
+
return metadata;
|
|
26
37
|
}
|
|
27
|
-
//# sourceMappingURL=get-ply-schema.js.map
|
|
@@ -1,69 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
attributes
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_1 = require("@loaders.gl/schema");
|
|
4
|
+
const get_ply_schema_1 = require("./get-ply-schema");
|
|
5
|
+
/**
|
|
6
|
+
* @param header
|
|
7
|
+
* @param attributes
|
|
8
|
+
* @returns data and header
|
|
9
|
+
*/
|
|
10
|
+
function normalizePLY(plyHeader, plyAttributes, options) {
|
|
11
|
+
const attributes = getMeshAttributes(plyAttributes);
|
|
12
|
+
const boundingBox = (0, schema_1.getMeshBoundingBox)(attributes);
|
|
13
|
+
const vertexCount = plyAttributes.indices.length || plyAttributes.vertices.length / 3;
|
|
14
|
+
// TODO - how to detect POINT CLOUDS vs MESHES?
|
|
15
|
+
// TODO - For Meshes, PLY quadrangles must be split?
|
|
16
|
+
const isTriangles = plyAttributes.indices && plyAttributes.indices.length > 0;
|
|
17
|
+
const mode = isTriangles ? 4 : 0; // TRIANGLES vs POINTS
|
|
18
|
+
const topology = isTriangles ? 'triangle-list' : 'point-list';
|
|
19
|
+
const schema = (0, get_ply_schema_1.getPLYSchema)(plyHeader, attributes);
|
|
20
|
+
const plyMesh = {
|
|
21
|
+
loader: 'ply',
|
|
22
|
+
loaderData: plyHeader,
|
|
23
|
+
header: {
|
|
24
|
+
vertexCount,
|
|
25
|
+
boundingBox
|
|
26
|
+
},
|
|
27
|
+
schema,
|
|
28
|
+
attributes,
|
|
29
|
+
indices: { value: new Uint32Array(0), size: 0 },
|
|
30
|
+
mode,
|
|
31
|
+
topology
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (plyAttributes.indices.length > 0) {
|
|
34
|
+
plyMesh.indices = { value: new Uint32Array(plyAttributes.indices), size: 1 };
|
|
35
|
+
}
|
|
36
|
+
return plyMesh;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
exports.default = normalizePLY;
|
|
39
|
+
/**
|
|
40
|
+
* @param attributes
|
|
41
|
+
* @returns accessors []
|
|
42
|
+
*/
|
|
43
|
+
// eslint-disable-next-line complexity
|
|
38
44
|
function getMeshAttributes(attributes) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
const accessors = {};
|
|
46
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
47
|
+
switch (attributeName) {
|
|
48
|
+
case 'vertices':
|
|
49
|
+
if (attributes.vertices.length > 0) {
|
|
50
|
+
accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
// optional attributes data
|
|
54
|
+
case 'normals':
|
|
55
|
+
if (attributes.normals.length > 0) {
|
|
56
|
+
accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'uvs':
|
|
60
|
+
if (attributes.uvs.length > 0) {
|
|
61
|
+
accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'colors':
|
|
65
|
+
if (attributes.colors.length > 0) {
|
|
66
|
+
// TODO - normalized shoud be based on `uchar` flag in source data?
|
|
67
|
+
accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case 'indices':
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
if (attributes[attributeName].length > 0) {
|
|
74
|
+
accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return accessors;
|
|
68
80
|
}
|
|
69
|
-
//# sourceMappingURL=normalize-ply.js.map
|
|
@@ -4,5 +4,5 @@ import { PLYMesh } from './ply-types';
|
|
|
4
4
|
* @param iterator
|
|
5
5
|
* @param options
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export declare function parsePLYInBatches(iterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options: any): AsyncIterable<PLYMesh>;
|
|
8
8
|
//# sourceMappingURL=parse-ply-in-batches.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-ply-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply-in-batches.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"parse-ply-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply-in-batches.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAC,OAAO,EAAoD,MAAM,aAAa,CAAC;AAIvF;;;;GAIG;AACH,wBAAuB,iBAAiB,CACtC,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EAC5D,OAAO,EAAE,GAAG,GACX,aAAa,CAAC,OAAO,CAAC,CAexB"}
|