@loaders.gl/textures 4.0.0-alpha.18 → 4.0.0-alpha.19
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-worker-node.js +26 -22
- package/dist/basis-worker.js +23 -19
- package/dist/compressed-texture-worker.js +23 -19
- package/dist/crunch-worker.js +17 -13
- package/dist/dist.min.js +51 -26
- package/dist/es5/index.js +14 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/ktx2-basis-writer.js +4 -2
- package/dist/es5/ktx2-basis-writer.js.map +1 -1
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js +6 -5
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/es5/lib/parsers/basis-module-loader.js +12 -7
- package/dist/es5/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/es5/lib/parsers/crunch-module-loader.js +6 -1
- package/dist/es5/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/workers/ktx2-basis-writer-worker-node.js.map +1 -1
- package/dist/es5/workers/ktx2-basis-writer-worker.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ktx2-basis-writer.js +6 -4
- package/dist/esm/ktx2-basis-writer.js.map +1 -1
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js +1 -1
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/esm/lib/parsers/basis-module-loader.js +8 -5
- package/dist/esm/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/esm/lib/parsers/crunch-module-loader.js +4 -1
- package/dist/esm/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/workers/ktx2-basis-writer-worker-node.js.map +1 -1
- package/dist/esm/workers/ktx2-basis-writer-worker.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/ktx2-basis-writer-worker-node.js +36 -25
- package/dist/ktx2-basis-writer-worker.js +33 -22
- package/dist/ktx2-basis-writer.d.ts +8 -6
- package/dist/ktx2-basis-writer.d.ts.map +1 -1
- package/dist/ktx2-basis-writer.js +6 -4
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +1 -1
- package/dist/lib/parsers/basis-module-loader.d.ts +10 -0
- package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/basis-module-loader.js +15 -11
- package/dist/lib/parsers/crunch-module-loader.d.ts +4 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js +6 -2
- package/dist/npy-worker.js +1 -1
- package/package.json +7 -7
- package/src/index.ts +4 -0
- package/src/ktx2-basis-writer.ts +14 -10
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +6 -1
- package/src/lib/parsers/basis-module-loader.ts +14 -11
- package/src/lib/parsers/crunch-module-loader.ts +6 -1
- package/src/workers/ktx2-basis-writer-worker-node.ts +2 -2
- package/src/workers/ktx2-basis-writer-worker.ts +2 -2
|
@@ -21408,7 +21408,7 @@ var require_cookie = __commonJS({
|
|
|
21408
21408
|
var Store = require_store().Store;
|
|
21409
21409
|
var MemoryCookieStore = require_memstore().MemoryCookieStore;
|
|
21410
21410
|
var pathMatch = require_pathMatch().pathMatch;
|
|
21411
|
-
var
|
|
21411
|
+
var VERSION4 = require_version();
|
|
21412
21412
|
var punycode;
|
|
21413
21413
|
try {
|
|
21414
21414
|
punycode = require("punycode");
|
|
@@ -22225,7 +22225,7 @@ var require_cookie = __commonJS({
|
|
|
22225
22225
|
type = null;
|
|
22226
22226
|
}
|
|
22227
22227
|
var serialized = {
|
|
22228
|
-
version: "tough-cookie@" +
|
|
22228
|
+
version: "tough-cookie@" + VERSION4,
|
|
22229
22229
|
storeType: type,
|
|
22230
22230
|
rejectPublicSuffixes: !!this.rejectPublicSuffixes,
|
|
22231
22231
|
cookies: []
|
|
@@ -22377,7 +22377,7 @@ var require_cookie = __commonJS({
|
|
|
22377
22377
|
CAN_BE_SYNC.forEach(function(method) {
|
|
22378
22378
|
CookieJar.prototype[method + "Sync"] = syncWrap(method);
|
|
22379
22379
|
});
|
|
22380
|
-
exports2.version =
|
|
22380
|
+
exports2.version = VERSION4;
|
|
22381
22381
|
exports2.CookieJar = CookieJar;
|
|
22382
22382
|
exports2.Cookie = Cookie;
|
|
22383
22383
|
exports2.Store = Store;
|
|
@@ -63127,7 +63127,7 @@ if (!("allSettled" in Promise)) {
|
|
|
63127
63127
|
}
|
|
63128
63128
|
|
|
63129
63129
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
63130
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
63130
|
+
var VERSION = true ? "4.0.0-alpha.19" : DEFAULT_VERSION;
|
|
63131
63131
|
if (false) {
|
|
63132
63132
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
63133
63133
|
}
|
|
@@ -63327,32 +63327,33 @@ function requireFromString(code, filename = "", options) {
|
|
|
63327
63327
|
var LATEST = "beta";
|
|
63328
63328
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
63329
63329
|
var loadLibraryPromises = {};
|
|
63330
|
-
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
63330
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
63331
63331
|
if (moduleName) {
|
|
63332
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
63332
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
63333
63333
|
}
|
|
63334
63334
|
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
63335
63335
|
return await loadLibraryPromises[libraryUrl];
|
|
63336
63336
|
}
|
|
63337
|
-
function getLibraryUrl(library, moduleName, options) {
|
|
63338
|
-
if (library.startsWith("http")) {
|
|
63337
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
63338
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
63339
63339
|
return library;
|
|
63340
63340
|
}
|
|
63341
|
+
libraryName = libraryName || library;
|
|
63341
63342
|
const modules = options.modules || {};
|
|
63342
|
-
if (modules[
|
|
63343
|
-
return modules[
|
|
63343
|
+
if (modules[libraryName]) {
|
|
63344
|
+
return modules[libraryName];
|
|
63344
63345
|
}
|
|
63345
63346
|
if (!isBrowser2) {
|
|
63346
|
-
return `modules/${moduleName}/dist/libs/${
|
|
63347
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
63347
63348
|
}
|
|
63348
63349
|
if (options.CDN) {
|
|
63349
63350
|
assert2(options.CDN.startsWith("http"));
|
|
63350
|
-
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${
|
|
63351
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
63351
63352
|
}
|
|
63352
63353
|
if (isWorker) {
|
|
63353
|
-
return `../src/libs/${
|
|
63354
|
+
return `../src/libs/${libraryName}`;
|
|
63354
63355
|
}
|
|
63355
|
-
return `modules/${moduleName}/src/libs/${
|
|
63356
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
63356
63357
|
}
|
|
63357
63358
|
async function loadLibraryFromFile(libraryUrl) {
|
|
63358
63359
|
if (libraryUrl.endsWith("wasm")) {
|
|
@@ -63405,12 +63406,15 @@ async function loadAsText(url) {
|
|
|
63405
63406
|
}
|
|
63406
63407
|
|
|
63407
63408
|
// src/lib/utils/version.ts
|
|
63408
|
-
var VERSION3 = true ? "4.0.0-alpha.
|
|
63409
|
+
var VERSION3 = true ? "4.0.0-alpha.19" : "beta";
|
|
63409
63410
|
|
|
63410
63411
|
// src/lib/parsers/basis-module-loader.ts
|
|
63411
|
-
var
|
|
63412
|
-
|
|
63413
|
-
|
|
63412
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
63413
|
+
TRANSCODER: "basis_transcoder.js",
|
|
63414
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
63415
|
+
ENCODER: "basis_encoder.js",
|
|
63416
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
63417
|
+
};
|
|
63414
63418
|
var loadBasisEncoderPromise;
|
|
63415
63419
|
async function loadBasisEncoderModule(options) {
|
|
63416
63420
|
const modules = options.modules || {};
|
|
@@ -63424,8 +63428,8 @@ async function loadBasisEncoder(options) {
|
|
|
63424
63428
|
let BASIS_ENCODER = null;
|
|
63425
63429
|
let wasmBinary = null;
|
|
63426
63430
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
63427
|
-
await loadLibrary(
|
|
63428
|
-
await loadLibrary(
|
|
63431
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
63432
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
63429
63433
|
]);
|
|
63430
63434
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
63431
63435
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
@@ -63446,7 +63450,12 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
|
63446
63450
|
|
|
63447
63451
|
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
|
63448
63452
|
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
63449
|
-
const {
|
|
63453
|
+
const {
|
|
63454
|
+
useSRGB = false,
|
|
63455
|
+
qualityLevel = 10,
|
|
63456
|
+
encodeUASTC = false,
|
|
63457
|
+
mipmaps = false
|
|
63458
|
+
} = (options == null ? void 0 : options["ktx2-basis-writer"]) || {};
|
|
63450
63459
|
const { BasisEncoder } = await loadBasisEncoderModule(options);
|
|
63451
63460
|
const basisEncoder = new BasisEncoder();
|
|
63452
63461
|
try {
|
|
@@ -63479,10 +63488,12 @@ var KTX2BasisWriter = {
|
|
|
63479
63488
|
version: VERSION3,
|
|
63480
63489
|
extensions: ["ktx2"],
|
|
63481
63490
|
options: {
|
|
63482
|
-
|
|
63483
|
-
|
|
63484
|
-
|
|
63485
|
-
|
|
63491
|
+
["ktx2-basis-writer"]: {
|
|
63492
|
+
useSRGB: false,
|
|
63493
|
+
qualityLevel: 10,
|
|
63494
|
+
encodeUASTC: false,
|
|
63495
|
+
mipmaps: false
|
|
63496
|
+
}
|
|
63486
63497
|
},
|
|
63487
63498
|
encode: encodeKTX2BasisTexture
|
|
63488
63499
|
};
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
31
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
31
|
+
var VERSION = true ? "4.0.0-alpha.19" : DEFAULT_VERSION;
|
|
32
32
|
if (false) {
|
|
33
33
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
34
34
|
}
|
|
@@ -171,32 +171,33 @@
|
|
|
171
171
|
var LATEST = "beta";
|
|
172
172
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
173
173
|
var loadLibraryPromises = {};
|
|
174
|
-
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
174
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
175
175
|
if (moduleName) {
|
|
176
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
176
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
177
177
|
}
|
|
178
178
|
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
179
179
|
return await loadLibraryPromises[libraryUrl];
|
|
180
180
|
}
|
|
181
|
-
function getLibraryUrl(library, moduleName, options) {
|
|
182
|
-
if (library.startsWith("http")) {
|
|
181
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
182
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
183
183
|
return library;
|
|
184
184
|
}
|
|
185
|
+
libraryName = libraryName || library;
|
|
185
186
|
const modules = options.modules || {};
|
|
186
|
-
if (modules[
|
|
187
|
-
return modules[
|
|
187
|
+
if (modules[libraryName]) {
|
|
188
|
+
return modules[libraryName];
|
|
188
189
|
}
|
|
189
190
|
if (!isBrowser) {
|
|
190
|
-
return `modules/${moduleName}/dist/libs/${
|
|
191
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
191
192
|
}
|
|
192
193
|
if (options.CDN) {
|
|
193
194
|
assert(options.CDN.startsWith("http"));
|
|
194
|
-
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${
|
|
195
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
195
196
|
}
|
|
196
197
|
if (isWorker) {
|
|
197
|
-
return `../src/libs/${
|
|
198
|
+
return `../src/libs/${libraryName}`;
|
|
198
199
|
}
|
|
199
|
-
return `modules/${moduleName}/src/libs/${
|
|
200
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
200
201
|
}
|
|
201
202
|
async function loadLibraryFromFile(libraryUrl) {
|
|
202
203
|
if (libraryUrl.endsWith("wasm")) {
|
|
@@ -249,12 +250,15 @@
|
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
// src/lib/utils/version.ts
|
|
252
|
-
var VERSION3 = true ? "4.0.0-alpha.
|
|
253
|
+
var VERSION3 = true ? "4.0.0-alpha.19" : "beta";
|
|
253
254
|
|
|
254
255
|
// src/lib/parsers/basis-module-loader.ts
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
257
|
+
TRANSCODER: "basis_transcoder.js",
|
|
258
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
259
|
+
ENCODER: "basis_encoder.js",
|
|
260
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
261
|
+
};
|
|
258
262
|
var loadBasisEncoderPromise;
|
|
259
263
|
async function loadBasisEncoderModule(options) {
|
|
260
264
|
const modules = options.modules || {};
|
|
@@ -268,8 +272,8 @@
|
|
|
268
272
|
let BASIS_ENCODER = null;
|
|
269
273
|
let wasmBinary = null;
|
|
270
274
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
271
|
-
await loadLibrary(
|
|
272
|
-
await loadLibrary(
|
|
275
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
276
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
273
277
|
]);
|
|
274
278
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
275
279
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
@@ -290,7 +294,12 @@
|
|
|
290
294
|
|
|
291
295
|
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
|
292
296
|
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
293
|
-
const {
|
|
297
|
+
const {
|
|
298
|
+
useSRGB = false,
|
|
299
|
+
qualityLevel = 10,
|
|
300
|
+
encodeUASTC = false,
|
|
301
|
+
mipmaps = false
|
|
302
|
+
} = options?.["ktx2-basis-writer"] || {};
|
|
294
303
|
const { BasisEncoder } = await loadBasisEncoderModule(options);
|
|
295
304
|
const basisEncoder = new BasisEncoder();
|
|
296
305
|
try {
|
|
@@ -323,10 +332,12 @@
|
|
|
323
332
|
version: VERSION3,
|
|
324
333
|
extensions: ["ktx2"],
|
|
325
334
|
options: {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
["ktx2-basis-writer"]: {
|
|
336
|
+
useSRGB: false,
|
|
337
|
+
qualityLevel: 10,
|
|
338
|
+
encodeUASTC: false,
|
|
339
|
+
mipmaps: false
|
|
340
|
+
}
|
|
330
341
|
},
|
|
331
342
|
encode: encodeKTX2BasisTexture
|
|
332
343
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { Writer } from '@loaders.gl/loader-utils';
|
|
1
|
+
import type { Writer, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { ImageDataType } from '@loaders.gl/images';
|
|
3
3
|
/** @todo should be in basis sub-object */
|
|
4
|
-
export type KTX2BasisWriterOptions = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export type KTX2BasisWriterOptions = WriterOptions & {
|
|
5
|
+
['ktx2-basis-writer']: {
|
|
6
|
+
useSRGB?: boolean;
|
|
7
|
+
qualityLevel?: number;
|
|
8
|
+
encodeUASTC?: boolean;
|
|
9
|
+
mipmaps?: boolean;
|
|
10
|
+
};
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
* Basis Universal Supercompressed GPU Texture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktx2-basis-writer.d.ts","sourceRoot":"","sources":["../src/ktx2-basis-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ktx2-basis-writer.d.ts","sourceRoot":"","sources":["../src/ktx2-basis-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAGtD,0CAA0C;AAC1C,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,CAAC,mBAAmB,CAAC,EAAE;QACrB,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,EAAE,MAAM,CAAC,aAAa,EAAE,OAAO,EAAE,sBAAsB,CAiBlF,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,MAAwB,CAAC"}
|
|
@@ -15,10 +15,12 @@ exports.KTX2BasisWriter = {
|
|
|
15
15
|
version: version_1.VERSION,
|
|
16
16
|
extensions: ['ktx2'],
|
|
17
17
|
options: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
['ktx2-basis-writer']: {
|
|
19
|
+
useSRGB: false,
|
|
20
|
+
qualityLevel: 10,
|
|
21
|
+
encodeUASTC: false,
|
|
22
|
+
mipmaps: false
|
|
23
|
+
}
|
|
22
24
|
},
|
|
23
25
|
encode: encode_ktx2_basis_texture_1.encodeKTX2BasisTexture
|
|
24
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-ktx2-basis-texture.d.ts","sourceRoot":"","sources":["../../../src/lib/encoders/encode-ktx2-basis-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAGtD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"encode-ktx2-basis-texture.d.ts","sourceRoot":"","sources":["../../../src/lib/encoders/encode-ktx2-basis-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAGtD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC,WAAW,CAAC,CAmCtB"}
|
|
@@ -11,7 +11,7 @@ const basis_module_loader_1 = require("../parsers/basis-module-loader");
|
|
|
11
11
|
*/
|
|
12
12
|
async function encodeKTX2BasisTexture(image, options = {}) {
|
|
13
13
|
// TODO remove default values after writer options will be normalized like it done in load module.
|
|
14
|
-
const { useSRGB = false, qualityLevel = 10, encodeUASTC = false, mipmaps = false } = options;
|
|
14
|
+
const { useSRGB = false, qualityLevel = 10, encodeUASTC = false, mipmaps = false } = options?.['ktx2-basis-writer'] || {};
|
|
15
15
|
const { BasisEncoder } = await (0, basis_module_loader_1.loadBasisEncoderModule)(options);
|
|
16
16
|
const basisEncoder = new BasisEncoder();
|
|
17
17
|
try {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export declare const BASIS_EXTERNAL_LIBRARIES: {
|
|
2
|
+
/** Basis transcoder, javascript wrapper part */
|
|
3
|
+
TRANSCODER: string;
|
|
4
|
+
/** Basis transcoder, compiled web assembly part */
|
|
5
|
+
TRANSCODER_WASM: string;
|
|
6
|
+
/** Basis encoder, javascript wrapper part */
|
|
7
|
+
ENCODER: string;
|
|
8
|
+
/** Basis encoder, compiled web assembly part */
|
|
9
|
+
ENCODER_WASM: string;
|
|
10
|
+
};
|
|
1
11
|
/**
|
|
2
12
|
* Loads wasm transcoder module
|
|
3
13
|
* @param options
|
|
@@ -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":"AAEA,eAAO,MAAM,wBAAwB;IACnC,gDAAgD;;IAEhD,mDAAmD;;IAEnD,6CAA6C;;IAE7C,gDAAgD;;CAEjD,CAAC;AAIF;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,KAAA,gBAQtD;AA+CD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,KAAA,gBAQnD"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadBasisEncoderModule = exports.loadBasisTranscoderModule = 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__ : 'beta';
|
|
7
|
-
// @ts-nocheck
|
|
3
|
+
exports.loadBasisEncoderModule = exports.loadBasisTranscoderModule = exports.BASIS_EXTERNAL_LIBRARIES = void 0;
|
|
8
4
|
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
exports.BASIS_EXTERNAL_LIBRARIES = {
|
|
6
|
+
/** Basis transcoder, javascript wrapper part */
|
|
7
|
+
TRANSCODER: 'basis_transcoder.js',
|
|
8
|
+
/** Basis transcoder, compiled web assembly part */
|
|
9
|
+
TRANSCODER_WASM: 'basis_transcoder.wasm',
|
|
10
|
+
/** Basis encoder, javascript wrapper part */
|
|
11
|
+
ENCODER: 'basis_encoder.js',
|
|
12
|
+
/** Basis encoder, compiled web assembly part */
|
|
13
|
+
ENCODER_WASM: 'basis_encoder.wasm'
|
|
14
|
+
};
|
|
11
15
|
let loadBasisTranscoderPromise;
|
|
12
16
|
/**
|
|
13
17
|
* Loads wasm transcoder module
|
|
@@ -32,8 +36,8 @@ async function loadBasisTranscoder(options) {
|
|
|
32
36
|
let BASIS = null;
|
|
33
37
|
let wasmBinary = null;
|
|
34
38
|
[BASIS, wasmBinary] = await Promise.all([
|
|
35
|
-
await (0, worker_utils_1.loadLibrary)(
|
|
36
|
-
await (0, worker_utils_1.loadLibrary)(
|
|
39
|
+
await (0, worker_utils_1.loadLibrary)(exports.BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'textures', options),
|
|
40
|
+
await (0, worker_utils_1.loadLibrary)(exports.BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'textures', options)
|
|
37
41
|
]);
|
|
38
42
|
// Depends on how import happened...
|
|
39
43
|
// @ts-ignore TS2339: Property does not exist on type
|
|
@@ -84,8 +88,8 @@ async function loadBasisEncoder(options) {
|
|
|
84
88
|
let BASIS_ENCODER = null;
|
|
85
89
|
let wasmBinary = null;
|
|
86
90
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
87
|
-
await (0, worker_utils_1.loadLibrary)(
|
|
88
|
-
await (0, worker_utils_1.loadLibrary)(
|
|
91
|
+
await (0, worker_utils_1.loadLibrary)(exports.BASIS_EXTERNAL_LIBRARIES.ENCODER, 'textures', options),
|
|
92
|
+
await (0, worker_utils_1.loadLibrary)(exports.BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'textures', options)
|
|
89
93
|
]);
|
|
90
94
|
// Depends on how import happened...
|
|
91
95
|
// @ts-ignore TS2339: Property does not exist on type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crunch-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/crunch-module-loader.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC,CAO5D"}
|
|
1
|
+
{"version":3,"file":"crunch-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/crunch-module-loader.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB;IACpC,wEAAwE;;CAEzE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC,CAO5D"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadCrunchModule = void 0;
|
|
3
|
+
exports.loadCrunchModule = exports.CRUNCH_EXTERNAL_LIBRARIES = void 0;
|
|
4
4
|
// @ts-nocheck
|
|
5
5
|
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
6
|
+
exports.CRUNCH_EXTERNAL_LIBRARIES = {
|
|
7
|
+
/** Crunch decoder library. It is used as dynamically imported script */
|
|
8
|
+
DECODER: 'crunch.js'
|
|
9
|
+
};
|
|
6
10
|
/**
|
|
7
11
|
* Load crunch decoder module
|
|
8
12
|
* @param options - loader options
|
|
@@ -26,7 +30,7 @@ async function loadCrunch(options) {
|
|
|
26
30
|
if (crunchModule) {
|
|
27
31
|
return crunchModule;
|
|
28
32
|
}
|
|
29
|
-
let loadCrunchDecoder = await (0, worker_utils_1.loadLibrary)(
|
|
33
|
+
let loadCrunchDecoder = await (0, worker_utils_1.loadLibrary)(exports.CRUNCH_EXTERNAL_LIBRARIES.DECODER, 'textures', options);
|
|
30
34
|
// Depends on how import happened...
|
|
31
35
|
// @ts-ignore TS2339: Property does not exist on type
|
|
32
36
|
loadCrunchDecoder = loadCrunchDecoder || globalThis.LoadCrunchDecoder;
|
package/dist/npy-worker.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/textures",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.19",
|
|
4
4
|
"description": "Framework-independent loaders for compressed and super compressed (basis) textures ",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"build-crunch-worker": "esbuild src/workers/crunch-worker.ts --outfile=dist/crunch-worker.js --target=esnext --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@loaders.gl/images": "4.0.0-alpha.
|
|
49
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
50
|
-
"@loaders.gl/schema": "4.0.0-alpha.
|
|
51
|
-
"@loaders.gl/worker-utils": "4.0.0-alpha.
|
|
48
|
+
"@loaders.gl/images": "4.0.0-alpha.19",
|
|
49
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.19",
|
|
50
|
+
"@loaders.gl/schema": "4.0.0-alpha.19",
|
|
51
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.19",
|
|
52
52
|
"ktx-parse": "^0.0.4",
|
|
53
53
|
"texture-compressor": "^1.0.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@loaders.gl/polyfills": "4.0.0-alpha.
|
|
56
|
+
"@loaders.gl/polyfills": "4.0.0-alpha.19"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "2ca50ec4e1d312c124eb7c93c60ab6fd17ee833e"
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,10 @@ export {CompressedTextureLoader, CompressedTextureWorkerLoader} from './compress
|
|
|
10
10
|
export {CrunchLoader} from './crunch-loader';
|
|
11
11
|
export {NPYLoader, NPYWorkerLoader} from './npy-loader';
|
|
12
12
|
|
|
13
|
+
// Module constants
|
|
14
|
+
export {BASIS_EXTERNAL_LIBRARIES} from './lib/parsers/basis-module-loader';
|
|
15
|
+
export {CRUNCH_EXTERNAL_LIBRARIES} from './lib/parsers/crunch-module-loader';
|
|
16
|
+
|
|
13
17
|
// Writers
|
|
14
18
|
export {CompressedTextureWriter} from './compressed-texture-writer';
|
|
15
19
|
export {KTX2BasisWriter} from './ktx2-basis-writer';
|
package/src/ktx2-basis-writer.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
2
|
|
|
3
|
-
import type {Writer} from '@loaders.gl/loader-utils';
|
|
3
|
+
import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';
|
|
4
4
|
import {VERSION} from './lib/utils/version';
|
|
5
5
|
import type {ImageDataType} from '@loaders.gl/images';
|
|
6
6
|
import {encodeKTX2BasisTexture} from './lib/encoders/encode-ktx2-basis-texture';
|
|
7
7
|
|
|
8
8
|
/** @todo should be in basis sub-object */
|
|
9
|
-
export type KTX2BasisWriterOptions = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export type KTX2BasisWriterOptions = WriterOptions & {
|
|
10
|
+
['ktx2-basis-writer']: {
|
|
11
|
+
useSRGB?: boolean;
|
|
12
|
+
qualityLevel?: number;
|
|
13
|
+
encodeUASTC?: boolean;
|
|
14
|
+
mipmaps?: boolean;
|
|
15
|
+
};
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -25,10 +27,12 @@ export const KTX2BasisWriter: Writer<ImageDataType, unknown, KTX2BasisWriterOpti
|
|
|
25
27
|
|
|
26
28
|
extensions: ['ktx2'],
|
|
27
29
|
options: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
['ktx2-basis-writer']: {
|
|
31
|
+
useSRGB: false,
|
|
32
|
+
qualityLevel: 10,
|
|
33
|
+
encodeUASTC: false,
|
|
34
|
+
mipmaps: false
|
|
35
|
+
}
|
|
32
36
|
},
|
|
33
37
|
|
|
34
38
|
encode: encodeKTX2BasisTexture
|
|
@@ -13,7 +13,12 @@ export async function encodeKTX2BasisTexture(
|
|
|
13
13
|
options: any = {}
|
|
14
14
|
): Promise<ArrayBuffer> {
|
|
15
15
|
// TODO remove default values after writer options will be normalized like it done in load module.
|
|
16
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
useSRGB = false,
|
|
18
|
+
qualityLevel = 10,
|
|
19
|
+
encodeUASTC = false,
|
|
20
|
+
mipmaps = false
|
|
21
|
+
} = options?.['ktx2-basis-writer'] || {};
|
|
17
22
|
const {BasisEncoder} = await loadBasisEncoderModule(options);
|
|
18
23
|
const basisEncoder = new BasisEncoder();
|
|
19
24
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
2
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
3
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
|
|
4
|
-
|
|
5
|
-
// @ts-nocheck
|
|
6
1
|
import {loadLibrary} from '@loaders.gl/worker-utils';
|
|
7
2
|
|
|
8
|
-
const
|
|
9
|
-
|
|
3
|
+
export const BASIS_EXTERNAL_LIBRARIES = {
|
|
4
|
+
/** Basis transcoder, javascript wrapper part */
|
|
5
|
+
TRANSCODER: 'basis_transcoder.js',
|
|
6
|
+
/** Basis transcoder, compiled web assembly part */
|
|
7
|
+
TRANSCODER_WASM: 'basis_transcoder.wasm',
|
|
8
|
+
/** Basis encoder, javascript wrapper part */
|
|
9
|
+
ENCODER: 'basis_encoder.js',
|
|
10
|
+
/** Basis encoder, compiled web assembly part */
|
|
11
|
+
ENCODER_WASM: 'basis_encoder.wasm'
|
|
12
|
+
};
|
|
10
13
|
|
|
11
14
|
let loadBasisTranscoderPromise;
|
|
12
15
|
|
|
@@ -35,8 +38,8 @@ async function loadBasisTranscoder(options) {
|
|
|
35
38
|
let wasmBinary = null;
|
|
36
39
|
|
|
37
40
|
[BASIS, wasmBinary] = await Promise.all([
|
|
38
|
-
await loadLibrary(
|
|
39
|
-
await loadLibrary(
|
|
41
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'textures', options),
|
|
42
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'textures', options)
|
|
40
43
|
]);
|
|
41
44
|
|
|
42
45
|
// Depends on how import happened...
|
|
@@ -95,8 +98,8 @@ async function loadBasisEncoder(options) {
|
|
|
95
98
|
let wasmBinary = null;
|
|
96
99
|
|
|
97
100
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
98
|
-
await loadLibrary(
|
|
99
|
-
await loadLibrary(
|
|
101
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, 'textures', options),
|
|
102
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'textures', options)
|
|
100
103
|
]);
|
|
101
104
|
|
|
102
105
|
// Depends on how import happened...
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import {loadLibrary} from '@loaders.gl/worker-utils';
|
|
3
3
|
|
|
4
|
+
export const CRUNCH_EXTERNAL_LIBRARIES = {
|
|
5
|
+
/** Crunch decoder library. It is used as dynamically imported script */
|
|
6
|
+
DECODER: 'crunch.js'
|
|
7
|
+
};
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* Load crunch decoder module
|
|
6
11
|
* @param options - loader options
|
|
@@ -27,7 +32,7 @@ async function loadCrunch(options) {
|
|
|
27
32
|
return crunchModule;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
let loadCrunchDecoder = await loadLibrary(
|
|
35
|
+
let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, 'textures', options);
|
|
31
36
|
|
|
32
37
|
// Depends on how import happened...
|
|
33
38
|
// @ts-ignore TS2339: Property does not exist on type
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Polyfills increases the bundle size significantly. Use it for NodeJS worker only
|
|
2
2
|
import '@loaders.gl/polyfills';
|
|
3
3
|
import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';
|
|
4
|
-
import {KTX2BasisWriter} from '../ktx2-basis-writer';
|
|
4
|
+
import {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';
|
|
5
5
|
|
|
6
6
|
(() => {
|
|
7
7
|
// Check that we are actually in a worker thread
|
|
@@ -14,7 +14,7 @@ import {KTX2BasisWriter} from '../ktx2-basis-writer';
|
|
|
14
14
|
case 'process':
|
|
15
15
|
try {
|
|
16
16
|
const {input, options} = payload;
|
|
17
|
-
const result = await KTX2BasisWriter.encode?.(input, options);
|
|
17
|
+
const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);
|
|
18
18
|
WorkerBody.postMessage('done', {result});
|
|
19
19
|
} catch (error) {
|
|
20
20
|
const message = error instanceof Error ? error.message : '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';
|
|
2
|
-
import {KTX2BasisWriter} from '../ktx2-basis-writer';
|
|
2
|
+
import {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';
|
|
3
3
|
|
|
4
4
|
(() => {
|
|
5
5
|
// Check that we are actually in a worker thread
|
|
@@ -12,7 +12,7 @@ import {KTX2BasisWriter} from '../ktx2-basis-writer';
|
|
|
12
12
|
case 'process':
|
|
13
13
|
try {
|
|
14
14
|
const {input, options} = payload;
|
|
15
|
-
const result = await KTX2BasisWriter.encode?.(input, options);
|
|
15
|
+
const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);
|
|
16
16
|
WorkerBody.postMessage('done', {result});
|
|
17
17
|
} catch (error) {
|
|
18
18
|
const message = error instanceof Error ? error.message : '';
|