@loaders.gl/obj 4.0.0-alpha.1 → 4.0.0-alpha.11

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.
Files changed (89) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +744 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/index.js +74 -0
  8. package/dist/es5/index.js.map +1 -0
  9. package/dist/es5/lib/get-obj-schema.js +54 -0
  10. package/dist/es5/lib/get-obj-schema.js.map +1 -0
  11. package/dist/es5/lib/obj-types.js +2 -0
  12. package/dist/es5/lib/obj-types.js.map +1 -0
  13. package/dist/es5/lib/parse-mtl.js +86 -0
  14. package/dist/es5/lib/parse-mtl.js.map +1 -0
  15. package/dist/es5/lib/parse-obj-meshes.js +486 -0
  16. package/dist/es5/lib/parse-obj-meshes.js.map +1 -0
  17. package/dist/es5/lib/parse-obj.js +100 -0
  18. package/dist/es5/lib/parse-obj.js.map +1 -0
  19. package/dist/es5/mtl-loader.js +26 -0
  20. package/dist/es5/mtl-loader.js.map +1 -0
  21. package/dist/es5/obj-loader.js +27 -0
  22. package/dist/es5/obj-loader.js.map +1 -0
  23. package/dist/es5/workers/obj-worker.js +6 -0
  24. package/dist/es5/workers/obj-worker.js.map +1 -0
  25. package/dist/esm/bundle.js +4 -0
  26. package/dist/esm/bundle.js.map +1 -0
  27. package/dist/esm/index.js +18 -0
  28. package/dist/esm/index.js.map +1 -0
  29. package/dist/esm/lib/get-obj-schema.js +49 -0
  30. package/dist/esm/lib/get-obj-schema.js.map +1 -0
  31. package/dist/esm/lib/obj-types.js +2 -0
  32. package/dist/esm/lib/obj-types.js.map +1 -0
  33. package/dist/esm/lib/parse-mtl.js +68 -0
  34. package/dist/esm/lib/parse-mtl.js.map +1 -0
  35. package/dist/esm/lib/parse-obj-meshes.js +385 -0
  36. package/dist/esm/lib/parse-obj-meshes.js.map +1 -0
  37. package/dist/{lib/load-obj.js → esm/lib/parse-obj.js} +5 -15
  38. package/dist/esm/lib/parse-obj.js.map +1 -0
  39. package/dist/esm/mtl-loader.js +16 -0
  40. package/dist/esm/mtl-loader.js.map +1 -0
  41. package/dist/esm/obj-loader.js +19 -0
  42. package/dist/esm/obj-loader.js.map +1 -0
  43. package/dist/esm/workers/obj-worker.js +4 -0
  44. package/dist/esm/workers/obj-worker.js.map +1 -0
  45. package/dist/index.d.ts +18 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +26 -8
  48. package/dist/lib/get-obj-schema.d.ts +4 -0
  49. package/dist/lib/get-obj-schema.d.ts.map +1 -0
  50. package/dist/lib/get-obj-schema.js +33 -33
  51. package/dist/lib/obj-types.d.ts +1 -0
  52. package/dist/lib/obj-types.d.ts.map +1 -0
  53. package/dist/lib/obj-types.js +1 -2
  54. package/dist/lib/parse-mtl.d.ts +34 -0
  55. package/dist/lib/parse-mtl.d.ts.map +1 -0
  56. package/dist/lib/parse-mtl.js +201 -0
  57. package/dist/lib/parse-obj-meshes.d.ts +5 -0
  58. package/dist/lib/parse-obj-meshes.d.ts.map +1 -0
  59. package/dist/lib/parse-obj-meshes.js +440 -0
  60. package/dist/lib/parse-obj.d.ts +3 -0
  61. package/dist/lib/parse-obj.d.ts.map +1 -0
  62. package/dist/lib/parse-obj.js +63 -449
  63. package/dist/mtl-loader.d.ts +12 -0
  64. package/dist/mtl-loader.d.ts.map +1 -0
  65. package/dist/mtl-loader.js +24 -0
  66. package/dist/obj-loader.d.ts +11 -0
  67. package/dist/obj-loader.d.ts.map +1 -0
  68. package/dist/obj-loader.js +24 -18
  69. package/dist/obj-worker.js +213 -507
  70. package/dist/workers/obj-worker.d.ts +2 -0
  71. package/dist/workers/obj-worker.d.ts.map +1 -0
  72. package/dist/workers/obj-worker.js +5 -4
  73. package/package.json +9 -9
  74. package/src/index.ts +25 -4
  75. package/src/lib/get-obj-schema.ts +24 -20
  76. package/src/lib/parse-mtl.ts +246 -0
  77. package/src/lib/parse-obj-meshes.ts +525 -0
  78. package/src/lib/parse-obj.ts +67 -508
  79. package/src/mtl-loader.ts +31 -0
  80. package/src/obj-loader.ts +8 -3
  81. package/dist/bundle.js.map +0 -1
  82. package/dist/index.js.map +0 -1
  83. package/dist/lib/get-obj-schema.js.map +0 -1
  84. package/dist/lib/load-obj.js.map +0 -1
  85. package/dist/lib/obj-types.js.map +0 -1
  86. package/dist/lib/parse-obj.js.map +0 -1
  87. package/dist/obj-loader.js.map +0 -1
  88. package/src/lib/load-obj.ts +0 -83
  89. /package/src/workers/{obj-worker.js → obj-worker.ts} +0 -0
@@ -1,458 +1,72 @@
1
- const OBJECT_RE = /^[og]\s*(.+)?/;
2
- const MATERIAL_RE = /^mtllib /;
3
- const MATERIAL_USE_RE = /^usemtl /;
4
-
5
- class MeshMaterial {
6
- constructor({
7
- index,
8
- name = '',
9
- mtllib,
10
- smooth,
11
- groupStart
12
- }) {
13
- this.index = index;
14
- this.name = name;
15
- this.mtllib = mtllib;
16
- this.smooth = smooth;
17
- this.groupStart = groupStart;
18
- this.groupEnd = -1;
19
- this.groupCount = -1;
20
- this.inherited = false;
21
- }
22
-
23
- clone(index = this.index) {
24
- return new MeshMaterial({
25
- index,
26
- name: this.name,
27
- mtllib: this.mtllib,
28
- smooth: this.smooth,
29
- groupStart: 0
30
- });
31
- }
32
-
33
- }
34
-
35
- class MeshObject {
36
- constructor(name = '') {
37
- this.name = name;
38
- this.geometry = {
39
- vertices: [],
40
- normals: [],
41
- colors: [],
42
- uvs: []
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOBJ = void 0;
4
+ const schema_1 = require("@loaders.gl/schema");
5
+ const parse_obj_meshes_1 = require("./parse-obj-meshes");
6
+ const get_obj_schema_1 = require("./get-obj-schema");
7
+ function parseOBJ(text, options) {
8
+ const { meshes } = (0, parse_obj_meshes_1.parseOBJMeshes)(text);
9
+ // @ts-expect-error
10
+ const vertexCount = meshes.reduce((s, mesh) => s + mesh.header.vertexCount, 0);
11
+ // TODO - render objects separately
12
+ const attributes = mergeAttributes(meshes, vertexCount);
13
+ const header = {
14
+ vertexCount,
15
+ // @ts-ignore Need to export Attributes type
16
+ boundingBox: (0, schema_1.getMeshBoundingBox)(attributes)
43
17
  };
44
- this.materials = [];
45
- this.smooth = true;
46
- this.fromDeclaration = null;
47
- }
48
-
49
- startMaterial(name, libraries) {
50
- const previous = this._finalize(false);
51
-
52
- if (previous && (previous.inherited || previous.groupCount <= 0)) {
53
- this.materials.splice(previous.index, 1);
54
- }
55
-
56
- const material = new MeshMaterial({
57
- index: this.materials.length,
58
- name,
59
- mtllib: Array.isArray(libraries) && libraries.length > 0 ? libraries[libraries.length - 1] : '',
60
- smooth: previous !== undefined ? previous.smooth : this.smooth,
61
- groupStart: previous !== undefined ? previous.groupEnd : 0
18
+ const schema = (0, get_obj_schema_1.getOBJSchema)(attributes, {
19
+ mode: 4,
20
+ boundingBox: header.boundingBox
62
21
  });
63
- this.materials.push(material);
64
- return material;
65
- }
66
-
67
- currentMaterial() {
68
- if (this.materials.length > 0) {
69
- return this.materials[this.materials.length - 1];
70
- }
71
-
72
- return undefined;
73
- }
74
-
75
- _finalize(end) {
76
- const lastMultiMaterial = this.currentMaterial();
77
-
78
- if (lastMultiMaterial && lastMultiMaterial.groupEnd === -1) {
79
- lastMultiMaterial.groupEnd = this.geometry.vertices.length / 3;
80
- lastMultiMaterial.groupCount = lastMultiMaterial.groupEnd - lastMultiMaterial.groupStart;
81
- lastMultiMaterial.inherited = false;
82
- }
83
-
84
- if (end && this.materials.length > 1) {
85
- for (let mi = this.materials.length - 1; mi >= 0; mi--) {
86
- if (this.materials[mi].groupCount <= 0) {
87
- this.materials.splice(mi, 1);
88
- }
89
- }
90
- }
91
-
92
- if (end && this.materials.length === 0) {
93
- this.materials.push({
94
- name: '',
95
- smooth: this.smooth
96
- });
97
- }
98
-
99
- return lastMultiMaterial;
100
- }
101
-
102
- }
103
-
104
- class ParserState {
105
- constructor() {
106
- this.objects = [];
107
- this.object = null;
108
- this.vertices = [];
109
- this.normals = [];
110
- this.colors = [];
111
- this.uvs = [];
112
- this.materialLibraries = [];
113
- this.startObject('', false);
114
- }
115
-
116
- startObject(name, fromDeclaration = true) {
117
- if (this.object && !this.object.fromDeclaration) {
118
- this.object.name = name;
119
- this.object.fromDeclaration = fromDeclaration;
120
- return;
121
- }
122
-
123
- const previousMaterial = this.object && typeof this.object.currentMaterial === 'function' ? this.object.currentMaterial() : undefined;
124
-
125
- if (this.object && typeof this.object._finalize === 'function') {
126
- this.object._finalize(true);
127
- }
128
-
129
- this.object = new MeshObject(name);
130
- this.object.fromDeclaration = fromDeclaration;
131
-
132
- if (previousMaterial && previousMaterial.name && typeof previousMaterial.clone === 'function') {
133
- const declared = previousMaterial.clone(0);
134
- declared.inherited = true;
135
- this.object.materials.push(declared);
136
- }
137
-
138
- this.objects.push(this.object);
139
- }
140
-
141
- finalize() {
142
- if (this.object && typeof this.object._finalize === 'function') {
143
- this.object._finalize(true);
144
- }
145
- }
146
-
147
- parseVertexIndex(value, len) {
148
- const index = parseInt(value);
149
- return (index >= 0 ? index - 1 : index + len / 3) * 3;
150
- }
151
-
152
- parseNormalIndex(value, len) {
153
- const index = parseInt(value);
154
- return (index >= 0 ? index - 1 : index + len / 3) * 3;
155
- }
156
-
157
- parseUVIndex(value, len) {
158
- const index = parseInt(value);
159
- return (index >= 0 ? index - 1 : index + len / 2) * 2;
160
- }
161
-
162
- addVertex(a, b, c) {
163
- const src = this.vertices;
164
- const dst = this.object.geometry.vertices;
165
- dst.push(src[a + 0], src[a + 1], src[a + 2]);
166
- dst.push(src[b + 0], src[b + 1], src[b + 2]);
167
- dst.push(src[c + 0], src[c + 1], src[c + 2]);
168
- }
169
-
170
- addVertexPoint(a) {
171
- const src = this.vertices;
172
- const dst = this.object.geometry.vertices;
173
- dst.push(src[a + 0], src[a + 1], src[a + 2]);
174
- }
175
-
176
- addVertexLine(a) {
177
- const src = this.vertices;
178
- const dst = this.object.geometry.vertices;
179
- dst.push(src[a + 0], src[a + 1], src[a + 2]);
180
- }
181
-
182
- addNormal(a, b, c) {
183
- const src = this.normals;
184
- const dst = this.object.geometry.normals;
185
- dst.push(src[a + 0], src[a + 1], src[a + 2]);
186
- dst.push(src[b + 0], src[b + 1], src[b + 2]);
187
- dst.push(src[c + 0], src[c + 1], src[c + 2]);
188
- }
189
-
190
- addColor(a, b, c) {
191
- const src = this.colors;
192
- const dst = this.object.geometry.colors;
193
- dst.push(src[a + 0], src[a + 1], src[a + 2]);
194
- dst.push(src[b + 0], src[b + 1], src[b + 2]);
195
- dst.push(src[c + 0], src[c + 1], src[c + 2]);
196
- }
197
-
198
- addUV(a, b, c) {
199
- const src = this.uvs;
200
- const dst = this.object.geometry.uvs;
201
- dst.push(src[a + 0], src[a + 1]);
202
- dst.push(src[b + 0], src[b + 1]);
203
- dst.push(src[c + 0], src[c + 1]);
204
- }
205
-
206
- addUVLine(a) {
207
- const src = this.uvs;
208
- const dst = this.object.geometry.uvs;
209
- dst.push(src[a + 0], src[a + 1]);
210
- }
211
-
212
- addFace(a, b, c, ua, ub, uc, na, nb, nc) {
213
- const vLen = this.vertices.length;
214
- let ia = this.parseVertexIndex(a, vLen);
215
- let ib = this.parseVertexIndex(b, vLen);
216
- let ic = this.parseVertexIndex(c, vLen);
217
- this.addVertex(ia, ib, ic);
218
-
219
- if (ua !== undefined && ua !== '') {
220
- const uvLen = this.uvs.length;
221
- ia = this.parseUVIndex(ua, uvLen);
222
- ib = this.parseUVIndex(ub, uvLen);
223
- ic = this.parseUVIndex(uc, uvLen);
224
- this.addUV(ia, ib, ic);
225
- }
226
-
227
- if (na !== undefined && na !== '') {
228
- const nLen = this.normals.length;
229
- ia = this.parseNormalIndex(na, nLen);
230
- ib = na === nb ? ia : this.parseNormalIndex(nb, nLen);
231
- ic = na === nc ? ia : this.parseNormalIndex(nc, nLen);
232
- this.addNormal(ia, ib, ic);
233
- }
234
-
235
- if (this.colors.length > 0) {
236
- this.addColor(ia, ib, ic);
237
- }
238
- }
239
-
240
- addPointGeometry(vertices) {
241
- this.object.geometry.type = 'Points';
242
- const vLen = this.vertices.length;
243
-
244
- for (const vertex of vertices) {
245
- this.addVertexPoint(this.parseVertexIndex(vertex, vLen));
246
- }
247
- }
248
-
249
- addLineGeometry(vertices, uvs) {
250
- this.object.geometry.type = 'Line';
251
- const vLen = this.vertices.length;
252
- const uvLen = this.uvs.length;
253
-
254
- for (const vertex of vertices) {
255
- this.addVertexLine(this.parseVertexIndex(vertex, vLen));
256
- }
257
-
258
- for (const uv of uvs) {
259
- this.addUVLine(this.parseUVIndex(uv, uvLen));
260
- }
261
- }
262
-
22
+ return {
23
+ // Data return by this loader implementation
24
+ loaderData: {
25
+ header: {}
26
+ },
27
+ // Normalised data
28
+ schema,
29
+ header,
30
+ mode: 4,
31
+ topology: 'point-list',
32
+ attributes
33
+ };
263
34
  }
264
-
265
- export default (text => {
266
- const state = new ParserState();
267
-
268
- if (text.indexOf('\r\n') !== -1) {
269
- text = text.replace(/\r\n/g, '\n');
270
- }
271
-
272
- if (text.indexOf('\\\n') !== -1) {
273
- text = text.replace(/\\\n/g, '');
274
- }
275
-
276
- const lines = text.split('\n');
277
- let line = '';
278
- let lineFirstChar = '';
279
- let lineLength = 0;
280
- let result = [];
281
- const trimLeft = typeof ''.trimLeft === 'function';
282
-
283
- for (let i = 0, l = lines.length; i < l; i++) {
284
- line = lines[i];
285
- line = trimLeft ? line.trimLeft() : line.trim();
286
- lineLength = line.length;
287
- if (lineLength === 0) continue;
288
- lineFirstChar = line.charAt(0);
289
- if (lineFirstChar === '#') continue;
290
-
291
- if (lineFirstChar === 'v') {
292
- const data = line.split(/\s+/);
293
-
294
- switch (data[0]) {
295
- case 'v':
296
- state.vertices.push(parseFloat(data[1]), parseFloat(data[2]), parseFloat(data[3]));
297
-
298
- if (data.length === 8) {
299
- state.colors.push(parseFloat(data[4]), parseFloat(data[5]), parseFloat(data[6]));
300
- }
301
-
302
- break;
303
-
304
- case 'vn':
305
- state.normals.push(parseFloat(data[1]), parseFloat(data[2]), parseFloat(data[3]));
306
- break;
307
-
308
- case 'vt':
309
- state.uvs.push(parseFloat(data[1]), parseFloat(data[2]));
310
- break;
311
-
312
- default:
313
- }
314
- } else if (lineFirstChar === 'f') {
315
- const lineData = line.substr(1).trim();
316
- const vertexData = lineData.split(/\s+/);
317
- const faceVertices = [];
318
-
319
- for (let j = 0, jl = vertexData.length; j < jl; j++) {
320
- const vertex = vertexData[j];
321
-
322
- if (vertex.length > 0) {
323
- const vertexParts = vertex.split('/');
324
- faceVertices.push(vertexParts);
35
+ exports.parseOBJ = parseOBJ;
36
+ // eslint-disable-next-line max-statements
37
+ function mergeAttributes(meshes, vertexCount) {
38
+ const positions = new Float32Array(vertexCount * 3);
39
+ let normals;
40
+ let colors;
41
+ let uvs;
42
+ let i = 0;
43
+ for (const mesh of meshes) {
44
+ const { POSITION, NORMAL, COLOR_0, TEXCOORD_0 } = mesh.attributes;
45
+ positions.set(POSITION.value, i * 3);
46
+ if (NORMAL) {
47
+ normals = normals || new Float32Array(vertexCount * 3);
48
+ normals.set(NORMAL.value, i * 3);
325
49
  }
326
- }
327
-
328
- const v1 = faceVertices[0];
329
-
330
- for (let j = 1, jl = faceVertices.length - 1; j < jl; j++) {
331
- const v2 = faceVertices[j];
332
- const v3 = faceVertices[j + 1];
333
- state.addFace(v1[0], v2[0], v3[0], v1[1], v2[1], v3[1], v1[2], v2[2], v3[2]);
334
- }
335
- } else if (lineFirstChar === 'l') {
336
- const lineParts = line.substring(1).trim().split(' ');
337
- let lineVertices;
338
- const lineUVs = [];
339
-
340
- if (line.indexOf('/') === -1) {
341
- lineVertices = lineParts;
342
- } else {
343
- lineVertices = [];
344
-
345
- for (let li = 0, llen = lineParts.length; li < llen; li++) {
346
- const parts = lineParts[li].split('/');
347
- if (parts[0] !== '') lineVertices.push(parts[0]);
348
- if (parts[1] !== '') lineUVs.push(parts[1]);
50
+ if (COLOR_0) {
51
+ colors = colors || new Float32Array(vertexCount * 3);
52
+ colors.set(COLOR_0.value, i * 3);
349
53
  }
350
- }
351
-
352
- state.addLineGeometry(lineVertices, lineUVs);
353
- } else if (lineFirstChar === 'p') {
354
- const lineData = line.substr(1).trim();
355
- const pointData = lineData.split(' ');
356
- state.addPointGeometry(pointData);
357
- } else if ((result = OBJECT_RE.exec(line)) !== null) {
358
- const name = (' ' + result[0].substr(1).trim()).substr(1);
359
- state.startObject(name);
360
- } else if (MATERIAL_USE_RE.test(line)) {
361
- state.object.startMaterial(line.substring(7).trim(), state.materialLibraries);
362
- } else if (MATERIAL_RE.test(line)) {
363
- state.materialLibraries.push(line.substring(7).trim());
364
- } else if (lineFirstChar === 's') {
365
- result = line.split(' ');
366
-
367
- if (result.length > 1) {
368
- const value = result[1].trim().toLowerCase();
369
- state.object.smooth = value !== '0' && value !== 'off';
370
- } else {
371
- state.object.smooth = true;
372
- }
373
-
374
- const material = state.object.currentMaterial();
375
- if (material) material.smooth = state.object.smooth;
376
- } else {
377
- if (line === '\0') continue;
378
- throw new Error("Unexpected line: \"".concat(line, "\""));
379
- }
380
- }
381
-
382
- state.finalize();
383
- const meshes = [];
384
- const materials = [];
385
-
386
- for (const object of state.objects) {
387
- const {
388
- geometry
389
- } = object;
390
- if (geometry.vertices.length === 0) continue;
391
- const mesh = {
392
- header: {
393
- vertexCount: geometry.vertices.length / 3
394
- },
395
- attributes: {}
396
- };
397
-
398
- switch (geometry.type) {
399
- case 'Points':
400
- mesh.mode = 0;
401
- break;
402
-
403
- case 'Line':
404
- mesh.mode = 1;
405
- break;
406
-
407
- default:
408
- mesh.mode = 4;
409
- break;
410
- }
411
-
412
- mesh.attributes.POSITION = {
413
- value: new Float32Array(geometry.vertices),
414
- size: 3
415
- };
416
-
417
- if (geometry.normals.length > 0) {
418
- mesh.attributes.NORMAL = {
419
- value: new Float32Array(geometry.normals),
420
- size: 3
421
- };
54
+ if (TEXCOORD_0) {
55
+ uvs = uvs || new Float32Array(vertexCount * 2);
56
+ uvs.set(TEXCOORD_0.value, i * 2);
57
+ }
58
+ i += POSITION.value.length / 3;
422
59
  }
423
-
424
- if (geometry.colors.length > 0) {
425
- mesh.attributes.COLOR_0 = {
426
- value: new Float32Array(geometry.colors),
427
- size: 3
428
- };
60
+ const attributes = {};
61
+ attributes.POSITION = { value: positions, size: 3 };
62
+ if (normals) {
63
+ attributes.NORMAL = { value: normals, size: 3 };
429
64
  }
430
-
431
- if (geometry.uvs.length > 0) {
432
- mesh.attributes.TEXCOORD_0 = {
433
- value: new Float32Array(geometry.uvs),
434
- size: 2
435
- };
65
+ if (colors) {
66
+ attributes.COLOR_0 = { value: colors, size: 3 };
436
67
  }
437
-
438
- mesh.materials = [];
439
-
440
- for (const sourceMaterial of object.materials) {
441
- const _material = {
442
- name: sourceMaterial.name,
443
- flatShading: !sourceMaterial.smooth
444
- };
445
- mesh.materials.push(_material);
446
- materials.push(_material);
68
+ if (uvs) {
69
+ attributes.TEXCOORD_0 = { value: uvs, size: 2 };
447
70
  }
448
-
449
- mesh.name = object.name;
450
- meshes.push(mesh);
451
- }
452
-
453
- return {
454
- meshes,
455
- materials
456
- };
457
- });
458
- //# sourceMappingURL=parse-obj.js.map
71
+ return attributes;
72
+ }
@@ -0,0 +1,12 @@
1
+ import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { MTLMaterial, ParseMTLOptions } from './lib/parse-mtl';
3
+ export type MTLLoaderOptions = LoaderOptions & {
4
+ mtl?: ParseMTLOptions;
5
+ };
6
+ /**
7
+ * Loader for the MTL material format
8
+ * Parses a Wavefront .mtl file specifying materials
9
+ */
10
+ export declare const MTLLoader: Loader<MTLMaterial[], never, LoaderOptions>;
11
+ export declare const _typecheckMTLLoader: Loader;
12
+ //# sourceMappingURL=mtl-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtl-loader.d.ts","sourceRoot":"","sources":["../src/mtl-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAMlE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,aAAa,CAYjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAkB,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._typecheckMTLLoader = exports.MTLLoader = void 0;
4
+ // __VERSION__ is injected by babel-plugin-version-inline
5
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
+ /**
8
+ * Loader for the MTL material format
9
+ * Parses a Wavefront .mtl file specifying materials
10
+ */
11
+ exports.MTLLoader = {
12
+ name: 'MTL',
13
+ id: 'mtl',
14
+ module: 'mtl',
15
+ version: VERSION,
16
+ worker: true,
17
+ extensions: ['mtl'],
18
+ mimeTypes: ['text/plain'],
19
+ testText: (text) => text.includes('newmtl'),
20
+ options: {
21
+ mtl: {}
22
+ }
23
+ };
24
+ exports._typecheckMTLLoader = exports.MTLLoader;
@@ -0,0 +1,11 @@
1
+ import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import { Mesh } from '@loaders.gl/schema';
3
+ export type OBJLoaderOptions = LoaderOptions & {
4
+ obj?: {};
5
+ };
6
+ /**
7
+ * Worker loader for the OBJ geometry format
8
+ */
9
+ export declare const OBJLoader: Loader<Mesh, never, OBJLoaderOptions>;
10
+ export declare const _typecheckOBJLoader: Loader;
11
+ //# sourceMappingURL=obj-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obj-loader.d.ts","sourceRoot":"","sources":["../src/obj-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAMxC,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,EAAE,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAY3D,CAAC;AAOF,eAAO,MAAM,mBAAmB,EAAE,MAAkB,CAAC"}
@@ -1,21 +1,27 @@
1
- const VERSION = typeof "4.0.0-alpha.1" !== 'undefined' ? "4.0.0-alpha.1" : 'latest';
2
- export const OBJLoader = {
3
- name: 'OBJ',
4
- id: 'obj',
5
- module: 'obj',
6
- version: VERSION,
7
- worker: true,
8
- extensions: ['obj'],
9
- mimeTypes: ['text/plain'],
10
- testText: testOBJFile,
11
- options: {
12
- obj: {}
13
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._typecheckOBJLoader = exports.OBJLoader = void 0;
4
+ // __VERSION__ is injected by babel-plugin-version-inline
5
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
+ /**
8
+ * Worker loader for the OBJ geometry format
9
+ */
10
+ exports.OBJLoader = {
11
+ name: 'OBJ',
12
+ id: 'obj',
13
+ module: 'obj',
14
+ version: VERSION,
15
+ worker: true,
16
+ extensions: ['obj'],
17
+ mimeTypes: ['text/plain'],
18
+ testText: testOBJFile,
19
+ options: {
20
+ obj: {}
21
+ }
14
22
  };
15
-
16
23
  function testOBJFile(text) {
17
- return text[0] === 'v';
24
+ // TODO - There could be comment line first
25
+ return text[0] === 'v';
18
26
  }
19
-
20
- export const _typecheckOBJLoader = OBJLoader;
21
- //# sourceMappingURL=obj-loader.js.map
27
+ exports._typecheckOBJLoader = exports.OBJLoader;