@loaders.gl/obj 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 +97 -549
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +74 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/get-obj-schema.js +54 -0
- package/dist/es5/lib/get-obj-schema.js.map +1 -0
- package/dist/es5/lib/obj-types.js +2 -0
- package/dist/es5/lib/obj-types.js.map +1 -0
- package/dist/es5/lib/parse-mtl.js +86 -0
- package/dist/es5/lib/parse-mtl.js.map +1 -0
- package/dist/es5/lib/parse-obj-meshes.js +486 -0
- package/dist/es5/lib/parse-obj-meshes.js.map +1 -0
- package/dist/es5/lib/parse-obj.js +100 -0
- package/dist/es5/lib/parse-obj.js.map +1 -0
- package/dist/es5/mtl-loader.js +26 -0
- package/dist/es5/mtl-loader.js.map +1 -0
- package/dist/es5/obj-loader.js +27 -0
- package/dist/es5/obj-loader.js.map +1 -0
- package/dist/es5/workers/obj-worker.js +6 -0
- package/dist/es5/workers/obj-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 +18 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/get-obj-schema.js +49 -0
- package/dist/esm/lib/get-obj-schema.js.map +1 -0
- package/dist/esm/lib/obj-types.js +2 -0
- package/dist/esm/lib/obj-types.js.map +1 -0
- package/dist/esm/lib/parse-mtl.js +68 -0
- package/dist/esm/lib/parse-mtl.js.map +1 -0
- package/dist/esm/lib/parse-obj-meshes.js +385 -0
- package/dist/esm/lib/parse-obj-meshes.js.map +1 -0
- package/dist/esm/lib/parse-obj.js +82 -0
- package/dist/esm/lib/parse-obj.js.map +1 -0
- package/dist/esm/mtl-loader.js +16 -0
- package/dist/esm/mtl-loader.js.map +1 -0
- package/dist/esm/obj-loader.js +19 -0
- package/dist/esm/obj-loader.js.map +1 -0
- package/dist/esm/workers/obj-worker.js +4 -0
- package/dist/esm/workers/obj-worker.js.map +1 -0
- package/dist/index.d.ts +4 -58
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -14
- package/dist/lib/get-obj-schema.d.ts +3 -2
- package/dist/lib/get-obj-schema.d.ts.map +1 -1
- package/dist/lib/get-obj-schema.js +33 -33
- package/dist/lib/obj-types.js +1 -2
- package/dist/lib/parse-mtl.d.ts +2 -2
- package/dist/lib/parse-mtl.d.ts.map +1 -1
- package/dist/lib/parse-mtl.js +185 -70
- package/dist/lib/parse-obj-meshes.js +408 -426
- package/dist/lib/parse-obj.d.ts +2 -13
- package/dist/lib/parse-obj.d.ts.map +1 -1
- package/dist/lib/parse-obj.js +66 -86
- package/dist/mtl-loader.d.ts +3 -15
- package/dist/mtl-loader.d.ts.map +1 -1
- package/dist/mtl-loader.js +23 -15
- package/dist/obj-loader.d.ts +3 -16
- package/dist/obj-loader.d.ts.map +1 -1
- package/dist/obj-loader.js +24 -18
- package/dist/obj-worker.js +133 -517
- package/dist/workers/obj-worker.js +5 -4
- package/package.json +6 -6
- package/src/index.ts +6 -3
- package/src/lib/get-obj-schema.ts +24 -20
- package/src/lib/parse-obj.ts +4 -3
- package/src/mtl-loader.ts +2 -2
- package/src/obj-loader.ts +2 -1
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/get-obj-schema.js.map +0 -1
- package/dist/lib/obj-types.js.map +0 -1
- package/dist/lib/parse-mtl.js.map +0 -1
- package/dist/lib/parse-obj-meshes.js.map +0 -1
- package/dist/lib/parse-obj.js.map +0 -1
- package/dist/mtl-loader.js.map +0 -1
- package/dist/obj-loader.js.map +0 -1
- package/dist/workers/obj-worker.js.map +0 -1
package/dist/obj-worker.js
CHANGED
|
@@ -35,16 +35,33 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
function getParentPort() {
|
|
39
|
+
let parentPort;
|
|
40
|
+
try {
|
|
41
|
+
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
42
|
+
parentPort = globalThis.parentPort;
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
return parentPort;
|
|
46
|
+
}
|
|
38
47
|
var onMessageWrapperMap = new Map();
|
|
39
48
|
var WorkerBody = class {
|
|
49
|
+
static inWorkerThread() {
|
|
50
|
+
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
51
|
+
}
|
|
40
52
|
static set onmessage(onMessage) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const { type, payload } = message.data;
|
|
53
|
+
function handleMessage(message) {
|
|
54
|
+
const parentPort3 = getParentPort();
|
|
55
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
46
56
|
onMessage(type, payload);
|
|
47
|
-
}
|
|
57
|
+
}
|
|
58
|
+
const parentPort2 = getParentPort();
|
|
59
|
+
if (parentPort2) {
|
|
60
|
+
parentPort2.on("message", handleMessage);
|
|
61
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
62
|
+
} else {
|
|
63
|
+
globalThis.onmessage = handleMessage;
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
static addEventListener(onMessage) {
|
|
50
67
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
@@ -53,22 +70,36 @@
|
|
|
53
70
|
if (!isKnownMessage(message)) {
|
|
54
71
|
return;
|
|
55
72
|
}
|
|
56
|
-
const
|
|
73
|
+
const parentPort3 = getParentPort();
|
|
74
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
57
75
|
onMessage(type, payload);
|
|
58
76
|
};
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
const parentPort2 = getParentPort();
|
|
79
|
+
if (parentPort2) {
|
|
80
|
+
console.error("not implemented");
|
|
81
|
+
} else {
|
|
82
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
static removeEventListener(onMessage) {
|
|
63
86
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
87
|
onMessageWrapperMap.delete(onMessage);
|
|
65
|
-
|
|
88
|
+
const parentPort2 = getParentPort();
|
|
89
|
+
if (parentPort2) {
|
|
90
|
+
console.error("not implemented");
|
|
91
|
+
} else {
|
|
92
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
static postMessage(type, payload) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
const data = { source: "loaders.gl", type, payload };
|
|
97
|
+
const transferList = getTransferList(payload);
|
|
98
|
+
const parentPort2 = getParentPort();
|
|
99
|
+
if (parentPort2) {
|
|
100
|
+
parentPort2.postMessage(data, transferList);
|
|
101
|
+
} else {
|
|
102
|
+
globalThis.postMessage(data, transferList);
|
|
72
103
|
}
|
|
73
104
|
}
|
|
74
105
|
};
|
|
@@ -80,19 +111,20 @@
|
|
|
80
111
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
112
|
var requestId = 0;
|
|
82
113
|
function createLoaderWorker(loader) {
|
|
83
|
-
if (
|
|
114
|
+
if (!WorkerBody.inWorkerThread()) {
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
86
117
|
WorkerBody.onmessage = async (type, payload) => {
|
|
87
118
|
switch (type) {
|
|
88
119
|
case "process":
|
|
89
120
|
try {
|
|
90
|
-
const { input, options = {} } = payload;
|
|
121
|
+
const { input, options = {}, context = {} } = payload;
|
|
91
122
|
const result = await parseData({
|
|
92
123
|
loader,
|
|
93
124
|
arrayBuffer: input,
|
|
94
125
|
options,
|
|
95
126
|
context: {
|
|
127
|
+
...context,
|
|
96
128
|
parse: parseOnMainThread
|
|
97
129
|
}
|
|
98
130
|
});
|
|
@@ -151,7 +183,58 @@
|
|
|
151
183
|
return await parser(data, { ...options }, context, loader);
|
|
152
184
|
}
|
|
153
185
|
|
|
154
|
-
// ../schema/src/
|
|
186
|
+
// ../schema/src/lib/table/simple-table/data-type.ts
|
|
187
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
188
|
+
if (value instanceof Date) {
|
|
189
|
+
return "date-millisecond";
|
|
190
|
+
}
|
|
191
|
+
if (value instanceof Number) {
|
|
192
|
+
return defaultNumberType;
|
|
193
|
+
}
|
|
194
|
+
if (typeof value === "string") {
|
|
195
|
+
return "utf8";
|
|
196
|
+
}
|
|
197
|
+
if (value === null || value === "undefined") {
|
|
198
|
+
return "null";
|
|
199
|
+
}
|
|
200
|
+
return "null";
|
|
201
|
+
}
|
|
202
|
+
function getDataTypeFromArray(array) {
|
|
203
|
+
let type = getDataTypeFromTypedArray(array);
|
|
204
|
+
if (type !== "null") {
|
|
205
|
+
return { type, nullable: false };
|
|
206
|
+
}
|
|
207
|
+
if (array.length > 0) {
|
|
208
|
+
type = getDataTypeFromValue(array[0]);
|
|
209
|
+
return { type, nullable: true };
|
|
210
|
+
}
|
|
211
|
+
return { type: "null", nullable: true };
|
|
212
|
+
}
|
|
213
|
+
function getDataTypeFromTypedArray(array) {
|
|
214
|
+
switch (array.constructor) {
|
|
215
|
+
case Int8Array:
|
|
216
|
+
return "int8";
|
|
217
|
+
case Uint8Array:
|
|
218
|
+
case Uint8ClampedArray:
|
|
219
|
+
return "uint8";
|
|
220
|
+
case Int16Array:
|
|
221
|
+
return "int16";
|
|
222
|
+
case Uint16Array:
|
|
223
|
+
return "uint16";
|
|
224
|
+
case Int32Array:
|
|
225
|
+
return "int32";
|
|
226
|
+
case Uint32Array:
|
|
227
|
+
return "uint32";
|
|
228
|
+
case Float32Array:
|
|
229
|
+
return "float32";
|
|
230
|
+
case Float64Array:
|
|
231
|
+
return "float64";
|
|
232
|
+
default:
|
|
233
|
+
return "null";
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
155
238
|
function getMeshBoundingBox(attributes) {
|
|
156
239
|
let minX = Infinity;
|
|
157
240
|
let minY = Infinity;
|
|
@@ -178,476 +261,6 @@
|
|
|
178
261
|
];
|
|
179
262
|
}
|
|
180
263
|
|
|
181
|
-
// ../schema/src/lib/utils/assert.ts
|
|
182
|
-
function assert(condition, message) {
|
|
183
|
-
if (!condition) {
|
|
184
|
-
throw new Error(message || "loader assertion failed.");
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// ../schema/src/lib/schema/impl/schema.ts
|
|
189
|
-
var Schema = class {
|
|
190
|
-
constructor(fields, metadata) {
|
|
191
|
-
assert(Array.isArray(fields));
|
|
192
|
-
checkNames(fields);
|
|
193
|
-
this.fields = fields;
|
|
194
|
-
this.metadata = metadata || new Map();
|
|
195
|
-
}
|
|
196
|
-
compareTo(other) {
|
|
197
|
-
if (this.metadata !== other.metadata) {
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
if (this.fields.length !== other.fields.length) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
for (let i = 0; i < this.fields.length; ++i) {
|
|
204
|
-
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
select(...columnNames) {
|
|
211
|
-
const nameMap = Object.create(null);
|
|
212
|
-
for (const name of columnNames) {
|
|
213
|
-
nameMap[name] = true;
|
|
214
|
-
}
|
|
215
|
-
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
216
|
-
return new Schema(selectedFields, this.metadata);
|
|
217
|
-
}
|
|
218
|
-
selectAt(...columnIndices) {
|
|
219
|
-
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
220
|
-
return new Schema(selectedFields, this.metadata);
|
|
221
|
-
}
|
|
222
|
-
assign(schemaOrFields) {
|
|
223
|
-
let fields;
|
|
224
|
-
let metadata = this.metadata;
|
|
225
|
-
if (schemaOrFields instanceof Schema) {
|
|
226
|
-
const otherSchema = schemaOrFields;
|
|
227
|
-
fields = otherSchema.fields;
|
|
228
|
-
metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
|
|
229
|
-
} else {
|
|
230
|
-
fields = schemaOrFields;
|
|
231
|
-
}
|
|
232
|
-
const fieldMap = Object.create(null);
|
|
233
|
-
for (const field of this.fields) {
|
|
234
|
-
fieldMap[field.name] = field;
|
|
235
|
-
}
|
|
236
|
-
for (const field of fields) {
|
|
237
|
-
fieldMap[field.name] = field;
|
|
238
|
-
}
|
|
239
|
-
const mergedFields = Object.values(fieldMap);
|
|
240
|
-
return new Schema(mergedFields, metadata);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
function checkNames(fields) {
|
|
244
|
-
const usedNames = {};
|
|
245
|
-
for (const field of fields) {
|
|
246
|
-
if (usedNames[field.name]) {
|
|
247
|
-
console.warn("Schema: duplicated field name", field.name, field);
|
|
248
|
-
}
|
|
249
|
-
usedNames[field.name] = true;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
function mergeMaps(m1, m2) {
|
|
253
|
-
return new Map([...m1 || new Map(), ...m2 || new Map()]);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ../schema/src/lib/schema/impl/field.ts
|
|
257
|
-
var Field = class {
|
|
258
|
-
constructor(name, type, nullable = false, metadata = new Map()) {
|
|
259
|
-
this.name = name;
|
|
260
|
-
this.type = type;
|
|
261
|
-
this.nullable = nullable;
|
|
262
|
-
this.metadata = metadata;
|
|
263
|
-
}
|
|
264
|
-
get typeId() {
|
|
265
|
-
return this.type && this.type.typeId;
|
|
266
|
-
}
|
|
267
|
-
clone() {
|
|
268
|
-
return new Field(this.name, this.type, this.nullable, this.metadata);
|
|
269
|
-
}
|
|
270
|
-
compareTo(other) {
|
|
271
|
-
return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
|
|
272
|
-
}
|
|
273
|
-
toString() {
|
|
274
|
-
return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// ../schema/src/lib/schema/impl/enum.ts
|
|
279
|
-
var Type;
|
|
280
|
-
(function(Type2) {
|
|
281
|
-
Type2[Type2["NONE"] = 0] = "NONE";
|
|
282
|
-
Type2[Type2["Null"] = 1] = "Null";
|
|
283
|
-
Type2[Type2["Int"] = 2] = "Int";
|
|
284
|
-
Type2[Type2["Float"] = 3] = "Float";
|
|
285
|
-
Type2[Type2["Binary"] = 4] = "Binary";
|
|
286
|
-
Type2[Type2["Utf8"] = 5] = "Utf8";
|
|
287
|
-
Type2[Type2["Bool"] = 6] = "Bool";
|
|
288
|
-
Type2[Type2["Decimal"] = 7] = "Decimal";
|
|
289
|
-
Type2[Type2["Date"] = 8] = "Date";
|
|
290
|
-
Type2[Type2["Time"] = 9] = "Time";
|
|
291
|
-
Type2[Type2["Timestamp"] = 10] = "Timestamp";
|
|
292
|
-
Type2[Type2["Interval"] = 11] = "Interval";
|
|
293
|
-
Type2[Type2["List"] = 12] = "List";
|
|
294
|
-
Type2[Type2["Struct"] = 13] = "Struct";
|
|
295
|
-
Type2[Type2["Union"] = 14] = "Union";
|
|
296
|
-
Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
|
|
297
|
-
Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
|
|
298
|
-
Type2[Type2["Map"] = 17] = "Map";
|
|
299
|
-
Type2[Type2["Dictionary"] = -1] = "Dictionary";
|
|
300
|
-
Type2[Type2["Int8"] = -2] = "Int8";
|
|
301
|
-
Type2[Type2["Int16"] = -3] = "Int16";
|
|
302
|
-
Type2[Type2["Int32"] = -4] = "Int32";
|
|
303
|
-
Type2[Type2["Int64"] = -5] = "Int64";
|
|
304
|
-
Type2[Type2["Uint8"] = -6] = "Uint8";
|
|
305
|
-
Type2[Type2["Uint16"] = -7] = "Uint16";
|
|
306
|
-
Type2[Type2["Uint32"] = -8] = "Uint32";
|
|
307
|
-
Type2[Type2["Uint64"] = -9] = "Uint64";
|
|
308
|
-
Type2[Type2["Float16"] = -10] = "Float16";
|
|
309
|
-
Type2[Type2["Float32"] = -11] = "Float32";
|
|
310
|
-
Type2[Type2["Float64"] = -12] = "Float64";
|
|
311
|
-
Type2[Type2["DateDay"] = -13] = "DateDay";
|
|
312
|
-
Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
|
|
313
|
-
Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
|
|
314
|
-
Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
|
|
315
|
-
Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
|
|
316
|
-
Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
|
|
317
|
-
Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
|
|
318
|
-
Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
|
|
319
|
-
Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
|
|
320
|
-
Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
|
|
321
|
-
Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
|
|
322
|
-
Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
|
|
323
|
-
Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
|
|
324
|
-
Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
|
|
325
|
-
})(Type || (Type = {}));
|
|
326
|
-
|
|
327
|
-
// ../schema/src/lib/schema/impl/type.ts
|
|
328
|
-
var DataType = class {
|
|
329
|
-
static isNull(x) {
|
|
330
|
-
return x && x.typeId === Type.Null;
|
|
331
|
-
}
|
|
332
|
-
static isInt(x) {
|
|
333
|
-
return x && x.typeId === Type.Int;
|
|
334
|
-
}
|
|
335
|
-
static isFloat(x) {
|
|
336
|
-
return x && x.typeId === Type.Float;
|
|
337
|
-
}
|
|
338
|
-
static isBinary(x) {
|
|
339
|
-
return x && x.typeId === Type.Binary;
|
|
340
|
-
}
|
|
341
|
-
static isUtf8(x) {
|
|
342
|
-
return x && x.typeId === Type.Utf8;
|
|
343
|
-
}
|
|
344
|
-
static isBool(x) {
|
|
345
|
-
return x && x.typeId === Type.Bool;
|
|
346
|
-
}
|
|
347
|
-
static isDecimal(x) {
|
|
348
|
-
return x && x.typeId === Type.Decimal;
|
|
349
|
-
}
|
|
350
|
-
static isDate(x) {
|
|
351
|
-
return x && x.typeId === Type.Date;
|
|
352
|
-
}
|
|
353
|
-
static isTime(x) {
|
|
354
|
-
return x && x.typeId === Type.Time;
|
|
355
|
-
}
|
|
356
|
-
static isTimestamp(x) {
|
|
357
|
-
return x && x.typeId === Type.Timestamp;
|
|
358
|
-
}
|
|
359
|
-
static isInterval(x) {
|
|
360
|
-
return x && x.typeId === Type.Interval;
|
|
361
|
-
}
|
|
362
|
-
static isList(x) {
|
|
363
|
-
return x && x.typeId === Type.List;
|
|
364
|
-
}
|
|
365
|
-
static isStruct(x) {
|
|
366
|
-
return x && x.typeId === Type.Struct;
|
|
367
|
-
}
|
|
368
|
-
static isUnion(x) {
|
|
369
|
-
return x && x.typeId === Type.Union;
|
|
370
|
-
}
|
|
371
|
-
static isFixedSizeBinary(x) {
|
|
372
|
-
return x && x.typeId === Type.FixedSizeBinary;
|
|
373
|
-
}
|
|
374
|
-
static isFixedSizeList(x) {
|
|
375
|
-
return x && x.typeId === Type.FixedSizeList;
|
|
376
|
-
}
|
|
377
|
-
static isMap(x) {
|
|
378
|
-
return x && x.typeId === Type.Map;
|
|
379
|
-
}
|
|
380
|
-
static isDictionary(x) {
|
|
381
|
-
return x && x.typeId === Type.Dictionary;
|
|
382
|
-
}
|
|
383
|
-
get typeId() {
|
|
384
|
-
return Type.NONE;
|
|
385
|
-
}
|
|
386
|
-
compareTo(other) {
|
|
387
|
-
return this === other;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
var Null = class extends DataType {
|
|
391
|
-
get typeId() {
|
|
392
|
-
return Type.Null;
|
|
393
|
-
}
|
|
394
|
-
get [Symbol.toStringTag]() {
|
|
395
|
-
return "Null";
|
|
396
|
-
}
|
|
397
|
-
toString() {
|
|
398
|
-
return "Null";
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
var Bool = class extends DataType {
|
|
402
|
-
get typeId() {
|
|
403
|
-
return Type.Bool;
|
|
404
|
-
}
|
|
405
|
-
get [Symbol.toStringTag]() {
|
|
406
|
-
return "Bool";
|
|
407
|
-
}
|
|
408
|
-
toString() {
|
|
409
|
-
return "Bool";
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
var Int = class extends DataType {
|
|
413
|
-
constructor(isSigned, bitWidth) {
|
|
414
|
-
super();
|
|
415
|
-
this.isSigned = isSigned;
|
|
416
|
-
this.bitWidth = bitWidth;
|
|
417
|
-
}
|
|
418
|
-
get typeId() {
|
|
419
|
-
return Type.Int;
|
|
420
|
-
}
|
|
421
|
-
get [Symbol.toStringTag]() {
|
|
422
|
-
return "Int";
|
|
423
|
-
}
|
|
424
|
-
toString() {
|
|
425
|
-
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
var Int8 = class extends Int {
|
|
429
|
-
constructor() {
|
|
430
|
-
super(true, 8);
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
var Int16 = class extends Int {
|
|
434
|
-
constructor() {
|
|
435
|
-
super(true, 16);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
var Int32 = class extends Int {
|
|
439
|
-
constructor() {
|
|
440
|
-
super(true, 32);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var Uint8 = class extends Int {
|
|
444
|
-
constructor() {
|
|
445
|
-
super(false, 8);
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
var Uint16 = class extends Int {
|
|
449
|
-
constructor() {
|
|
450
|
-
super(false, 16);
|
|
451
|
-
}
|
|
452
|
-
};
|
|
453
|
-
var Uint32 = class extends Int {
|
|
454
|
-
constructor() {
|
|
455
|
-
super(false, 32);
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
var Precision = {
|
|
459
|
-
HALF: 16,
|
|
460
|
-
SINGLE: 32,
|
|
461
|
-
DOUBLE: 64
|
|
462
|
-
};
|
|
463
|
-
var Float = class extends DataType {
|
|
464
|
-
constructor(precision) {
|
|
465
|
-
super();
|
|
466
|
-
this.precision = precision;
|
|
467
|
-
}
|
|
468
|
-
get typeId() {
|
|
469
|
-
return Type.Float;
|
|
470
|
-
}
|
|
471
|
-
get [Symbol.toStringTag]() {
|
|
472
|
-
return "Float";
|
|
473
|
-
}
|
|
474
|
-
toString() {
|
|
475
|
-
return `Float${this.precision}`;
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
var Float32 = class extends Float {
|
|
479
|
-
constructor() {
|
|
480
|
-
super(Precision.SINGLE);
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
var Float64 = class extends Float {
|
|
484
|
-
constructor() {
|
|
485
|
-
super(Precision.DOUBLE);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
var Binary = class extends DataType {
|
|
489
|
-
constructor() {
|
|
490
|
-
super();
|
|
491
|
-
}
|
|
492
|
-
get typeId() {
|
|
493
|
-
return Type.Binary;
|
|
494
|
-
}
|
|
495
|
-
toString() {
|
|
496
|
-
return "Binary";
|
|
497
|
-
}
|
|
498
|
-
get [Symbol.toStringTag]() {
|
|
499
|
-
return "Binary";
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
var Utf8 = class extends DataType {
|
|
503
|
-
get typeId() {
|
|
504
|
-
return Type.Utf8;
|
|
505
|
-
}
|
|
506
|
-
get [Symbol.toStringTag]() {
|
|
507
|
-
return "Utf8";
|
|
508
|
-
}
|
|
509
|
-
toString() {
|
|
510
|
-
return "Utf8";
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
var DateUnit = {
|
|
514
|
-
DAY: 0,
|
|
515
|
-
MILLISECOND: 1
|
|
516
|
-
};
|
|
517
|
-
var Date = class extends DataType {
|
|
518
|
-
constructor(unit) {
|
|
519
|
-
super();
|
|
520
|
-
this.unit = unit;
|
|
521
|
-
}
|
|
522
|
-
get typeId() {
|
|
523
|
-
return Type.Date;
|
|
524
|
-
}
|
|
525
|
-
get [Symbol.toStringTag]() {
|
|
526
|
-
return "Date";
|
|
527
|
-
}
|
|
528
|
-
toString() {
|
|
529
|
-
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
var TimeUnit = {
|
|
533
|
-
SECOND: 1,
|
|
534
|
-
MILLISECOND: 1e3,
|
|
535
|
-
MICROSECOND: 1e6,
|
|
536
|
-
NANOSECOND: 1e9
|
|
537
|
-
};
|
|
538
|
-
var Time = class extends DataType {
|
|
539
|
-
constructor(unit, bitWidth) {
|
|
540
|
-
super();
|
|
541
|
-
this.unit = unit;
|
|
542
|
-
this.bitWidth = bitWidth;
|
|
543
|
-
}
|
|
544
|
-
get typeId() {
|
|
545
|
-
return Type.Time;
|
|
546
|
-
}
|
|
547
|
-
toString() {
|
|
548
|
-
return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
|
|
549
|
-
}
|
|
550
|
-
get [Symbol.toStringTag]() {
|
|
551
|
-
return "Time";
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
var Timestamp = class extends DataType {
|
|
555
|
-
constructor(unit, timezone = null) {
|
|
556
|
-
super();
|
|
557
|
-
this.unit = unit;
|
|
558
|
-
this.timezone = timezone;
|
|
559
|
-
}
|
|
560
|
-
get typeId() {
|
|
561
|
-
return Type.Timestamp;
|
|
562
|
-
}
|
|
563
|
-
get [Symbol.toStringTag]() {
|
|
564
|
-
return "Timestamp";
|
|
565
|
-
}
|
|
566
|
-
toString() {
|
|
567
|
-
return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
var IntervalUnit = {
|
|
571
|
-
DAY_TIME: 0,
|
|
572
|
-
YEAR_MONTH: 1
|
|
573
|
-
};
|
|
574
|
-
var Interval = class extends DataType {
|
|
575
|
-
constructor(unit) {
|
|
576
|
-
super();
|
|
577
|
-
this.unit = unit;
|
|
578
|
-
}
|
|
579
|
-
get typeId() {
|
|
580
|
-
return Type.Interval;
|
|
581
|
-
}
|
|
582
|
-
get [Symbol.toStringTag]() {
|
|
583
|
-
return "Interval";
|
|
584
|
-
}
|
|
585
|
-
toString() {
|
|
586
|
-
return `Interval<${IntervalUnit[this.unit]}>`;
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
var FixedSizeList = class extends DataType {
|
|
590
|
-
constructor(listSize, child) {
|
|
591
|
-
super();
|
|
592
|
-
this.listSize = listSize;
|
|
593
|
-
this.children = [child];
|
|
594
|
-
}
|
|
595
|
-
get typeId() {
|
|
596
|
-
return Type.FixedSizeList;
|
|
597
|
-
}
|
|
598
|
-
get valueType() {
|
|
599
|
-
return this.children[0].type;
|
|
600
|
-
}
|
|
601
|
-
get valueField() {
|
|
602
|
-
return this.children[0];
|
|
603
|
-
}
|
|
604
|
-
get [Symbol.toStringTag]() {
|
|
605
|
-
return "FixedSizeList";
|
|
606
|
-
}
|
|
607
|
-
toString() {
|
|
608
|
-
return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
var Struct = class extends DataType {
|
|
612
|
-
constructor(children) {
|
|
613
|
-
super();
|
|
614
|
-
this.children = children;
|
|
615
|
-
}
|
|
616
|
-
get typeId() {
|
|
617
|
-
return Type.Struct;
|
|
618
|
-
}
|
|
619
|
-
toString() {
|
|
620
|
-
return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
|
|
621
|
-
}
|
|
622
|
-
get [Symbol.toStringTag]() {
|
|
623
|
-
return "Struct";
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
// ../schema/src/lib/arrow/arrow-like-type-utils.ts
|
|
628
|
-
function getArrowTypeFromTypedArray(array) {
|
|
629
|
-
switch (array.constructor) {
|
|
630
|
-
case Int8Array:
|
|
631
|
-
return new Int8();
|
|
632
|
-
case Uint8Array:
|
|
633
|
-
return new Uint8();
|
|
634
|
-
case Int16Array:
|
|
635
|
-
return new Int16();
|
|
636
|
-
case Uint16Array:
|
|
637
|
-
return new Uint16();
|
|
638
|
-
case Int32Array:
|
|
639
|
-
return new Int32();
|
|
640
|
-
case Uint32Array:
|
|
641
|
-
return new Uint32();
|
|
642
|
-
case Float32Array:
|
|
643
|
-
return new Float32();
|
|
644
|
-
case Float64Array:
|
|
645
|
-
return new Float64();
|
|
646
|
-
default:
|
|
647
|
-
throw new Error("array type not supported");
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
264
|
// src/lib/parse-obj-meshes.ts
|
|
652
265
|
var OBJECT_RE = /^[og]\s*(.+)?/;
|
|
653
266
|
var MATERIAL_RE = /^mtllib /;
|
|
@@ -1016,31 +629,33 @@
|
|
|
1016
629
|
|
|
1017
630
|
// src/lib/get-obj-schema.ts
|
|
1018
631
|
function getOBJSchema(attributes, metadata = {}) {
|
|
1019
|
-
|
|
632
|
+
const stringMetadata = {};
|
|
1020
633
|
for (const key in metadata) {
|
|
1021
|
-
metadataMap = metadataMap || new Map();
|
|
1022
634
|
if (key !== "value") {
|
|
1023
|
-
|
|
635
|
+
stringMetadata[key] = JSON.stringify(metadata[key]);
|
|
1024
636
|
}
|
|
1025
637
|
}
|
|
1026
638
|
const fields = [];
|
|
1027
639
|
for (const attributeName in attributes) {
|
|
1028
640
|
const attribute = attributes[attributeName];
|
|
1029
|
-
const field =
|
|
641
|
+
const field = getFieldFromAttribute(attributeName, attribute);
|
|
1030
642
|
fields.push(field);
|
|
1031
643
|
}
|
|
1032
|
-
return
|
|
644
|
+
return { fields, metadata: stringMetadata };
|
|
1033
645
|
}
|
|
1034
|
-
function
|
|
1035
|
-
const
|
|
646
|
+
function getFieldFromAttribute(name, attribute) {
|
|
647
|
+
const metadata = {};
|
|
1036
648
|
for (const key in attribute) {
|
|
1037
649
|
if (key !== "value") {
|
|
1038
|
-
|
|
650
|
+
metadata[key] = JSON.stringify(attribute[key]);
|
|
1039
651
|
}
|
|
1040
652
|
}
|
|
1041
|
-
|
|
1042
|
-
const isSingleValue =
|
|
1043
|
-
|
|
653
|
+
let { type } = getDataTypeFromArray(attribute.value);
|
|
654
|
+
const isSingleValue = attribute.size === 1 || attribute.size === void 0;
|
|
655
|
+
if (!isSingleValue) {
|
|
656
|
+
type = { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "values", type }] };
|
|
657
|
+
}
|
|
658
|
+
return { name, type, nullable: false, metadata };
|
|
1044
659
|
}
|
|
1045
660
|
|
|
1046
661
|
// src/lib/parse-obj.ts
|
|
@@ -1063,6 +678,7 @@
|
|
|
1063
678
|
schema,
|
|
1064
679
|
header,
|
|
1065
680
|
mode: 4,
|
|
681
|
+
topology: "point-list",
|
|
1066
682
|
attributes
|
|
1067
683
|
};
|
|
1068
684
|
}
|
|
@@ -1103,6 +719,25 @@
|
|
|
1103
719
|
return attributes;
|
|
1104
720
|
}
|
|
1105
721
|
|
|
722
|
+
// src/obj-loader.ts
|
|
723
|
+
var VERSION = true ? "4.0.0-alpha.6" : "latest";
|
|
724
|
+
var OBJLoader = {
|
|
725
|
+
name: "OBJ",
|
|
726
|
+
id: "obj",
|
|
727
|
+
module: "obj",
|
|
728
|
+
version: VERSION,
|
|
729
|
+
worker: true,
|
|
730
|
+
extensions: ["obj"],
|
|
731
|
+
mimeTypes: ["text/plain"],
|
|
732
|
+
testText: testOBJFile,
|
|
733
|
+
options: {
|
|
734
|
+
obj: {}
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
function testOBJFile(text) {
|
|
738
|
+
return text[0] === "v";
|
|
739
|
+
}
|
|
740
|
+
|
|
1106
741
|
// src/lib/parse-mtl.ts
|
|
1107
742
|
var DELIMITER_PATTERN = /\s+/;
|
|
1108
743
|
function parseMTL(text, options) {
|
|
@@ -1172,27 +807,8 @@
|
|
|
1172
807
|
return color;
|
|
1173
808
|
}
|
|
1174
809
|
|
|
1175
|
-
// src/obj-loader.ts
|
|
1176
|
-
var VERSION = true ? "4.0.0-alpha.5" : "latest";
|
|
1177
|
-
var OBJLoader = {
|
|
1178
|
-
name: "OBJ",
|
|
1179
|
-
id: "obj",
|
|
1180
|
-
module: "obj",
|
|
1181
|
-
version: VERSION,
|
|
1182
|
-
worker: true,
|
|
1183
|
-
extensions: ["obj"],
|
|
1184
|
-
mimeTypes: ["text/plain"],
|
|
1185
|
-
testText: testOBJFile,
|
|
1186
|
-
options: {
|
|
1187
|
-
obj: {}
|
|
1188
|
-
}
|
|
1189
|
-
};
|
|
1190
|
-
function testOBJFile(text) {
|
|
1191
|
-
return text[0] === "v";
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
810
|
// src/mtl-loader.ts
|
|
1195
|
-
var VERSION2 = true ? "4.0.0-alpha.
|
|
811
|
+
var VERSION2 = true ? "4.0.0-alpha.6" : "latest";
|
|
1196
812
|
var MTLLoader = {
|
|
1197
813
|
name: "MTL",
|
|
1198
814
|
id: "mtl",
|