@loaders.gl/ply 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist.min.js → dist.dev.js} +106 -134
- package/dist/index.cjs +644 -0
- package/dist/{esm/index.js → index.js} +3 -3
- package/dist/index.js.map +1 -0
- package/dist/lib/get-ply-schema.js.map +1 -0
- package/dist/{esm/lib → lib}/normalize-ply.js +1 -1
- package/dist/lib/normalize-ply.js.map +1 -0
- package/dist/{esm/lib → lib}/parse-ply-in-batches.js +1 -1
- package/dist/lib/parse-ply-in-batches.js.map +1 -0
- package/dist/{esm/lib → lib}/parse-ply.js +1 -1
- package/dist/lib/parse-ply.js.map +1 -0
- package/dist/lib/ply-types.js.map +1 -0
- package/dist/{esm/ply-loader.js → ply-loader.js} +1 -1
- package/dist/ply-loader.js.map +1 -0
- package/dist/ply-worker.js +24 -4
- package/dist/{esm/workers → workers}/ply-worker.js +1 -1
- package/dist/workers/ply-worker.js.map +1 -0
- package/package.json +16 -8
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -51
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/get-ply-schema.js +0 -28
- package/dist/es5/lib/get-ply-schema.js.map +0 -1
- package/dist/es5/lib/normalize-ply.js +0 -93
- package/dist/es5/lib/normalize-ply.js.map +0 -1
- package/dist/es5/lib/parse-ply-in-batches.js +0 -289
- package/dist/es5/lib/parse-ply-in-batches.js.map +0 -1
- package/dist/es5/lib/parse-ply.js +0 -348
- package/dist/es5/lib/parse-ply.js.map +0 -1
- package/dist/es5/lib/ply-types.js +0 -2
- package/dist/es5/lib/ply-types.js.map +0 -1
- package/dist/es5/ply-loader.js +0 -24
- package/dist/es5/ply-loader.js.map +0 -1
- package/dist/es5/workers/ply-worker.js +0 -6
- package/dist/es5/workers/ply-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/get-ply-schema.js.map +0 -1
- package/dist/esm/lib/normalize-ply.js.map +0 -1
- package/dist/esm/lib/parse-ply-in-batches.js.map +0 -1
- package/dist/esm/lib/parse-ply.js.map +0 -1
- package/dist/esm/lib/ply-types.js.map +0 -1
- package/dist/esm/ply-loader.js.map +0 -1
- package/dist/esm/workers/ply-worker.js.map +0 -1
- package/src/bundle.ts +0 -4
- /package/dist/{esm/lib → lib}/get-ply-schema.js +0 -0
- /package/dist/{esm/lib → lib}/ply-types.js +0 -0
|
@@ -1,40 +1,54 @@
|
|
|
1
|
-
(()
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['loader'] = factory();
|
|
6
|
+
else root['loader'] = factory();})(globalThis, function () {
|
|
7
|
+
"use strict";
|
|
8
|
+
var __exports__ = (() => {
|
|
2
9
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
13
|
var __export = (target, all) => {
|
|
11
|
-
__markAsModule(target);
|
|
12
14
|
for (var name in all)
|
|
13
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
16
|
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
PLYLoader: () => PLYLoader2,
|
|
31
|
+
PLYWorkerLoader: () => PLYLoader
|
|
32
|
+
});
|
|
15
33
|
|
|
16
34
|
// src/ply-loader.ts
|
|
17
|
-
var VERSION
|
|
18
|
-
var
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
options: {
|
|
33
|
-
ply: {}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
35
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
36
|
+
var PLYLoader = {
|
|
37
|
+
name: "PLY",
|
|
38
|
+
id: "ply",
|
|
39
|
+
module: "ply",
|
|
40
|
+
// shapes: ['mesh', 'gltf', 'columnar-table'],
|
|
41
|
+
version: VERSION,
|
|
42
|
+
worker: true,
|
|
43
|
+
extensions: ["ply"],
|
|
44
|
+
mimeTypes: ["text/plain", "application/octet-stream"],
|
|
45
|
+
text: true,
|
|
46
|
+
binary: true,
|
|
47
|
+
tests: ["ply"],
|
|
48
|
+
options: {
|
|
49
|
+
ply: {}
|
|
36
50
|
}
|
|
37
|
-
}
|
|
51
|
+
};
|
|
38
52
|
|
|
39
53
|
// ../schema/src/lib/table/simple-table/data-type.ts
|
|
40
54
|
function getDataTypeFromTypedArray(array) {
|
|
@@ -60,10 +74,6 @@
|
|
|
60
74
|
return "null";
|
|
61
75
|
}
|
|
62
76
|
}
|
|
63
|
-
var init_data_type = __esm({
|
|
64
|
-
"../schema/src/lib/table/simple-table/data-type.ts"() {
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
77
|
|
|
68
78
|
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
69
79
|
function getMeshBoundingBox(attributes) {
|
|
@@ -86,27 +96,30 @@
|
|
|
86
96
|
maxY = y > maxY ? y : maxY;
|
|
87
97
|
maxZ = z > maxZ ? z : maxZ;
|
|
88
98
|
}
|
|
89
|
-
return [
|
|
90
|
-
[minX, minY, minZ],
|
|
91
|
-
[maxX, maxY, maxZ]
|
|
92
|
-
];
|
|
99
|
+
return [[minX, minY, minZ], [maxX, maxY, maxZ]];
|
|
93
100
|
}
|
|
94
|
-
var init_mesh_utils = __esm({
|
|
95
|
-
"../schema/src/lib/mesh/mesh-utils.ts"() {
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
101
|
|
|
99
102
|
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
100
103
|
function deduceMeshSchema(attributes, metadata = {}) {
|
|
101
104
|
const fields = deduceMeshFields(attributes);
|
|
102
|
-
return {
|
|
105
|
+
return {
|
|
106
|
+
fields,
|
|
107
|
+
metadata
|
|
108
|
+
};
|
|
103
109
|
}
|
|
104
110
|
function deduceMeshField(name, attribute, optionalMetadata) {
|
|
105
111
|
const type = getDataTypeFromTypedArray(attribute.value);
|
|
106
112
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
107
113
|
return {
|
|
108
114
|
name,
|
|
109
|
-
type: {
|
|
115
|
+
type: {
|
|
116
|
+
type: "fixed-size-list",
|
|
117
|
+
listSize: attribute.size,
|
|
118
|
+
children: [{
|
|
119
|
+
name: "value",
|
|
120
|
+
type
|
|
121
|
+
}]
|
|
122
|
+
},
|
|
110
123
|
nullable: false,
|
|
111
124
|
metadata
|
|
112
125
|
};
|
|
@@ -132,19 +145,6 @@
|
|
|
132
145
|
}
|
|
133
146
|
return result;
|
|
134
147
|
}
|
|
135
|
-
var init_deduce_mesh_schema = __esm({
|
|
136
|
-
"../schema/src/lib/mesh/deduce-mesh-schema.ts"() {
|
|
137
|
-
init_data_type();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// ../schema/src/index.ts
|
|
142
|
-
var init_src = __esm({
|
|
143
|
-
"../schema/src/index.ts"() {
|
|
144
|
-
init_mesh_utils();
|
|
145
|
-
init_deduce_mesh_schema();
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
148
|
|
|
149
149
|
// src/lib/get-ply-schema.ts
|
|
150
150
|
function getPLYSchema(plyHeader, attributes) {
|
|
@@ -167,11 +167,6 @@
|
|
|
167
167
|
}
|
|
168
168
|
return metadata;
|
|
169
169
|
}
|
|
170
|
-
var init_get_ply_schema = __esm({
|
|
171
|
-
"src/lib/get-ply-schema.ts"() {
|
|
172
|
-
init_src();
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
170
|
|
|
176
171
|
// src/lib/normalize-ply.ts
|
|
177
172
|
function normalizePLY(plyHeader, plyAttributes, options) {
|
|
@@ -191,12 +186,18 @@
|
|
|
191
186
|
},
|
|
192
187
|
schema,
|
|
193
188
|
attributes,
|
|
194
|
-
indices: {
|
|
189
|
+
indices: {
|
|
190
|
+
value: new Uint32Array(0),
|
|
191
|
+
size: 0
|
|
192
|
+
},
|
|
195
193
|
mode,
|
|
196
194
|
topology
|
|
197
195
|
};
|
|
198
196
|
if (plyAttributes.indices.length > 0) {
|
|
199
|
-
plyMesh.indices = {
|
|
197
|
+
plyMesh.indices = {
|
|
198
|
+
value: new Uint32Array(plyAttributes.indices),
|
|
199
|
+
size: 1
|
|
200
|
+
};
|
|
200
201
|
}
|
|
201
202
|
return plyMesh;
|
|
202
203
|
}
|
|
@@ -206,41 +207,51 @@
|
|
|
206
207
|
switch (attributeName) {
|
|
207
208
|
case "vertices":
|
|
208
209
|
if (attributes.vertices.length > 0) {
|
|
209
|
-
accessors.POSITION = {
|
|
210
|
+
accessors.POSITION = {
|
|
211
|
+
value: new Float32Array(attributes.vertices),
|
|
212
|
+
size: 3
|
|
213
|
+
};
|
|
210
214
|
}
|
|
211
215
|
break;
|
|
212
216
|
case "normals":
|
|
213
217
|
if (attributes.normals.length > 0) {
|
|
214
|
-
accessors.NORMAL = {
|
|
218
|
+
accessors.NORMAL = {
|
|
219
|
+
value: new Float32Array(attributes.normals),
|
|
220
|
+
size: 3
|
|
221
|
+
};
|
|
215
222
|
}
|
|
216
223
|
break;
|
|
217
224
|
case "uvs":
|
|
218
225
|
if (attributes.uvs.length > 0) {
|
|
219
|
-
accessors.TEXCOORD_0 = {
|
|
226
|
+
accessors.TEXCOORD_0 = {
|
|
227
|
+
value: new Float32Array(attributes.uvs),
|
|
228
|
+
size: 2
|
|
229
|
+
};
|
|
220
230
|
}
|
|
221
231
|
break;
|
|
222
232
|
case "colors":
|
|
223
233
|
if (attributes.colors.length > 0) {
|
|
224
|
-
accessors.COLOR_0 = {
|
|
234
|
+
accessors.COLOR_0 = {
|
|
235
|
+
value: new Uint8Array(attributes.colors),
|
|
236
|
+
size: 3,
|
|
237
|
+
normalized: true
|
|
238
|
+
};
|
|
225
239
|
}
|
|
226
240
|
break;
|
|
227
241
|
case "indices":
|
|
228
242
|
break;
|
|
229
243
|
default:
|
|
230
244
|
if (attributes[attributeName].length > 0) {
|
|
231
|
-
accessors[attributeName] = {
|
|
245
|
+
accessors[attributeName] = {
|
|
246
|
+
value: new Float32Array(attributes[attributeName]),
|
|
247
|
+
size: 1
|
|
248
|
+
};
|
|
232
249
|
}
|
|
233
250
|
break;
|
|
234
251
|
}
|
|
235
252
|
}
|
|
236
253
|
return accessors;
|
|
237
254
|
}
|
|
238
|
-
var init_normalize_ply = __esm({
|
|
239
|
-
"src/lib/normalize-ply.ts"() {
|
|
240
|
-
init_src();
|
|
241
|
-
init_get_ply_schema();
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
255
|
|
|
245
256
|
// src/lib/parse-ply.ts
|
|
246
257
|
function parsePLY(data, options = {}) {
|
|
@@ -558,17 +569,14 @@
|
|
|
558
569
|
}
|
|
559
570
|
return attributes;
|
|
560
571
|
}
|
|
561
|
-
var init_parse_ply = __esm({
|
|
562
|
-
"src/lib/parse-ply.ts"() {
|
|
563
|
-
init_normalize_ply();
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
572
|
|
|
567
573
|
// ../loader-utils/src/lib/iterators/text-iterators.ts
|
|
568
574
|
async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
|
|
569
575
|
const textDecoder = new TextDecoder(void 0, options);
|
|
570
576
|
for await (const arrayBuffer of arrayBufferIterator) {
|
|
571
|
-
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
577
|
+
yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, {
|
|
578
|
+
stream: true
|
|
579
|
+
});
|
|
572
580
|
}
|
|
573
581
|
}
|
|
574
582
|
async function* makeLineIterator(textIterator) {
|
|
@@ -586,15 +594,14 @@
|
|
|
586
594
|
yield previous;
|
|
587
595
|
}
|
|
588
596
|
}
|
|
589
|
-
var init_text_iterators = __esm({
|
|
590
|
-
"../loader-utils/src/lib/iterators/text-iterators.ts"() {
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
597
|
|
|
594
598
|
// ../loader-utils/src/lib/iterators/async-iteration.ts
|
|
595
599
|
async function forEach(iterator, visitor) {
|
|
596
600
|
while (true) {
|
|
597
|
-
const {
|
|
601
|
+
const {
|
|
602
|
+
done,
|
|
603
|
+
value
|
|
604
|
+
} = await iterator.next();
|
|
598
605
|
if (done) {
|
|
599
606
|
iterator.return();
|
|
600
607
|
return;
|
|
@@ -605,20 +612,9 @@
|
|
|
605
612
|
}
|
|
606
613
|
}
|
|
607
614
|
}
|
|
608
|
-
var init_async_iteration = __esm({
|
|
609
|
-
"../loader-utils/src/lib/iterators/async-iteration.ts"() {
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
// ../loader-utils/src/index.ts
|
|
614
|
-
var init_src2 = __esm({
|
|
615
|
-
"../loader-utils/src/index.ts"() {
|
|
616
|
-
init_text_iterators();
|
|
617
|
-
init_async_iteration();
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
615
|
|
|
621
616
|
// src/lib/parse-ply-in-batches.ts
|
|
617
|
+
var currentElement;
|
|
622
618
|
async function* parsePLYInBatches(iterator, options) {
|
|
623
619
|
const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));
|
|
624
620
|
const header = await parsePLYHeader(lineIterator, options);
|
|
@@ -636,6 +632,7 @@
|
|
|
636
632
|
const header = {
|
|
637
633
|
comments: [],
|
|
638
634
|
elements: []
|
|
635
|
+
// headerLength
|
|
639
636
|
};
|
|
640
637
|
await forEach(lineIterator, (line) => {
|
|
641
638
|
line = line.trim();
|
|
@@ -791,43 +788,18 @@
|
|
|
791
788
|
break;
|
|
792
789
|
}
|
|
793
790
|
}
|
|
794
|
-
var currentElement;
|
|
795
|
-
var init_parse_ply_in_batches = __esm({
|
|
796
|
-
"src/lib/parse-ply-in-batches.ts"() {
|
|
797
|
-
init_src2();
|
|
798
|
-
init_normalize_ply();
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
791
|
|
|
802
792
|
// src/index.ts
|
|
803
|
-
var
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
init_parse_ply_in_batches();
|
|
814
|
-
PLYLoader2 = {
|
|
815
|
-
...PLYLoader,
|
|
816
|
-
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
817
|
-
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
818
|
-
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
819
|
-
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
// src/bundle.ts
|
|
825
|
-
var require_bundle = __commonJS({
|
|
826
|
-
"src/bundle.ts"(exports, module) {
|
|
827
|
-
var moduleExports = (init_src3(), src_exports);
|
|
828
|
-
globalThis.loaders = globalThis.loaders || {};
|
|
829
|
-
module.exports = Object.assign(globalThis.loaders, moduleExports);
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
require_bundle();
|
|
793
|
+
var PLYLoader2 = {
|
|
794
|
+
...PLYLoader,
|
|
795
|
+
// Note: parsePLY supports both text and binary
|
|
796
|
+
parse: async (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
797
|
+
// TODO - this may not detect text correctly?
|
|
798
|
+
parseTextSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
799
|
+
parseSync: (arrayBuffer, options) => parsePLY(arrayBuffer, options?.ply),
|
|
800
|
+
parseInBatches: (arrayBuffer, options) => parsePLYInBatches(arrayBuffer, options?.ply)
|
|
801
|
+
};
|
|
802
|
+
return __toCommonJS(src_exports);
|
|
833
803
|
})();
|
|
804
|
+
return __exports__;
|
|
805
|
+
});
|