@loaders.gl/textures 4.2.0-alpha.5 → 4.2.0-beta.1
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/basis-loader.d.ts +61 -3
- package/dist/basis-loader.d.ts.map +1 -1
- package/dist/basis-loader.js +5 -3
- package/dist/basis-worker-node.js +348 -335
- package/dist/basis-worker.js +32 -49
- package/dist/compressed-texture-loader.d.ts +43 -4
- package/dist/compressed-texture-loader.d.ts.map +1 -1
- package/dist/compressed-texture-loader.js +2 -0
- package/dist/compressed-texture-worker.js +33 -47
- package/dist/compressed-texture-writer.d.ts +24 -2
- package/dist/compressed-texture-writer.d.ts.map +1 -1
- package/dist/compressed-texture-writer.js +0 -8
- package/dist/crunch-loader.d.ts +23 -2
- package/dist/crunch-loader.d.ts.map +1 -1
- package/dist/crunch-loader.js +2 -0
- package/dist/crunch-worker.js +33 -47
- package/dist/dist.dev.js +96 -81
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +23 -15
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ktx2-basis-writer-worker-node.js +329 -328
- package/dist/ktx2-basis-writer-worker.js +15 -43
- package/dist/ktx2-basis-writer.d.ts +18 -3
- package/dist/ktx2-basis-writer.d.ts.map +1 -1
- package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/basis-module-loader.js +6 -4
- package/dist/lib/parsers/crunch-module-loader.d.ts +2 -1
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js +6 -4
- package/dist/lib/utils/version.js +1 -1
- package/dist/npy-loader.d.ts +40 -5
- package/dist/npy-loader.d.ts.map +1 -1
- package/dist/npy-loader.js +2 -0
- package/dist/npy-worker.js +6 -2
- package/dist/workers/crunch-worker.d.ts +15 -17
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/package.json +7 -9
- package/src/basis-loader.ts +27 -7
- package/src/compressed-texture-loader.ts +14 -6
- package/src/compressed-texture-writer.ts +5 -15
- package/src/crunch-loader.ts +10 -2
- package/src/index.ts +10 -1
- package/src/ktx2-basis-writer.ts +2 -2
- package/src/lib/parsers/basis-module-loader.ts +6 -4
- package/src/lib/parsers/crunch-module-loader.ts +8 -6
- package/src/npy-loader.ts +13 -5
|
@@ -1,38 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
|
|
29
|
-
// (disabled):../worker-utils/src/lib/node/require-utils.node
|
|
30
|
-
var require_require_utils = __commonJS({
|
|
31
|
-
"(disabled):../worker-utils/src/lib/node/require-utils.node"() {
|
|
32
|
-
"use strict";
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
3
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
37
4
|
function getVersion() {
|
|
38
5
|
if (!globalThis._loadersgl_?.version) {
|
|
@@ -43,7 +10,7 @@
|
|
|
43
10
|
);
|
|
44
11
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
12
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.2.0-alpha.
|
|
13
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.6";
|
|
47
14
|
}
|
|
48
15
|
}
|
|
49
16
|
return globalThis._loadersgl_.version;
|
|
@@ -136,7 +103,9 @@
|
|
|
136
103
|
}
|
|
137
104
|
getParentPort().then((parentPort2) => {
|
|
138
105
|
if (parentPort2) {
|
|
139
|
-
parentPort2.on("message",
|
|
106
|
+
parentPort2.on("message", (message) => {
|
|
107
|
+
handleMessage(message);
|
|
108
|
+
});
|
|
140
109
|
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
141
110
|
} else {
|
|
142
111
|
globalThis.onmessage = handleMessage;
|
|
@@ -194,7 +163,6 @@
|
|
|
194
163
|
}
|
|
195
164
|
|
|
196
165
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
197
|
-
var node = __toESM(require_require_utils(), 1);
|
|
198
166
|
var loadLibraryPromises = {};
|
|
199
167
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
200
168
|
if (moduleName) {
|
|
@@ -231,7 +199,8 @@
|
|
|
231
199
|
}
|
|
232
200
|
if (!isBrowser) {
|
|
233
201
|
try {
|
|
234
|
-
|
|
202
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
203
|
+
return await requireFromFile?.(libraryUrl);
|
|
235
204
|
} catch (error) {
|
|
236
205
|
console.error(error);
|
|
237
206
|
return null;
|
|
@@ -245,7 +214,8 @@
|
|
|
245
214
|
}
|
|
246
215
|
function loadLibraryFromString(scriptSource, id) {
|
|
247
216
|
if (!isBrowser) {
|
|
248
|
-
|
|
217
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
218
|
+
return requireFromString?.(scriptSource, id);
|
|
249
219
|
}
|
|
250
220
|
if (isWorker) {
|
|
251
221
|
eval.call(globalThis, scriptSource);
|
|
@@ -262,22 +232,24 @@
|
|
|
262
232
|
return null;
|
|
263
233
|
}
|
|
264
234
|
async function loadAsArrayBuffer(url) {
|
|
265
|
-
|
|
235
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
236
|
+
if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
266
237
|
const response = await fetch(url);
|
|
267
238
|
return await response.arrayBuffer();
|
|
268
239
|
}
|
|
269
|
-
return await (
|
|
240
|
+
return await readFileAsArrayBuffer(url);
|
|
270
241
|
}
|
|
271
242
|
async function loadAsText(url) {
|
|
272
|
-
|
|
243
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
244
|
+
if (isBrowser || !readFileAsText || url.startsWith("http")) {
|
|
273
245
|
const response = await fetch(url);
|
|
274
246
|
return await response.text();
|
|
275
247
|
}
|
|
276
|
-
return await (
|
|
248
|
+
return await readFileAsText(url);
|
|
277
249
|
}
|
|
278
250
|
|
|
279
251
|
// src/lib/utils/version.ts
|
|
280
|
-
var VERSION2 = true ? "4.2.0-alpha.
|
|
252
|
+
var VERSION2 = true ? "4.2.0-alpha.6" : "latest";
|
|
281
253
|
|
|
282
254
|
// src/lib/parsers/basis-module-loader.ts
|
|
283
255
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { encodeKTX2BasisTexture } from "./lib/encoders/encode-ktx2-basis-texture.js";
|
|
3
3
|
/** @todo should be in basis sub-object */
|
|
4
4
|
export type KTX2BasisWriterOptions = WriterOptions & {
|
|
5
5
|
['ktx2-basis-writer']?: {
|
|
@@ -13,5 +13,20 @@ export type KTX2BasisWriterOptions = WriterOptions & {
|
|
|
13
13
|
* Basis Universal Supercompressed GPU Texture.
|
|
14
14
|
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureSetDefinitionFormat.cmn.md
|
|
15
15
|
*/
|
|
16
|
-
export declare const KTX2BasisWriter:
|
|
16
|
+
export declare const KTX2BasisWriter: {
|
|
17
|
+
readonly name: "Basis Universal Supercompressed GPU Texture";
|
|
18
|
+
readonly id: "ktx2-basis-writer";
|
|
19
|
+
readonly module: "textures";
|
|
20
|
+
readonly version: any;
|
|
21
|
+
readonly extensions: ["ktx2"];
|
|
22
|
+
readonly options: {
|
|
23
|
+
readonly "ktx2-basis-writer": {
|
|
24
|
+
readonly useSRGB: false;
|
|
25
|
+
readonly qualityLevel: 10;
|
|
26
|
+
readonly encodeUASTC: false;
|
|
27
|
+
readonly mipmaps: false;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
readonly encode: typeof encodeKTX2BasisTexture;
|
|
31
|
+
};
|
|
17
32
|
//# sourceMappingURL=ktx2-basis-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktx2-basis-writer.d.ts","sourceRoot":"","sources":["../src/ktx2-basis-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ktx2-basis-writer.d.ts","sourceRoot":"","sources":["../src/ktx2-basis-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG/E,OAAO,EAAC,sBAAsB,EAAC,oDAAiD;AAEhF,0CAA0C;AAC1C,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,CAAC,mBAAmB,CAAC,CAAC,EAAE;QACtB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;CAiB0D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basis-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/basis-module-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basis-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/basis-module-loader.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB;IACnC,gDAAgD;;IAEhD,mDAAmD;;IAEnD,6CAA6C;;IAE7C,gDAAgD;;CAEjD,CAAC;AAIF;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,KAAA,gBAStD;AA+CD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,KAAA,gBAQnD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { registerJSModules, getJSModuleOrNull } from '@loaders.gl/loader-utils';
|
|
4
5
|
import { loadLibrary } from '@loaders.gl/worker-utils';
|
|
5
6
|
export const BASIS_EXTERNAL_LIBRARIES = {
|
|
6
7
|
/** Basis transcoder, javascript wrapper part */
|
|
@@ -19,11 +20,12 @@ let loadBasisTranscoderPromise;
|
|
|
19
20
|
* @returns {BasisFile} promise
|
|
20
21
|
*/
|
|
21
22
|
export async function loadBasisTranscoderModule(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
registerJSModules(options.modules);
|
|
24
|
+
const basis = getJSModuleOrNull('basis');
|
|
25
|
+
if (basis) {
|
|
26
|
+
return basis;
|
|
25
27
|
}
|
|
26
|
-
loadBasisTranscoderPromise
|
|
28
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
27
29
|
return await loadBasisTranscoderPromise;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
1
2
|
export declare const CRUNCH_EXTERNAL_LIBRARIES: {
|
|
2
3
|
/** Crunch decoder library. It is used as dynamically imported script */
|
|
3
4
|
DECODER: string;
|
|
@@ -7,5 +8,5 @@ export declare const CRUNCH_EXTERNAL_LIBRARIES: {
|
|
|
7
8
|
* @param options - loader options
|
|
8
9
|
* @returns Promise of module object
|
|
9
10
|
*/
|
|
10
|
-
export declare function loadCrunchModule(options:
|
|
11
|
+
export declare function loadCrunchModule(options: LoaderOptions): Promise<any>;
|
|
11
12
|
//# sourceMappingURL=crunch-module-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crunch-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/crunch-module-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crunch-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/crunch-module-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,aAAa,EAAoB,MAAM,0BAA0B,CAAC;AAG7F,eAAO,MAAM,yBAAyB;IACpC,wEAAwE;;CAEzE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAQ3E"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// @ts-nocheck
|
|
5
|
+
import { getJSModuleOrNull, registerJSModules } from '@loaders.gl/loader-utils';
|
|
5
6
|
import { loadLibrary } from '@loaders.gl/worker-utils';
|
|
6
7
|
export const CRUNCH_EXTERNAL_LIBRARIES = {
|
|
7
8
|
/** Crunch decoder library. It is used as dynamically imported script */
|
|
@@ -13,9 +14,10 @@ export const CRUNCH_EXTERNAL_LIBRARIES = {
|
|
|
13
14
|
* @returns Promise of module object
|
|
14
15
|
*/
|
|
15
16
|
export async function loadCrunchModule(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
registerJSModules(options.modules);
|
|
18
|
+
const crunch = getJSModuleOrNull('crunch');
|
|
19
|
+
if (crunch) {
|
|
20
|
+
return crunch;
|
|
19
21
|
}
|
|
20
22
|
return loadCrunch(options);
|
|
21
23
|
}
|
|
@@ -32,7 +34,7 @@ async function loadCrunch(options) {
|
|
|
32
34
|
let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, 'textures', options);
|
|
33
35
|
// Depends on how import happened...
|
|
34
36
|
// @ts-ignore TS2339: Property does not exist on type
|
|
35
|
-
loadCrunchDecoder
|
|
37
|
+
loadCrunchDecoder ||= globalThis.LoadCrunchDecoder;
|
|
36
38
|
crunchModule = loadCrunchDecoder();
|
|
37
39
|
return crunchModule;
|
|
38
40
|
}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
export const VERSION = typeof "4.2.0-alpha.
|
|
7
|
+
export const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
|
package/dist/npy-loader.d.ts
CHANGED
|
@@ -1,14 +1,49 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { NPYTile } from "./lib/parsers/parse-npy.js";
|
|
1
|
+
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { parseNPY, NPYTile } from "./lib/parsers/parse-npy.js";
|
|
3
|
+
/** NPYLoader for numpy tiles */
|
|
3
4
|
export type NPYLoaderOptions = LoaderOptions & {
|
|
4
|
-
|
|
5
|
+
/** NPYLoader for numpy tiles */
|
|
6
|
+
npy?: {
|
|
7
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
8
|
+
workerUrl?: string;
|
|
9
|
+
};
|
|
5
10
|
};
|
|
6
11
|
/**
|
|
7
12
|
* Worker loader for numpy "tiles"
|
|
8
13
|
*/
|
|
9
|
-
export declare const NPYWorkerLoader:
|
|
14
|
+
export declare const NPYWorkerLoader: {
|
|
15
|
+
readonly dataType: NPYTile;
|
|
16
|
+
readonly batchType: never;
|
|
17
|
+
readonly name: "NPY";
|
|
18
|
+
readonly id: "npy";
|
|
19
|
+
readonly module: "textures";
|
|
20
|
+
readonly version: any;
|
|
21
|
+
readonly worker: true;
|
|
22
|
+
readonly extensions: ["npy"];
|
|
23
|
+
readonly mimeTypes: [];
|
|
24
|
+
readonly tests: [ArrayBufferLike];
|
|
25
|
+
readonly options: {
|
|
26
|
+
readonly npy: {};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
10
29
|
/**
|
|
11
30
|
* Loader for numpy "tiles"
|
|
12
31
|
*/
|
|
13
|
-
export declare const NPYLoader:
|
|
32
|
+
export declare const NPYLoader: {
|
|
33
|
+
readonly parseSync: typeof parseNPY;
|
|
34
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options?: LoaderOptions) => Promise<NPYTile>;
|
|
35
|
+
readonly dataType: NPYTile;
|
|
36
|
+
readonly batchType: never;
|
|
37
|
+
readonly name: "NPY";
|
|
38
|
+
readonly id: "npy";
|
|
39
|
+
readonly module: "textures";
|
|
40
|
+
readonly version: any;
|
|
41
|
+
readonly worker: true;
|
|
42
|
+
readonly extensions: ["npy"];
|
|
43
|
+
readonly mimeTypes: [];
|
|
44
|
+
readonly tests: [ArrayBufferLike];
|
|
45
|
+
readonly options: {
|
|
46
|
+
readonly npy: {};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
14
49
|
//# sourceMappingURL=npy-loader.d.ts.map
|
package/dist/npy-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npy-loader.d.ts","sourceRoot":"","sources":["../src/npy-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"npy-loader.d.ts","sourceRoot":"","sources":["../src/npy-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA2B,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,mCAAgC;AAK1D,gCAAgC;AAChC,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,gCAAgC;IAChC,GAAG,CAAC,EAAE;QACJ,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;CAeiC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,SAAS;;kCAGO,WAAW,YAAY,aAAa;;;;;;;;;;;;;;CACA,CAAC"}
|
package/dist/npy-loader.js
CHANGED
package/dist/npy-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
// src/lib/utils/version.ts
|
|
4
|
-
var VERSION = true ? "4.2.0-alpha.
|
|
4
|
+
var VERSION = true ? "4.2.0-alpha.6" : "latest";
|
|
5
5
|
|
|
6
6
|
// src/lib/parsers/parse-npy.ts
|
|
7
7
|
var a = new Uint32Array([305419896]);
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
// src/npy-loader.ts
|
|
66
66
|
var NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
67
67
|
var NPYWorkerLoader = {
|
|
68
|
+
dataType: null,
|
|
69
|
+
batchType: null,
|
|
68
70
|
name: "NPY",
|
|
69
71
|
id: "npy",
|
|
70
72
|
module: "textures",
|
|
@@ -142,7 +144,9 @@
|
|
|
142
144
|
}
|
|
143
145
|
getParentPort().then((parentPort2) => {
|
|
144
146
|
if (parentPort2) {
|
|
145
|
-
parentPort2.on("message",
|
|
147
|
+
parentPort2.on("message", (message) => {
|
|
148
|
+
handleMessage(message);
|
|
149
|
+
});
|
|
146
150
|
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
147
151
|
} else {
|
|
148
152
|
globalThis.onmessage = handleMessage;
|
|
@@ -4,22 +4,20 @@ import { parseCrunch } from "../lib/parsers/parse-crunch.js";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const CrunchLoaderWithParser: {
|
|
6
6
|
parse: typeof parseCrunch;
|
|
7
|
-
dataType
|
|
8
|
-
batchType
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
supported?: boolean | undefined;
|
|
23
|
-
testText?: ((string: string) => boolean) | undefined;
|
|
7
|
+
dataType: import("@loaders.gl/schema").TextureLevel[];
|
|
8
|
+
batchType: never;
|
|
9
|
+
id: "crunch";
|
|
10
|
+
name: "Crunch";
|
|
11
|
+
module: "textures";
|
|
12
|
+
version: any;
|
|
13
|
+
worker: true;
|
|
14
|
+
extensions: ["crn"];
|
|
15
|
+
mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"];
|
|
16
|
+
binary: true;
|
|
17
|
+
options: {
|
|
18
|
+
readonly crunch: {
|
|
19
|
+
readonly libraryPath: "libs/";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
24
22
|
};
|
|
25
23
|
//# sourceMappingURL=crunch-worker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crunch-worker.d.ts","sourceRoot":"","sources":["../../src/workers/crunch-worker.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,WAAW,EAAC,uCAAoC;AAExD;;GAEG;AACH,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"crunch-worker.d.ts","sourceRoot":"","sources":["../../src/workers/crunch-worker.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,WAAW,EAAC,uCAAoC;AAExD;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;CAGlC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/textures",
|
|
3
|
-
"version": "4.2.0-
|
|
3
|
+
"version": "4.2.0-beta.1",
|
|
4
4
|
"description": "Framework-independent loaders for compressed and super compressed (basis) textures ",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -54,18 +54,16 @@
|
|
|
54
54
|
"build-crunch-worker": "esbuild src/workers/crunch-worker.ts --outfile=dist/crunch-worker.js --target=esnext --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@loaders.gl/images": "4.2.0-
|
|
58
|
-
"@loaders.gl/loader-utils": "4.2.0-
|
|
59
|
-
"@loaders.gl/schema": "4.2.0-
|
|
60
|
-
"@loaders.gl/worker-utils": "4.2.0-
|
|
57
|
+
"@loaders.gl/images": "4.2.0-beta.1",
|
|
58
|
+
"@loaders.gl/loader-utils": "4.2.0-beta.1",
|
|
59
|
+
"@loaders.gl/schema": "4.2.0-beta.1",
|
|
60
|
+
"@loaders.gl/worker-utils": "4.2.0-beta.1",
|
|
61
|
+
"@math.gl/types": "^4.0.1",
|
|
61
62
|
"ktx-parse": "^0.0.4",
|
|
62
63
|
"texture-compressor": "^1.0.2"
|
|
63
64
|
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@loaders.gl/polyfills": "4.2.0-alpha.5"
|
|
66
|
-
},
|
|
67
65
|
"peerDependencies": {
|
|
68
66
|
"@loaders.gl/core": "^4.0.0"
|
|
69
67
|
},
|
|
70
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905"
|
|
71
69
|
}
|
package/src/basis-loader.ts
CHANGED
|
@@ -7,10 +7,30 @@ import type {TextureLevel} from '@loaders.gl/schema';
|
|
|
7
7
|
import {VERSION} from './lib/utils/version';
|
|
8
8
|
import parseBasis from './lib/parsers/parse-basis';
|
|
9
9
|
|
|
10
|
+
/** Options for the BasisLoader */
|
|
11
|
+
export type BasisLoaderOptions = LoaderOptions & {
|
|
12
|
+
/** Options for the BasisLoader */
|
|
13
|
+
basis?: {
|
|
14
|
+
/** Format for texture data. auto selects based on platform caps (but gl context doesn't exist on a worker thread) */
|
|
15
|
+
format: 'auto' | 'rgb565' | 'etc1s' | 'etc2' | 'astc' | 'dxt1' | 'dxt3' | 'dxt5';
|
|
16
|
+
/** @deprecated specify path of basis library */
|
|
17
|
+
libraryPath?: string;
|
|
18
|
+
/** What container format is used? */
|
|
19
|
+
containerFormat: 'auto' | 'ktx2' | 'basis';
|
|
20
|
+
/** What module to use for transcoding? */
|
|
21
|
+
module?: 'transcoder' | 'encoder';
|
|
22
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
23
|
+
workerUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
10
27
|
/**
|
|
11
28
|
* Worker loader for Basis super compressed textures
|
|
12
29
|
*/
|
|
13
|
-
export const BasisWorkerLoader
|
|
30
|
+
export const BasisWorkerLoader = {
|
|
31
|
+
dataType: null as unknown as TextureLevel[][],
|
|
32
|
+
batchType: null as never,
|
|
33
|
+
|
|
14
34
|
name: 'Basis',
|
|
15
35
|
id: 'basis',
|
|
16
36
|
module: 'textures',
|
|
@@ -22,18 +42,18 @@ export const BasisWorkerLoader: Loader<TextureLevel[][], never, LoaderOptions> =
|
|
|
22
42
|
binary: true,
|
|
23
43
|
options: {
|
|
24
44
|
basis: {
|
|
25
|
-
format: 'auto',
|
|
45
|
+
format: 'auto',
|
|
26
46
|
libraryPath: 'libs/',
|
|
27
|
-
containerFormat: 'auto',
|
|
28
|
-
module: 'transcoder'
|
|
47
|
+
containerFormat: 'auto',
|
|
48
|
+
module: 'transcoder'
|
|
29
49
|
}
|
|
30
50
|
}
|
|
31
|
-
}
|
|
51
|
+
} as const satisfies Loader<TextureLevel[][], never, BasisLoaderOptions>;
|
|
32
52
|
|
|
33
53
|
/**
|
|
34
54
|
* Loader for Basis super compressed textures
|
|
35
55
|
*/
|
|
36
|
-
export const BasisLoader
|
|
56
|
+
export const BasisLoader = {
|
|
37
57
|
...BasisWorkerLoader,
|
|
38
58
|
parse: parseBasis
|
|
39
|
-
}
|
|
59
|
+
} as const satisfies LoaderWithParser<TextureLevel[][], never, LoaderOptions>;
|
|
@@ -7,17 +7,25 @@ import {VERSION} from './lib/utils/version';
|
|
|
7
7
|
import {parseCompressedTexture} from './lib/parsers/parse-compressed-texture';
|
|
8
8
|
import parseBasis from './lib/parsers/parse-basis';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** Options for the CompressedTextureLoader */
|
|
11
|
+
export type CompressedTextureLoaderOptions = {
|
|
11
12
|
'compressed-texture'?: {
|
|
13
|
+
/** @deprecated Specify path to libraries */
|
|
12
14
|
libraryPath?: string;
|
|
15
|
+
/** Whether to use Basis decoding */
|
|
13
16
|
useBasis?: boolean;
|
|
17
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
18
|
+
workerUrl?: string;
|
|
14
19
|
};
|
|
15
20
|
};
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* Worker Loader for KTX, DDS, and PVR texture container formats
|
|
19
24
|
*/
|
|
20
|
-
export const CompressedTextureWorkerLoader
|
|
25
|
+
export const CompressedTextureWorkerLoader = {
|
|
26
|
+
dataType: null as unknown as any,
|
|
27
|
+
batchType: null as never,
|
|
28
|
+
|
|
21
29
|
name: 'Texture Containers',
|
|
22
30
|
id: 'compressed-texture',
|
|
23
31
|
module: 'textures',
|
|
@@ -43,14 +51,14 @@ export const CompressedTextureWorkerLoader: Loader<any, never, TextureLoaderOpti
|
|
|
43
51
|
useBasis: false
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
}
|
|
54
|
+
} as const satisfies Loader<any, never, CompressedTextureLoaderOptions>;
|
|
47
55
|
|
|
48
56
|
/**
|
|
49
57
|
* Loader for KTX, DDS, and PVR texture container formats
|
|
50
58
|
*/
|
|
51
|
-
export const CompressedTextureLoader
|
|
59
|
+
export const CompressedTextureLoader = {
|
|
52
60
|
...CompressedTextureWorkerLoader,
|
|
53
|
-
parse: async (arrayBuffer: ArrayBuffer, options?:
|
|
61
|
+
parse: async (arrayBuffer: ArrayBuffer, options?: CompressedTextureLoaderOptions) => {
|
|
54
62
|
if (options?.['compressed-texture']?.useBasis) {
|
|
55
63
|
// @ts-expect-error TODO not allowed to modify inputs
|
|
56
64
|
options.basis = {
|
|
@@ -68,4 +76,4 @@ export const CompressedTextureLoader: LoaderWithParser<any, never, TextureLoader
|
|
|
68
76
|
}
|
|
69
77
|
return parseCompressedTexture(arrayBuffer);
|
|
70
78
|
}
|
|
71
|
-
}
|
|
79
|
+
} as const satisfies LoaderWithParser<any, never, CompressedTextureLoaderOptions>;
|
|
@@ -6,8 +6,11 @@ import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
|
6
6
|
import {VERSION} from './lib/utils/version';
|
|
7
7
|
import {encodeImageURLToCompressedTextureURL} from './lib/encoders/encode-texture';
|
|
8
8
|
|
|
9
|
+
/** Compressed Texture writer options */
|
|
9
10
|
export type CompressedTextureWriterOptions = WriterOptions & {
|
|
11
|
+
/** @deprecated current working directory */
|
|
10
12
|
cwd?: string;
|
|
13
|
+
/** Compressed Texture writer options */
|
|
11
14
|
texture?: {
|
|
12
15
|
format: string;
|
|
13
16
|
compression: string;
|
|
@@ -21,11 +24,7 @@ export type CompressedTextureWriterOptions = WriterOptions & {
|
|
|
21
24
|
/**
|
|
22
25
|
* DDS Texture Container Exporter
|
|
23
26
|
*/
|
|
24
|
-
export const CompressedTextureWriter
|
|
25
|
-
unknown,
|
|
26
|
-
unknown,
|
|
27
|
-
CompressedTextureWriterOptions
|
|
28
|
-
> = {
|
|
27
|
+
export const CompressedTextureWriter = {
|
|
29
28
|
name: 'DDS Texture Container',
|
|
30
29
|
id: 'dds',
|
|
31
30
|
module: 'textures',
|
|
@@ -48,13 +47,4 @@ export const CompressedTextureWriter: WriterWithEncoder<
|
|
|
48
47
|
encode() {
|
|
49
48
|
throw new Error('Not implemented');
|
|
50
49
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// TYPE TESTS - TODO find a better way than exporting junk
|
|
54
|
-
// export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {
|
|
55
|
-
// encodeURLtoURL: (
|
|
56
|
-
// inputUrl: string,
|
|
57
|
-
// outputUrl: string,
|
|
58
|
-
// options?: CompressedTextureWriterOptions
|
|
59
|
-
// ) => Promise<string>;
|
|
60
|
-
// } = CompressedTextureWriter;
|
|
50
|
+
} as const satisfies WriterWithEncoder<unknown, unknown, CompressedTextureWriterOptions>;
|
package/src/crunch-loader.ts
CHANGED
|
@@ -6,9 +6,14 @@ import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
|
6
6
|
import type {TextureLevel} from '@loaders.gl/schema';
|
|
7
7
|
import {VERSION} from './lib/utils/version';
|
|
8
8
|
|
|
9
|
+
/** CrunchLoader options */
|
|
9
10
|
export type CrunchLoaderOptions = LoaderOptions & {
|
|
11
|
+
/** CrunchLoader options */
|
|
10
12
|
crunch?: {
|
|
13
|
+
/** @deprecated Specify where to load the Crunch decoder library */
|
|
11
14
|
libraryPath?: string;
|
|
15
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
16
|
+
workerUrl?: string;
|
|
12
17
|
};
|
|
13
18
|
};
|
|
14
19
|
|
|
@@ -16,7 +21,10 @@ export type CrunchLoaderOptions = LoaderOptions & {
|
|
|
16
21
|
* Worker loader for the Crunch compressed texture container format
|
|
17
22
|
* @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
|
|
18
23
|
*/
|
|
19
|
-
export const CrunchLoader
|
|
24
|
+
export const CrunchLoader = {
|
|
25
|
+
dataType: null as unknown as TextureLevel[],
|
|
26
|
+
batchType: null as never,
|
|
27
|
+
|
|
20
28
|
id: 'crunch',
|
|
21
29
|
name: 'Crunch',
|
|
22
30
|
module: 'textures',
|
|
@@ -30,4 +38,4 @@ export const CrunchLoader: Loader<TextureLevel[], never, CrunchLoaderOptions> =
|
|
|
30
38
|
libraryPath: 'libs/'
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
|
-
}
|
|
41
|
+
} as const satisfies Loader<TextureLevel[], never, CrunchLoaderOptions>;
|
package/src/index.ts
CHANGED
|
@@ -6,12 +6,18 @@ import {VERSION} from './lib/utils/version';
|
|
|
6
6
|
|
|
7
7
|
// Types
|
|
8
8
|
export type {GPUTextureFormat} from '@loaders.gl/schema';
|
|
9
|
-
export type {TextureLoaderOptions} from './compressed-texture-loader';
|
|
10
9
|
|
|
11
10
|
// Loaders
|
|
11
|
+
export type {BasisLoaderOptions} from './basis-loader';
|
|
12
12
|
export {BasisLoader, BasisWorkerLoader} from './basis-loader';
|
|
13
|
+
|
|
14
|
+
export type {CompressedTextureLoaderOptions} from './compressed-texture-loader';
|
|
13
15
|
export {CompressedTextureLoader, CompressedTextureWorkerLoader} from './compressed-texture-loader';
|
|
16
|
+
|
|
17
|
+
export type {CrunchLoaderOptions} from './crunch-loader';
|
|
14
18
|
export {CrunchLoader} from './crunch-loader';
|
|
19
|
+
|
|
20
|
+
export type {NPYLoaderOptions} from './npy-loader';
|
|
15
21
|
export {NPYLoader, NPYWorkerLoader} from './npy-loader';
|
|
16
22
|
|
|
17
23
|
// Module constants
|
|
@@ -48,4 +54,7 @@ export {selectSupportedBasisFormat} from './lib/parsers/parse-basis';
|
|
|
48
54
|
export {getSupportedGPUTextureFormats} from './lib/utils/texture-formats';
|
|
49
55
|
|
|
50
56
|
// DEPRECATED
|
|
57
|
+
// @deprecated
|
|
51
58
|
export {CrunchLoader as CrunchWorkerLoader} from './crunch-loader';
|
|
59
|
+
// @deprecated
|
|
60
|
+
export type {CompressedTextureLoaderOptions as TextureLoaderOptions} from './compressed-texture-loader';
|
package/src/ktx2-basis-writer.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type KTX2BasisWriterOptions = WriterOptions & {
|
|
|
21
21
|
* Basis Universal Supercompressed GPU Texture.
|
|
22
22
|
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureSetDefinitionFormat.cmn.md
|
|
23
23
|
*/
|
|
24
|
-
export const KTX2BasisWriter
|
|
24
|
+
export const KTX2BasisWriter = {
|
|
25
25
|
name: 'Basis Universal Supercompressed GPU Texture',
|
|
26
26
|
id: 'ktx2-basis-writer',
|
|
27
27
|
module: 'textures',
|
|
@@ -38,4 +38,4 @@ export const KTX2BasisWriter: WriterWithEncoder<ImageDataType, unknown, KTX2Basi
|
|
|
38
38
|
},
|
|
39
39
|
|
|
40
40
|
encode: encodeKTX2BasisTexture
|
|
41
|
-
}
|
|
41
|
+
} as const satisfies WriterWithEncoder<ImageDataType, unknown, KTX2BasisWriterOptions>;
|