@loaders.gl/obj 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 +11998 -61
- package/dist/dist.min.js +15 -6
- package/dist/index.cjs +57 -30
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +6 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -21
- package/dist/index.js.map +1 -0
- package/dist/lib/get-obj-schema.js +2 -1
- package/dist/lib/get-obj-schema.js.map +1 -0
- package/dist/lib/obj-types.js +1 -0
- package/dist/lib/obj-types.js.map +1 -0
- package/dist/lib/parse-mtl.js +1 -0
- package/dist/lib/parse-mtl.js.map +1 -0
- package/dist/lib/parse-obj-meshes.js +1 -0
- package/dist/lib/parse-obj-meshes.js.map +1 -0
- package/dist/lib/parse-obj.d.ts +1 -1
- package/dist/lib/parse-obj.d.ts.map +1 -1
- package/dist/lib/parse-obj.js +2 -1
- package/dist/lib/parse-obj.js.map +1 -0
- package/dist/mtl-format.d.ts +12 -0
- package/dist/mtl-format.d.ts.map +1 -0
- package/dist/mtl-format.js +15 -0
- package/dist/mtl-format.js.map +1 -0
- package/dist/mtl-loader.d.ts +23 -3
- package/dist/mtl-loader.d.ts.map +1 -1
- package/dist/mtl-loader.js +18 -7
- package/dist/mtl-loader.js.map +1 -0
- package/dist/obj-arrow-loader.d.ts +21 -0
- package/dist/obj-arrow-loader.d.ts.map +1 -0
- package/dist/obj-arrow-loader.js +22 -0
- package/dist/obj-arrow-loader.js.map +1 -0
- package/dist/obj-format.d.ts +11 -0
- package/dist/obj-format.d.ts.map +1 -0
- package/dist/obj-format.js +14 -0
- package/dist/obj-format.js.map +1 -0
- package/dist/obj-loader.d.ts +25 -5
- package/dist/obj-loader.d.ts.map +1 -1
- package/dist/obj-loader.js +18 -7
- package/dist/obj-loader.js.map +1 -0
- package/dist/obj-worker.js +21 -107
- package/dist/workers/obj-worker.js +1 -0
- package/dist/workers/obj-worker.js.map +1 -0
- package/package.json +9 -5
- package/src/index.ts +6 -32
- package/src/lib/get-obj-schema.ts +1 -1
- package/src/lib/parse-obj.ts +2 -2
- package/src/mtl-format.ts +17 -0
- package/src/mtl-loader.ts +19 -7
- package/src/obj-arrow-loader.ts +26 -0
- package/src/obj-format.ts +16 -0
- package/src/obj-loader.ts +23 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtl-format.d.ts","sourceRoot":"","sources":["../src/mtl-format.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;CAMK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* The MTL material format
|
|
6
|
+
* A Wavefront .mtl file specifying materials
|
|
7
|
+
*/
|
|
8
|
+
export const MTLFormat = {
|
|
9
|
+
name: 'MTL',
|
|
10
|
+
id: 'mtl',
|
|
11
|
+
module: 'mtl',
|
|
12
|
+
extensions: ['mtl'],
|
|
13
|
+
mimeTypes: ['text/plain']
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=mtl-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtl-format.js","sourceRoot":"","sources":["../src/mtl-format.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,YAAY,CAAC;CACA,CAAC"}
|
package/dist/mtl-loader.d.ts
CHANGED
|
@@ -7,19 +7,39 @@ export type MTLLoaderOptions = LoaderOptions & {
|
|
|
7
7
|
* Loader for the MTL material format
|
|
8
8
|
* Parses a Wavefront .mtl file specifying materials
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const MTLWorkerLoader: {
|
|
11
11
|
readonly dataType: MTLMaterial[];
|
|
12
12
|
readonly batchType: never;
|
|
13
|
+
readonly version: any;
|
|
14
|
+
readonly worker: true;
|
|
15
|
+
readonly testText: (text: string) => boolean;
|
|
16
|
+
readonly options: {
|
|
17
|
+
readonly mtl: {};
|
|
18
|
+
};
|
|
13
19
|
readonly name: "MTL";
|
|
14
20
|
readonly id: "mtl";
|
|
15
21
|
readonly module: "mtl";
|
|
16
|
-
readonly version: any;
|
|
17
|
-
readonly worker: true;
|
|
18
22
|
readonly extensions: ["mtl"];
|
|
19
23
|
readonly mimeTypes: ["text/plain"];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Loader for the MTL material format
|
|
27
|
+
*/
|
|
28
|
+
export declare const MTLLoader: {
|
|
29
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options?: MTLLoaderOptions) => Promise<MTLMaterial[]>;
|
|
30
|
+
readonly parseTextSync: (text: string, options?: MTLLoaderOptions) => MTLMaterial[];
|
|
31
|
+
readonly dataType: MTLMaterial[];
|
|
32
|
+
readonly batchType: never;
|
|
33
|
+
readonly version: any;
|
|
34
|
+
readonly worker: true;
|
|
20
35
|
readonly testText: (text: string) => boolean;
|
|
21
36
|
readonly options: {
|
|
22
37
|
readonly mtl: {};
|
|
23
38
|
};
|
|
39
|
+
readonly name: "MTL";
|
|
40
|
+
readonly id: "mtl";
|
|
41
|
+
readonly module: "mtl";
|
|
42
|
+
readonly extensions: ["mtl"];
|
|
43
|
+
readonly mimeTypes: ["text/plain"];
|
|
24
44
|
};
|
|
25
45
|
//# sourceMappingURL=mtl-loader.d.ts.map
|
package/dist/mtl-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mtl-loader.d.ts","sourceRoot":"","sources":["../src/mtl-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mtl-loader.d.ts","sourceRoot":"","sources":["../src/mtl-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA2B,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,2BAAwB;AAQlE,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe;uBAGG,WAAW,EAAE;wBACvB,KAAK;;;8BAIP,MAAM,KAAG,OAAO;;;;;;;;;CAI6B,CAAC;AAIjE;;GAEG;AACH,eAAO,MAAM,SAAS;kCAEO,WAAW,YAAY,gBAAgB;mCAE5C,MAAM,YAAY,gBAAgB;uBApB3B,WAAW,EAAE;wBACvB,KAAK;;;8BAIP,MAAM,KAAG,OAAO;;;;;;;;;CAgB0C,CAAC"}
|
package/dist/mtl-loader.js
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { parseMTL } from "./lib/parse-mtl.js";
|
|
5
|
+
import { MTLFormat } from "./mtl-format.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
|
* Loader for the MTL material format
|
|
6
11
|
* Parses a Wavefront .mtl file specifying materials
|
|
7
12
|
*/
|
|
8
|
-
export const
|
|
13
|
+
export const MTLWorkerLoader = {
|
|
14
|
+
...MTLFormat,
|
|
9
15
|
dataType: null,
|
|
10
16
|
batchType: null,
|
|
11
|
-
name: 'MTL',
|
|
12
|
-
id: 'mtl',
|
|
13
|
-
module: 'mtl',
|
|
14
17
|
version: VERSION,
|
|
15
18
|
worker: true,
|
|
16
|
-
extensions: ['mtl'],
|
|
17
|
-
mimeTypes: ['text/plain'],
|
|
18
19
|
testText: (text) => text.includes('newmtl'),
|
|
19
20
|
options: {
|
|
20
21
|
mtl: {}
|
|
21
22
|
}
|
|
22
23
|
};
|
|
24
|
+
// MTLLoader
|
|
25
|
+
/**
|
|
26
|
+
* Loader for the MTL material format
|
|
27
|
+
*/
|
|
28
|
+
export const MTLLoader = {
|
|
29
|
+
...MTLWorkerLoader,
|
|
30
|
+
parse: async (arrayBuffer, options) => parseMTL(new TextDecoder().decode(arrayBuffer), options?.mtl),
|
|
31
|
+
parseTextSync: (text, options) => parseMTL(text, options?.mtl)
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=mtl-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mtl-loader.js","sourceRoot":"","sources":["../src/mtl-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AACzC,OAAO,EAAC,SAAS,EAAC,wBAAqB;AAEvC,yDAAyD;AACzD,qDAAqD;AACrD,MAAM,OAAO,GAAG,uBAAkB,KAAK,WAAW,CAAC,CAAC,kBAAa,CAAC,CAAC,QAAQ,CAAC;AAM5E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,SAAS;IAEZ,QAAQ,EAAE,IAAgC;IAC1C,SAAS,EAAE,IAAa;IAExB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC5D,OAAO,EAAE;QACP,GAAG,EAAE,EAAE;KACR;CAC6D,CAAC;AAEjE,YAAY;AAEZ;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,eAAe;IAClB,KAAK,EAAE,KAAK,EAAE,WAAwB,EAAE,OAA0B,EAAE,EAAE,CACpE,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC;IAC/D,aAAa,EAAE,CAAC,IAAY,EAAE,OAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ArrowTable } from '@loaders.gl/schema';
|
|
2
|
+
/**
|
|
3
|
+
* Worker loader for OBJ - Point Cloud Data
|
|
4
|
+
*/
|
|
5
|
+
export declare const OBJArrowLoader: {
|
|
6
|
+
readonly dataType: ArrowTable;
|
|
7
|
+
readonly batchType: never;
|
|
8
|
+
readonly worker: false;
|
|
9
|
+
readonly parse: (arrayBuffer: ArrayBuffer) => Promise<ArrowTable>;
|
|
10
|
+
readonly version: any;
|
|
11
|
+
readonly testText: (text: string) => boolean;
|
|
12
|
+
readonly options: {
|
|
13
|
+
readonly obj: {};
|
|
14
|
+
};
|
|
15
|
+
readonly name: "OBJ";
|
|
16
|
+
readonly id: "obj";
|
|
17
|
+
readonly module: "obj";
|
|
18
|
+
readonly extensions: ["obj"];
|
|
19
|
+
readonly mimeTypes: ["text/plain"];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=obj-arrow-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-arrow-loader.d.ts","sourceRoot":"","sources":["../src/obj-arrow-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAMnD;;GAEG;AACH,eAAO,MAAM,cAAc;uBAEI,UAAU;wBACpB,KAAK;;kCAEG,WAAW;;;;;;;;;;;CAMkC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { OBJWorkerLoader } from "./obj-loader.js";
|
|
5
|
+
import { convertMeshToTable } from '@loaders.gl/schema-utils';
|
|
6
|
+
import { parseOBJ } from "./lib/parse-obj.js";
|
|
7
|
+
/**
|
|
8
|
+
* Worker loader for OBJ - Point Cloud Data
|
|
9
|
+
*/
|
|
10
|
+
export const OBJArrowLoader = {
|
|
11
|
+
...OBJWorkerLoader,
|
|
12
|
+
dataType: null,
|
|
13
|
+
batchType: null,
|
|
14
|
+
worker: false,
|
|
15
|
+
parse: async (arrayBuffer) => {
|
|
16
|
+
const text = new TextDecoder().decode(arrayBuffer);
|
|
17
|
+
const mesh = parseOBJ(text);
|
|
18
|
+
const arrowTable = convertMeshToTable(mesh, 'arrow-table');
|
|
19
|
+
return arrowTable;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=obj-arrow-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-arrow-loader.js","sourceRoot":"","sources":["../src/obj-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,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC5B,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC3D,OAAO,UAAU,CAAC;IACpB,CAAC;CACuE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OBJ geometry format
|
|
3
|
+
*/
|
|
4
|
+
export declare const OBJFormat: {
|
|
5
|
+
readonly name: "OBJ";
|
|
6
|
+
readonly id: "obj";
|
|
7
|
+
readonly module: "obj";
|
|
8
|
+
readonly extensions: ["obj"];
|
|
9
|
+
readonly mimeTypes: ["text/plain"];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=obj-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-format.d.ts","sourceRoot":"","sources":["../src/obj-format.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;CAMK,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* The OBJ geometry format
|
|
6
|
+
*/
|
|
7
|
+
export const OBJFormat = {
|
|
8
|
+
name: 'OBJ',
|
|
9
|
+
id: 'obj',
|
|
10
|
+
module: 'obj',
|
|
11
|
+
extensions: ['obj'],
|
|
12
|
+
mimeTypes: ['text/plain']
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=obj-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-format.js","sourceRoot":"","sources":["../src/obj-format.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,KAAK;IACX,EAAE,EAAE,KAAK;IACT,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,SAAS,EAAE,CAAC,YAAY,CAAC;CACA,CAAC"}
|
package/dist/obj-loader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { Mesh } from '@loaders.gl/schema';
|
|
2
|
+
import type { Mesh } from '@loaders.gl/schema';
|
|
3
3
|
export type OBJLoaderOptions = LoaderOptions & {
|
|
4
4
|
obj?: {
|
|
5
5
|
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
@@ -9,21 +9,41 @@ export type OBJLoaderOptions = LoaderOptions & {
|
|
|
9
9
|
/**
|
|
10
10
|
* Worker loader for the OBJ geometry format
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const OBJWorkerLoader: {
|
|
13
13
|
readonly dataType: Mesh;
|
|
14
14
|
readonly batchType: never;
|
|
15
|
+
readonly version: any;
|
|
16
|
+
readonly worker: true;
|
|
17
|
+
readonly testText: typeof testOBJFile;
|
|
18
|
+
readonly options: {
|
|
19
|
+
readonly obj: {};
|
|
20
|
+
};
|
|
15
21
|
readonly name: "OBJ";
|
|
16
22
|
readonly id: "obj";
|
|
17
23
|
readonly module: "obj";
|
|
18
|
-
readonly version: any;
|
|
19
|
-
readonly worker: true;
|
|
20
24
|
readonly extensions: ["obj"];
|
|
21
25
|
readonly mimeTypes: ["text/plain"];
|
|
26
|
+
};
|
|
27
|
+
declare function testOBJFile(text: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Loader for the OBJ geometry format
|
|
30
|
+
*/
|
|
31
|
+
export declare const OBJLoader: {
|
|
32
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options?: OBJLoaderOptions) => Promise<Mesh>;
|
|
33
|
+
readonly parseTextSync: (text: string, options?: OBJLoaderOptions) => Mesh;
|
|
34
|
+
readonly dataType: Mesh;
|
|
35
|
+
readonly batchType: never;
|
|
36
|
+
readonly version: any;
|
|
37
|
+
readonly worker: true;
|
|
22
38
|
readonly testText: typeof testOBJFile;
|
|
23
39
|
readonly options: {
|
|
24
40
|
readonly obj: {};
|
|
25
41
|
};
|
|
42
|
+
readonly name: "OBJ";
|
|
43
|
+
readonly id: "obj";
|
|
44
|
+
readonly module: "obj";
|
|
45
|
+
readonly extensions: ["obj"];
|
|
46
|
+
readonly mimeTypes: ["text/plain"];
|
|
26
47
|
};
|
|
27
|
-
declare function testOBJFile(text: string): boolean;
|
|
28
48
|
export {};
|
|
29
49
|
//# sourceMappingURL=obj-loader.d.ts.map
|
package/dist/obj-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obj-loader.d.ts","sourceRoot":"","sources":["../src/obj-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"obj-loader.d.ts","sourceRoot":"","sources":["../src/obj-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAQ7C,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;uBAGG,IAAI;wBACd,KAAK;;;;;;;;;;;;CAOgC,CAAC;AAE3D,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG1C;AAID;;GAEG;AACH,eAAO,MAAM,SAAS;kCAEO,WAAW,YAAY,gBAAgB;mCAE5C,MAAM,YAAY,gBAAgB;uBAxB3B,IAAI;wBACd,KAAK;;;;;;;;;;;;CAwB0C,CAAC"}
|
package/dist/obj-loader.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { OBJFormat } from "./obj-format.js";
|
|
5
|
+
import { parseOBJ } from "./lib/parse-obj.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 the OBJ geometry format
|
|
6
11
|
*/
|
|
7
|
-
export const
|
|
12
|
+
export const OBJWorkerLoader = {
|
|
13
|
+
...OBJFormat,
|
|
8
14
|
dataType: null,
|
|
9
15
|
batchType: null,
|
|
10
|
-
name: 'OBJ',
|
|
11
|
-
id: 'obj',
|
|
12
|
-
module: 'obj',
|
|
13
16
|
version: VERSION,
|
|
14
17
|
worker: true,
|
|
15
|
-
extensions: ['obj'],
|
|
16
|
-
mimeTypes: ['text/plain'],
|
|
17
18
|
testText: testOBJFile,
|
|
18
19
|
options: {
|
|
19
20
|
obj: {}
|
|
@@ -23,3 +24,13 @@ function testOBJFile(text) {
|
|
|
23
24
|
// TODO - There could be comment line first
|
|
24
25
|
return text[0] === 'v';
|
|
25
26
|
}
|
|
27
|
+
// OBJLoader
|
|
28
|
+
/**
|
|
29
|
+
* Loader for the OBJ geometry format
|
|
30
|
+
*/
|
|
31
|
+
export const OBJLoader = {
|
|
32
|
+
...OBJWorkerLoader,
|
|
33
|
+
parse: async (arrayBuffer, options) => parseOBJ(new TextDecoder().decode(arrayBuffer), options),
|
|
34
|
+
parseTextSync: (text, options) => parseOBJ(text, options)
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=obj-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-loader.js","sourceRoot":"","sources":["../src/obj-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,SAAS,EAAC,wBAAqB;AACvC,OAAO,EAAC,QAAQ,EAAC,2BAAwB;AAEzC,yDAAyD;AACzD,qDAAqD;AACrD,MAAM,OAAO,GAAG,uBAAkB,KAAK,WAAW,CAAC,CAAC,kBAAa,CAAC,CAAC,QAAQ,CAAC;AAS5E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,SAAS;IAEZ,QAAQ,EAAE,IAAuB;IACjC,SAAS,EAAE,IAAa;IACxB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE;QACP,GAAG,EAAE,EAAE;KACR;CACuD,CAAC;AAE3D,SAAS,WAAW,CAAC,IAAY;IAC/B,2CAA2C;IAC3C,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AACzB,CAAC;AAED,YAAY;AAEZ;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,eAAe;IAClB,KAAK,EAAE,KAAK,EAAE,WAAwB,EAAE,OAA0B,EAAE,EAAE,CACpE,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC1D,aAAa,EAAE,CAAC,IAAY,EAAE,OAA0B,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
package/dist/obj-worker.js
CHANGED
|
@@ -194,12 +194,24 @@
|
|
|
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
|
}
|
|
201
204
|
|
|
202
|
-
//
|
|
205
|
+
// src/obj-format.ts
|
|
206
|
+
var OBJFormat = {
|
|
207
|
+
name: "OBJ",
|
|
208
|
+
id: "obj",
|
|
209
|
+
module: "obj",
|
|
210
|
+
extensions: ["obj"],
|
|
211
|
+
mimeTypes: ["text/plain"]
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// ../schema-utils/src/lib/schema/data-type.ts
|
|
203
215
|
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
204
216
|
if (value instanceof Date) {
|
|
205
217
|
return "date-millisecond";
|
|
@@ -250,7 +262,7 @@
|
|
|
250
262
|
}
|
|
251
263
|
}
|
|
252
264
|
|
|
253
|
-
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
265
|
+
// ../schema-utils/src/lib/mesh/mesh-utils.ts
|
|
254
266
|
function getMeshBoundingBox(attributes) {
|
|
255
267
|
let minX = Infinity;
|
|
256
268
|
let minY = Infinity;
|
|
@@ -741,17 +753,13 @@
|
|
|
741
753
|
}
|
|
742
754
|
|
|
743
755
|
// src/obj-loader.ts
|
|
744
|
-
var VERSION = true ? "4.
|
|
745
|
-
var
|
|
756
|
+
var VERSION = true ? "4.4.0-alpha.10" : "latest";
|
|
757
|
+
var OBJWorkerLoader = {
|
|
758
|
+
...OBJFormat,
|
|
746
759
|
dataType: null,
|
|
747
760
|
batchType: null,
|
|
748
|
-
name: "OBJ",
|
|
749
|
-
id: "obj",
|
|
750
|
-
module: "obj",
|
|
751
761
|
version: VERSION,
|
|
752
762
|
worker: true,
|
|
753
|
-
extensions: ["obj"],
|
|
754
|
-
mimeTypes: ["text/plain"],
|
|
755
763
|
testText: testOBJFile,
|
|
756
764
|
options: {
|
|
757
765
|
obj: {}
|
|
@@ -760,106 +768,12 @@
|
|
|
760
768
|
function testOBJFile(text) {
|
|
761
769
|
return text[0] === "v";
|
|
762
770
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
var DELIMITER_PATTERN = /\s+/;
|
|
766
|
-
function parseMTL(text, options) {
|
|
767
|
-
const materials = [];
|
|
768
|
-
let currentMaterial = { name: "placeholder" };
|
|
769
|
-
const lines = text.split("\n");
|
|
770
|
-
for (let line of lines) {
|
|
771
|
-
line = line.trim();
|
|
772
|
-
if (line.length === 0 || line.charAt(0) === "#") {
|
|
773
|
-
continue;
|
|
774
|
-
}
|
|
775
|
-
const pos = line.indexOf(" ");
|
|
776
|
-
let key = pos >= 0 ? line.substring(0, pos) : line;
|
|
777
|
-
key = key.toLowerCase();
|
|
778
|
-
let value = pos >= 0 ? line.substring(pos + 1) : "";
|
|
779
|
-
value = value.trim();
|
|
780
|
-
switch (key) {
|
|
781
|
-
case "newmtl":
|
|
782
|
-
currentMaterial = { name: value };
|
|
783
|
-
materials.push(currentMaterial);
|
|
784
|
-
break;
|
|
785
|
-
case "ka":
|
|
786
|
-
currentMaterial.ambientColor = parseColor(value);
|
|
787
|
-
break;
|
|
788
|
-
case "kd":
|
|
789
|
-
currentMaterial.diffuseColor = parseColor(value);
|
|
790
|
-
break;
|
|
791
|
-
case "map_kd":
|
|
792
|
-
currentMaterial.diffuseTextureUrl = value;
|
|
793
|
-
break;
|
|
794
|
-
case "ks":
|
|
795
|
-
currentMaterial.specularColor = parseColor(value);
|
|
796
|
-
break;
|
|
797
|
-
case "map_ks":
|
|
798
|
-
currentMaterial.specularTextureUrl = value;
|
|
799
|
-
break;
|
|
800
|
-
case "ke":
|
|
801
|
-
currentMaterial.emissiveColor = parseColor(value);
|
|
802
|
-
break;
|
|
803
|
-
case "map_ke":
|
|
804
|
-
currentMaterial.emissiveTextureUrl = value;
|
|
805
|
-
break;
|
|
806
|
-
case "ns":
|
|
807
|
-
currentMaterial.shininess = parseFloat(value);
|
|
808
|
-
break;
|
|
809
|
-
case "map_ns":
|
|
810
|
-
break;
|
|
811
|
-
case "ni":
|
|
812
|
-
currentMaterial.refraction = parseFloat(value);
|
|
813
|
-
break;
|
|
814
|
-
case "illum":
|
|
815
|
-
currentMaterial.illumination = parseFloat(value);
|
|
816
|
-
break;
|
|
817
|
-
default:
|
|
818
|
-
break;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return materials;
|
|
822
|
-
}
|
|
823
|
-
function parseColor(value, options) {
|
|
824
|
-
const rgb = value.split(DELIMITER_PATTERN, 3);
|
|
825
|
-
const color = [
|
|
826
|
-
parseFloat(rgb[0]),
|
|
827
|
-
parseFloat(rgb[1]),
|
|
828
|
-
parseFloat(rgb[2])
|
|
829
|
-
];
|
|
830
|
-
return color;
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
// src/mtl-loader.ts
|
|
834
|
-
var VERSION2 = true ? "4.3.3" : "latest";
|
|
835
|
-
var MTLLoader = {
|
|
836
|
-
dataType: null,
|
|
837
|
-
batchType: null,
|
|
838
|
-
name: "MTL",
|
|
839
|
-
id: "mtl",
|
|
840
|
-
module: "mtl",
|
|
841
|
-
version: VERSION2,
|
|
842
|
-
worker: true,
|
|
843
|
-
extensions: ["mtl"],
|
|
844
|
-
mimeTypes: ["text/plain"],
|
|
845
|
-
testText: (text) => text.includes("newmtl"),
|
|
846
|
-
options: {
|
|
847
|
-
mtl: {}
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
|
|
851
|
-
// src/index.ts
|
|
852
|
-
var OBJLoader2 = {
|
|
853
|
-
...OBJLoader,
|
|
771
|
+
var OBJLoader = {
|
|
772
|
+
...OBJWorkerLoader,
|
|
854
773
|
parse: async (arrayBuffer, options) => parseOBJ(new TextDecoder().decode(arrayBuffer), options),
|
|
855
774
|
parseTextSync: (text, options) => parseOBJ(text, options)
|
|
856
775
|
};
|
|
857
|
-
var MTLLoader2 = {
|
|
858
|
-
...MTLLoader,
|
|
859
|
-
parse: async (arrayBuffer, options) => parseMTL(new TextDecoder().decode(arrayBuffer), options?.mtl),
|
|
860
|
-
parseTextSync: (text, options) => parseMTL(text, options?.mtl)
|
|
861
|
-
};
|
|
862
776
|
|
|
863
777
|
// src/workers/obj-worker.ts
|
|
864
|
-
createLoaderWorker(
|
|
778
|
+
createLoaderWorker(OBJLoader);
|
|
865
779
|
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obj-worker.js","sourceRoot":"","sources":["../../src/workers/obj-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/obj",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.10",
|
|
4
4
|
"description": "Framework-independent loader for the OBJ 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
|
+
"./obj-worker.js": {
|
|
32
|
+
"import": "./dist/obj-worker.js"
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
35
|
"sideEffects": false,
|
|
@@ -42,11 +45,12 @@
|
|
|
42
45
|
"build-worker": "esbuild src/workers/obj-worker.ts --bundle --outfile=dist/obj-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,41 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
6
|
-
import type {Mesh} from '@loaders.gl/schema';
|
|
7
|
-
import {parseOBJ} from './lib/parse-obj';
|
|
8
|
-
import type {OBJLoaderOptions} from './obj-loader';
|
|
9
|
-
import {OBJLoader as OBJWorkerLoader} from './obj-loader';
|
|
10
|
-
|
|
11
|
-
import type {MTLMaterial} from './lib/parse-mtl';
|
|
12
|
-
import {parseMTL} from './lib/parse-mtl';
|
|
13
|
-
import type {MTLLoaderOptions} from './mtl-loader';
|
|
14
|
-
import {MTLLoader as MTLWorkerLoader} from './mtl-loader';
|
|
15
|
-
|
|
16
5
|
// OBJLoader
|
|
17
6
|
|
|
7
|
+
export {OBJFormat} from './obj-format';
|
|
18
8
|
export type {OBJLoaderOptions} from './obj-loader';
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Loader for the OBJ geometry format
|
|
24
|
-
*/
|
|
25
|
-
export const OBJLoader = {
|
|
26
|
-
...OBJWorkerLoader,
|
|
27
|
-
parse: async (arrayBuffer: ArrayBuffer, options?: OBJLoaderOptions) =>
|
|
28
|
-
parseOBJ(new TextDecoder().decode(arrayBuffer), options),
|
|
29
|
-
parseTextSync: (text: string, options?: OBJLoaderOptions) => parseOBJ(text, options)
|
|
30
|
-
} as const satisfies LoaderWithParser<Mesh, never, OBJLoaderOptions>;
|
|
9
|
+
export {OBJWorkerLoader, OBJLoader} from './obj-loader';
|
|
10
|
+
export {OBJArrowLoader} from './obj-arrow-loader';
|
|
31
11
|
|
|
32
12
|
// MTLLoader
|
|
33
13
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export const MTLLoader = {
|
|
38
|
-
...MTLWorkerLoader,
|
|
39
|
-
parse: async (arrayBuffer: ArrayBuffer, options?: MTLLoaderOptions) =>
|
|
40
|
-
parseMTL(new TextDecoder().decode(arrayBuffer), options?.mtl),
|
|
41
|
-
parseTextSync: (text: string, options?: MTLLoaderOptions) => parseMTL(text, options?.mtl)
|
|
42
|
-
} as const satisfies LoaderWithParser<MTLMaterial[], never, MTLLoaderOptions>;
|
|
14
|
+
export {MTLFormat} from './mtl-format';
|
|
15
|
+
export type {MTLLoaderOptions} from './mtl-loader';
|
|
16
|
+
export {MTLWorkerLoader, MTLLoader} from './mtl-loader';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Schema, SchemaMetadata, Field, MeshAttribute} from '@loaders.gl/schema';
|
|
6
|
-
import {getDataTypeFromArray} from '@loaders.gl/schema';
|
|
6
|
+
import {getDataTypeFromArray} from '@loaders.gl/schema-utils';
|
|
7
7
|
|
|
8
8
|
/** Get Mesh Schema */
|
|
9
9
|
export function getOBJSchema(
|
package/src/lib/parse-obj.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {Mesh, MeshAttributes} from '@loaders.gl/schema';
|
|
2
|
-
import {getMeshBoundingBox} from '@loaders.gl/schema';
|
|
2
|
+
import {getMeshBoundingBox} from '@loaders.gl/schema-utils';
|
|
3
3
|
import {parseOBJMeshes} from './parse-obj-meshes';
|
|
4
4
|
import {getOBJSchema} from './get-obj-schema';
|
|
5
5
|
|
|
6
|
-
export function parseOBJ(text, options): Mesh {
|
|
6
|
+
export function parseOBJ(text: string, options?): Mesh {
|
|
7
7
|
const {meshes} = parseOBJMeshes(text);
|
|
8
8
|
|
|
9
9
|
// @ts-expect-error
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* The MTL material format
|
|
9
|
+
* A Wavefront .mtl file specifying materials
|
|
10
|
+
*/
|
|
11
|
+
export const MTLFormat = {
|
|
12
|
+
name: 'MTL',
|
|
13
|
+
id: 'mtl',
|
|
14
|
+
module: 'mtl',
|
|
15
|
+
extensions: ['mtl'],
|
|
16
|
+
mimeTypes: ['text/plain']
|
|
17
|
+
} as const satisfies Format;
|
package/src/mtl-loader.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
5
6
|
import type {MTLMaterial, ParseMTLOptions} from './lib/parse-mtl';
|
|
7
|
+
import {parseMTL} from './lib/parse-mtl';
|
|
8
|
+
import {MTLFormat} from './mtl-format';
|
|
6
9
|
|
|
7
10
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
11
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
@@ -16,19 +19,28 @@ export type MTLLoaderOptions = LoaderOptions & {
|
|
|
16
19
|
* Loader for the MTL material format
|
|
17
20
|
* Parses a Wavefront .mtl file specifying materials
|
|
18
21
|
*/
|
|
19
|
-
export const
|
|
22
|
+
export const MTLWorkerLoader = {
|
|
23
|
+
...MTLFormat,
|
|
24
|
+
|
|
20
25
|
dataType: null as unknown as MTLMaterial[],
|
|
21
26
|
batchType: null as never,
|
|
22
27
|
|
|
23
|
-
name: 'MTL',
|
|
24
|
-
id: 'mtl',
|
|
25
|
-
module: 'mtl',
|
|
26
28
|
version: VERSION,
|
|
27
29
|
worker: true,
|
|
28
|
-
extensions: ['mtl'],
|
|
29
|
-
mimeTypes: ['text/plain'],
|
|
30
30
|
testText: (text: string): boolean => text.includes('newmtl'),
|
|
31
31
|
options: {
|
|
32
32
|
mtl: {}
|
|
33
33
|
}
|
|
34
34
|
} as const satisfies Loader<MTLMaterial[], never, LoaderOptions>;
|
|
35
|
+
|
|
36
|
+
// MTLLoader
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Loader for the MTL material format
|
|
40
|
+
*/
|
|
41
|
+
export const MTLLoader = {
|
|
42
|
+
...MTLWorkerLoader,
|
|
43
|
+
parse: async (arrayBuffer: ArrayBuffer, options?: MTLLoaderOptions) =>
|
|
44
|
+
parseMTL(new TextDecoder().decode(arrayBuffer), options?.mtl),
|
|
45
|
+
parseTextSync: (text: string, options?: MTLLoaderOptions) => parseMTL(text, options?.mtl)
|
|
46
|
+
} as const satisfies LoaderWithParser<MTLMaterial[], never, MTLLoaderOptions>;
|