@loaders.gl/textures 4.2.0-alpha.6 → 4.2.0-beta.2
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 +167 -210
- package/dist/basis-worker.js +29 -48
- 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 +30 -46
- 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 +30 -46
- 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 +148 -203
- package/dist/ktx2-basis-writer-worker.js +12 -42
- 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 +3 -1
- package/dist/workers/crunch-worker.d.ts +15 -17
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/package.json +6 -6
- 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
package/dist/basis-worker.js
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
});
|
|
3
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
4
|
+
function registerJSModules(modules) {
|
|
5
|
+
globalThis.loaders ||= {};
|
|
6
|
+
globalThis.loaders.modules ||= {};
|
|
7
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
8
|
+
}
|
|
9
|
+
function getJSModuleOrNull(name) {
|
|
10
|
+
const module = globalThis.loaders?.modules?.[name];
|
|
11
|
+
return module || null;
|
|
12
|
+
}
|
|
35
13
|
|
|
36
14
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
37
15
|
function getVersion() {
|
|
@@ -43,7 +21,7 @@
|
|
|
43
21
|
);
|
|
44
22
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
23
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.2.0-
|
|
24
|
+
globalThis._loadersgl_.version = "4.2.0-beta.1";
|
|
47
25
|
}
|
|
48
26
|
}
|
|
49
27
|
return globalThis._loadersgl_.version;
|
|
@@ -196,7 +174,6 @@
|
|
|
196
174
|
}
|
|
197
175
|
|
|
198
176
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
199
|
-
var node = __toESM(require_require_utils(), 1);
|
|
200
177
|
var loadLibraryPromises = {};
|
|
201
178
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
202
179
|
if (moduleName) {
|
|
@@ -233,7 +210,8 @@
|
|
|
233
210
|
}
|
|
234
211
|
if (!isBrowser) {
|
|
235
212
|
try {
|
|
236
|
-
|
|
213
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
214
|
+
return await requireFromFile?.(libraryUrl);
|
|
237
215
|
} catch (error) {
|
|
238
216
|
console.error(error);
|
|
239
217
|
return null;
|
|
@@ -247,7 +225,8 @@
|
|
|
247
225
|
}
|
|
248
226
|
function loadLibraryFromString(scriptSource, id) {
|
|
249
227
|
if (!isBrowser) {
|
|
250
|
-
|
|
228
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
229
|
+
return requireFromString?.(scriptSource, id);
|
|
251
230
|
}
|
|
252
231
|
if (isWorker) {
|
|
253
232
|
eval.call(globalThis, scriptSource);
|
|
@@ -264,18 +243,20 @@
|
|
|
264
243
|
return null;
|
|
265
244
|
}
|
|
266
245
|
async function loadAsArrayBuffer(url) {
|
|
267
|
-
|
|
246
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
247
|
+
if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
268
248
|
const response = await fetch(url);
|
|
269
249
|
return await response.arrayBuffer();
|
|
270
250
|
}
|
|
271
|
-
return await (
|
|
251
|
+
return await readFileAsArrayBuffer(url);
|
|
272
252
|
}
|
|
273
253
|
async function loadAsText(url) {
|
|
274
|
-
|
|
254
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
255
|
+
if (isBrowser || !readFileAsText || url.startsWith("http")) {
|
|
275
256
|
const response = await fetch(url);
|
|
276
257
|
return await response.text();
|
|
277
258
|
}
|
|
278
|
-
return await (
|
|
259
|
+
return await readFileAsText(url);
|
|
279
260
|
}
|
|
280
261
|
|
|
281
262
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
@@ -360,7 +341,7 @@
|
|
|
360
341
|
}
|
|
361
342
|
|
|
362
343
|
// src/lib/utils/version.ts
|
|
363
|
-
var VERSION2 = true ? "4.2.0-
|
|
344
|
+
var VERSION2 = true ? "4.2.0-beta.1" : "latest";
|
|
364
345
|
|
|
365
346
|
// src/lib/parsers/basis-module-loader.ts
|
|
366
347
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -375,11 +356,12 @@
|
|
|
375
356
|
};
|
|
376
357
|
var loadBasisTranscoderPromise;
|
|
377
358
|
async function loadBasisTranscoderModule(options) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
359
|
+
registerJSModules(options.modules);
|
|
360
|
+
const basis = getJSModuleOrNull("basis");
|
|
361
|
+
if (basis) {
|
|
362
|
+
return basis;
|
|
381
363
|
}
|
|
382
|
-
loadBasisTranscoderPromise
|
|
364
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
383
365
|
return await loadBasisTranscoderPromise;
|
|
384
366
|
}
|
|
385
367
|
async function loadBasisTranscoder(options) {
|
|
@@ -811,6 +793,8 @@
|
|
|
811
793
|
|
|
812
794
|
// src/basis-loader.ts
|
|
813
795
|
var BasisWorkerLoader = {
|
|
796
|
+
dataType: null,
|
|
797
|
+
batchType: null,
|
|
814
798
|
name: "Basis",
|
|
815
799
|
id: "basis",
|
|
816
800
|
module: "textures",
|
|
@@ -823,12 +807,9 @@
|
|
|
823
807
|
options: {
|
|
824
808
|
basis: {
|
|
825
809
|
format: "auto",
|
|
826
|
-
// gl context doesn't exist on a worker thread
|
|
827
810
|
libraryPath: "libs/",
|
|
828
811
|
containerFormat: "auto",
|
|
829
|
-
// 'basis' || 'ktx2' || 'auto'
|
|
830
812
|
module: "transcoder"
|
|
831
|
-
// 'transcoder' || 'encoder'
|
|
832
813
|
}
|
|
833
814
|
}
|
|
834
815
|
};
|
|
@@ -1,16 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
1
|
+
/** Options for the CompressedTextureLoader */
|
|
2
|
+
export type CompressedTextureLoaderOptions = {
|
|
3
3
|
'compressed-texture'?: {
|
|
4
|
+
/** @deprecated Specify path to libraries */
|
|
4
5
|
libraryPath?: string;
|
|
6
|
+
/** Whether to use Basis decoding */
|
|
5
7
|
useBasis?: boolean;
|
|
8
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
9
|
+
workerUrl?: string;
|
|
6
10
|
};
|
|
7
11
|
};
|
|
8
12
|
/**
|
|
9
13
|
* Worker Loader for KTX, DDS, and PVR texture container formats
|
|
10
14
|
*/
|
|
11
|
-
export declare const CompressedTextureWorkerLoader:
|
|
15
|
+
export declare const CompressedTextureWorkerLoader: {
|
|
16
|
+
readonly dataType: any;
|
|
17
|
+
readonly batchType: never;
|
|
18
|
+
readonly name: "Texture Containers";
|
|
19
|
+
readonly id: "compressed-texture";
|
|
20
|
+
readonly module: "textures";
|
|
21
|
+
readonly version: any;
|
|
22
|
+
readonly worker: true;
|
|
23
|
+
readonly extensions: ["ktx", "ktx2", "dds", "pvr"];
|
|
24
|
+
readonly mimeTypes: ["image/ktx2", "image/ktx", "image/vnd-ms.dds", "image/x-dds", "application/octet-stream"];
|
|
25
|
+
readonly binary: true;
|
|
26
|
+
readonly options: {
|
|
27
|
+
readonly 'compressed-texture': {
|
|
28
|
+
readonly libraryPath: "libs/";
|
|
29
|
+
readonly useBasis: false;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
12
33
|
/**
|
|
13
34
|
* Loader for KTX, DDS, and PVR texture container formats
|
|
14
35
|
*/
|
|
15
|
-
export declare const CompressedTextureLoader:
|
|
36
|
+
export declare const CompressedTextureLoader: {
|
|
37
|
+
readonly parse: (arrayBuffer: ArrayBuffer, options?: CompressedTextureLoaderOptions) => Promise<import("@loaders.gl/schema").TextureLevel[]>;
|
|
38
|
+
readonly dataType: any;
|
|
39
|
+
readonly batchType: never;
|
|
40
|
+
readonly name: "Texture Containers";
|
|
41
|
+
readonly id: "compressed-texture";
|
|
42
|
+
readonly module: "textures";
|
|
43
|
+
readonly version: any;
|
|
44
|
+
readonly worker: true;
|
|
45
|
+
readonly extensions: ["ktx", "ktx2", "dds", "pvr"];
|
|
46
|
+
readonly mimeTypes: ["image/ktx2", "image/ktx", "image/vnd-ms.dds", "image/x-dds", "application/octet-stream"];
|
|
47
|
+
readonly binary: true;
|
|
48
|
+
readonly options: {
|
|
49
|
+
readonly 'compressed-texture': {
|
|
50
|
+
readonly libraryPath: "libs/";
|
|
51
|
+
readonly useBasis: false;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
16
55
|
//# sourceMappingURL=compressed-texture-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressed-texture-loader.d.ts","sourceRoot":"","sources":["../src/compressed-texture-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compressed-texture-loader.d.ts","sourceRoot":"","sources":["../src/compressed-texture-loader.ts"],"names":[],"mappings":"AASA,8CAA8C;AAC9C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,oBAAoB,CAAC,EAAE;QACrB,4CAA4C;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,oCAAoC;QACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;CA6B6B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,uBAAuB;kCAEP,WAAW,YAAY,8BAA8B;;;;;;;;;;;;;;;;;CAkBD,CAAC"}
|
|
@@ -8,6 +8,8 @@ import parseBasis from "./lib/parsers/parse-basis.js";
|
|
|
8
8
|
* Worker Loader for KTX, DDS, and PVR texture container formats
|
|
9
9
|
*/
|
|
10
10
|
export const CompressedTextureWorkerLoader = {
|
|
11
|
+
dataType: null,
|
|
12
|
+
batchType: null,
|
|
11
13
|
name: 'Texture Containers',
|
|
12
14
|
id: 'compressed-texture',
|
|
13
15
|
module: 'textures',
|
|
@@ -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
|
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
37
4
|
function assert(condition, message) {
|
|
38
5
|
if (!condition) {
|
|
@@ -40,6 +7,17 @@
|
|
|
40
7
|
}
|
|
41
8
|
}
|
|
42
9
|
|
|
10
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
11
|
+
function registerJSModules(modules) {
|
|
12
|
+
globalThis.loaders ||= {};
|
|
13
|
+
globalThis.loaders.modules ||= {};
|
|
14
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
15
|
+
}
|
|
16
|
+
function getJSModuleOrNull(name) {
|
|
17
|
+
const module = globalThis.loaders?.modules?.[name];
|
|
18
|
+
return module || null;
|
|
19
|
+
}
|
|
20
|
+
|
|
43
21
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
44
22
|
function getVersion() {
|
|
45
23
|
if (!globalThis._loadersgl_?.version) {
|
|
@@ -50,7 +28,7 @@
|
|
|
50
28
|
);
|
|
51
29
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
52
30
|
} else {
|
|
53
|
-
globalThis._loadersgl_.version = "4.2.0-
|
|
31
|
+
globalThis._loadersgl_.version = "4.2.0-beta.1";
|
|
54
32
|
}
|
|
55
33
|
}
|
|
56
34
|
return globalThis._loadersgl_.version;
|
|
@@ -203,7 +181,6 @@
|
|
|
203
181
|
}
|
|
204
182
|
|
|
205
183
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
206
|
-
var node = __toESM(require_require_utils(), 1);
|
|
207
184
|
var loadLibraryPromises = {};
|
|
208
185
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
209
186
|
if (moduleName) {
|
|
@@ -240,7 +217,8 @@
|
|
|
240
217
|
}
|
|
241
218
|
if (!isBrowser) {
|
|
242
219
|
try {
|
|
243
|
-
|
|
220
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
221
|
+
return await requireFromFile?.(libraryUrl);
|
|
244
222
|
} catch (error) {
|
|
245
223
|
console.error(error);
|
|
246
224
|
return null;
|
|
@@ -254,7 +232,8 @@
|
|
|
254
232
|
}
|
|
255
233
|
function loadLibraryFromString(scriptSource, id) {
|
|
256
234
|
if (!isBrowser) {
|
|
257
|
-
|
|
235
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
236
|
+
return requireFromString?.(scriptSource, id);
|
|
258
237
|
}
|
|
259
238
|
if (isWorker) {
|
|
260
239
|
eval.call(globalThis, scriptSource);
|
|
@@ -271,18 +250,20 @@
|
|
|
271
250
|
return null;
|
|
272
251
|
}
|
|
273
252
|
async function loadAsArrayBuffer(url) {
|
|
274
|
-
|
|
253
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
254
|
+
if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
275
255
|
const response = await fetch(url);
|
|
276
256
|
return await response.arrayBuffer();
|
|
277
257
|
}
|
|
278
|
-
return await (
|
|
258
|
+
return await readFileAsArrayBuffer(url);
|
|
279
259
|
}
|
|
280
260
|
async function loadAsText(url) {
|
|
281
|
-
|
|
261
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
262
|
+
if (isBrowser || !readFileAsText || url.startsWith("http")) {
|
|
282
263
|
const response = await fetch(url);
|
|
283
264
|
return await response.text();
|
|
284
265
|
}
|
|
285
|
-
return await (
|
|
266
|
+
return await readFileAsText(url);
|
|
286
267
|
}
|
|
287
268
|
|
|
288
269
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
@@ -367,7 +348,7 @@
|
|
|
367
348
|
}
|
|
368
349
|
|
|
369
350
|
// src/lib/utils/version.ts
|
|
370
|
-
var VERSION2 = true ? "4.2.0-
|
|
351
|
+
var VERSION2 = true ? "4.2.0-beta.1" : "latest";
|
|
371
352
|
|
|
372
353
|
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
373
354
|
var t = new Uint8Array([0]);
|
|
@@ -1037,11 +1018,12 @@
|
|
|
1037
1018
|
};
|
|
1038
1019
|
var loadBasisTranscoderPromise;
|
|
1039
1020
|
async function loadBasisTranscoderModule(options) {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1021
|
+
registerJSModules(options.modules);
|
|
1022
|
+
const basis = getJSModuleOrNull("basis");
|
|
1023
|
+
if (basis) {
|
|
1024
|
+
return basis;
|
|
1043
1025
|
}
|
|
1044
|
-
loadBasisTranscoderPromise
|
|
1026
|
+
loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
|
|
1045
1027
|
return await loadBasisTranscoderPromise;
|
|
1046
1028
|
}
|
|
1047
1029
|
async function loadBasisTranscoder(options) {
|
|
@@ -1342,6 +1324,8 @@
|
|
|
1342
1324
|
|
|
1343
1325
|
// src/compressed-texture-loader.ts
|
|
1344
1326
|
var CompressedTextureWorkerLoader = {
|
|
1327
|
+
dataType: null,
|
|
1328
|
+
batchType: null,
|
|
1345
1329
|
name: "Texture Containers",
|
|
1346
1330
|
id: "compressed-texture",
|
|
1347
1331
|
module: "textures",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { encodeImageURLToCompressedTextureURL } from "./lib/encoders/encode-texture.js";
|
|
3
|
+
/** Compressed Texture writer options */
|
|
2
4
|
export type CompressedTextureWriterOptions = WriterOptions & {
|
|
5
|
+
/** @deprecated current working directory */
|
|
3
6
|
cwd?: string;
|
|
7
|
+
/** Compressed Texture writer options */
|
|
4
8
|
texture?: {
|
|
5
9
|
format: string;
|
|
6
10
|
compression: string;
|
|
@@ -13,5 +17,23 @@ export type CompressedTextureWriterOptions = WriterOptions & {
|
|
|
13
17
|
/**
|
|
14
18
|
* DDS Texture Container Exporter
|
|
15
19
|
*/
|
|
16
|
-
export declare const CompressedTextureWriter:
|
|
20
|
+
export declare const CompressedTextureWriter: {
|
|
21
|
+
readonly name: "DDS Texture Container";
|
|
22
|
+
readonly id: "dds";
|
|
23
|
+
readonly module: "textures";
|
|
24
|
+
readonly version: any;
|
|
25
|
+
readonly extensions: ["dds"];
|
|
26
|
+
readonly options: {
|
|
27
|
+
readonly texture: {
|
|
28
|
+
readonly format: "auto";
|
|
29
|
+
readonly compression: "auto";
|
|
30
|
+
readonly quality: "auto";
|
|
31
|
+
readonly mipmap: false;
|
|
32
|
+
readonly flipY: false;
|
|
33
|
+
readonly toolFlags: "";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly encodeURLtoURL: typeof encodeImageURLToCompressedTextureURL;
|
|
37
|
+
readonly encode: () => never;
|
|
38
|
+
};
|
|
17
39
|
//# sourceMappingURL=compressed-texture-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAC,oCAAoC,EAAC,yCAAsC;AAEnF,wCAAwC;AACxC,MAAM,MAAM,8BAA8B,GAAG,aAAa,GAAG;IAC3D,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,OAAO,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;CAuBoD,CAAC"}
|
|
@@ -27,11 +27,3 @@ export const CompressedTextureWriter = {
|
|
|
27
27
|
throw new Error('Not implemented');
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
// TYPE TESTS - TODO find a better way than exporting junk
|
|
31
|
-
// export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {
|
|
32
|
-
// encodeURLtoURL: (
|
|
33
|
-
// inputUrl: string,
|
|
34
|
-
// outputUrl: string,
|
|
35
|
-
// options?: CompressedTextureWriterOptions
|
|
36
|
-
// ) => Promise<string>;
|
|
37
|
-
// } = CompressedTextureWriter;
|
package/dist/crunch-loader.d.ts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { TextureLevel } from '@loaders.gl/schema';
|
|
3
|
+
/** CrunchLoader options */
|
|
3
4
|
export type CrunchLoaderOptions = LoaderOptions & {
|
|
5
|
+
/** CrunchLoader options */
|
|
4
6
|
crunch?: {
|
|
7
|
+
/** @deprecated Specify where to load the Crunch decoder library */
|
|
5
8
|
libraryPath?: string;
|
|
9
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
10
|
+
workerUrl?: string;
|
|
6
11
|
};
|
|
7
12
|
};
|
|
8
13
|
/**
|
|
9
14
|
* Worker loader for the Crunch compressed texture container format
|
|
10
15
|
* @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
|
|
11
16
|
*/
|
|
12
|
-
export declare const CrunchLoader:
|
|
17
|
+
export declare const CrunchLoader: {
|
|
18
|
+
readonly dataType: TextureLevel[];
|
|
19
|
+
readonly batchType: never;
|
|
20
|
+
readonly id: "crunch";
|
|
21
|
+
readonly name: "Crunch";
|
|
22
|
+
readonly module: "textures";
|
|
23
|
+
readonly version: any;
|
|
24
|
+
readonly worker: true;
|
|
25
|
+
readonly extensions: ["crn"];
|
|
26
|
+
readonly mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"];
|
|
27
|
+
readonly binary: true;
|
|
28
|
+
readonly options: {
|
|
29
|
+
readonly crunch: {
|
|
30
|
+
readonly libraryPath: "libs/";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
13
34
|
//# sourceMappingURL=crunch-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crunch-loader.d.ts","sourceRoot":"","sources":["../src/crunch-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"crunch-loader.d.ts","sourceRoot":"","sources":["../src/crunch-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGrD,2BAA2B;AAC3B,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,2BAA2B;IAC3B,MAAM,CAAC,EAAE;QACP,mEAAmE;QACnE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CAiB8C,CAAC"}
|
package/dist/crunch-loader.js
CHANGED
|
@@ -7,6 +7,8 @@ import { VERSION } from "./lib/utils/version.js";
|
|
|
7
7
|
* @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
|
|
8
8
|
*/
|
|
9
9
|
export const CrunchLoader = {
|
|
10
|
+
dataType: null,
|
|
11
|
+
batchType: null,
|
|
10
12
|
id: 'crunch',
|
|
11
13
|
name: 'Crunch',
|
|
12
14
|
module: 'textures',
|
package/dist/crunch-worker.js
CHANGED
|
@@ -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
|
// ../loader-utils/src/lib/env-utils/assert.ts
|
|
37
4
|
function assert(condition, message) {
|
|
38
5
|
if (!condition) {
|
|
@@ -40,6 +7,17 @@
|
|
|
40
7
|
}
|
|
41
8
|
}
|
|
42
9
|
|
|
10
|
+
// ../loader-utils/src/lib/module-utils/js-module-utils.ts
|
|
11
|
+
function registerJSModules(modules) {
|
|
12
|
+
globalThis.loaders ||= {};
|
|
13
|
+
globalThis.loaders.modules ||= {};
|
|
14
|
+
Object.assign(globalThis.loaders.modules, modules);
|
|
15
|
+
}
|
|
16
|
+
function getJSModuleOrNull(name) {
|
|
17
|
+
const module = globalThis.loaders?.modules?.[name];
|
|
18
|
+
return module || null;
|
|
19
|
+
}
|
|
20
|
+
|
|
43
21
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
44
22
|
function getVersion() {
|
|
45
23
|
if (!globalThis._loadersgl_?.version) {
|
|
@@ -50,7 +28,7 @@
|
|
|
50
28
|
);
|
|
51
29
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
52
30
|
} else {
|
|
53
|
-
globalThis._loadersgl_.version = "4.2.0-
|
|
31
|
+
globalThis._loadersgl_.version = "4.2.0-beta.1";
|
|
54
32
|
}
|
|
55
33
|
}
|
|
56
34
|
return globalThis._loadersgl_.version;
|
|
@@ -203,7 +181,6 @@
|
|
|
203
181
|
}
|
|
204
182
|
|
|
205
183
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
206
|
-
var node = __toESM(require_require_utils(), 1);
|
|
207
184
|
var loadLibraryPromises = {};
|
|
208
185
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
209
186
|
if (moduleName) {
|
|
@@ -240,7 +217,8 @@
|
|
|
240
217
|
}
|
|
241
218
|
if (!isBrowser) {
|
|
242
219
|
try {
|
|
243
|
-
|
|
220
|
+
const { requireFromFile } = globalThis.loaders || {};
|
|
221
|
+
return await requireFromFile?.(libraryUrl);
|
|
244
222
|
} catch (error) {
|
|
245
223
|
console.error(error);
|
|
246
224
|
return null;
|
|
@@ -254,7 +232,8 @@
|
|
|
254
232
|
}
|
|
255
233
|
function loadLibraryFromString(scriptSource, id) {
|
|
256
234
|
if (!isBrowser) {
|
|
257
|
-
|
|
235
|
+
const { requireFromString } = globalThis.loaders || {};
|
|
236
|
+
return requireFromString?.(scriptSource, id);
|
|
258
237
|
}
|
|
259
238
|
if (isWorker) {
|
|
260
239
|
eval.call(globalThis, scriptSource);
|
|
@@ -271,18 +250,20 @@
|
|
|
271
250
|
return null;
|
|
272
251
|
}
|
|
273
252
|
async function loadAsArrayBuffer(url) {
|
|
274
|
-
|
|
253
|
+
const { readFileAsArrayBuffer } = globalThis.loaders || {};
|
|
254
|
+
if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
275
255
|
const response = await fetch(url);
|
|
276
256
|
return await response.arrayBuffer();
|
|
277
257
|
}
|
|
278
|
-
return await (
|
|
258
|
+
return await readFileAsArrayBuffer(url);
|
|
279
259
|
}
|
|
280
260
|
async function loadAsText(url) {
|
|
281
|
-
|
|
261
|
+
const { readFileAsText } = globalThis.loaders || {};
|
|
262
|
+
if (isBrowser || !readFileAsText || url.startsWith("http")) {
|
|
282
263
|
const response = await fetch(url);
|
|
283
264
|
return await response.text();
|
|
284
265
|
}
|
|
285
|
-
return await (
|
|
266
|
+
return await readFileAsText(url);
|
|
286
267
|
}
|
|
287
268
|
|
|
288
269
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
@@ -367,10 +348,12 @@
|
|
|
367
348
|
}
|
|
368
349
|
|
|
369
350
|
// src/lib/utils/version.ts
|
|
370
|
-
var VERSION2 = true ? "4.2.0-
|
|
351
|
+
var VERSION2 = true ? "4.2.0-beta.1" : "latest";
|
|
371
352
|
|
|
372
353
|
// src/crunch-loader.ts
|
|
373
354
|
var CrunchLoader = {
|
|
355
|
+
dataType: null,
|
|
356
|
+
batchType: null,
|
|
374
357
|
id: "crunch",
|
|
375
358
|
name: "Crunch",
|
|
376
359
|
module: "textures",
|
|
@@ -392,9 +375,10 @@
|
|
|
392
375
|
DECODER: "crunch.js"
|
|
393
376
|
};
|
|
394
377
|
async function loadCrunchModule(options) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
378
|
+
registerJSModules(options.modules);
|
|
379
|
+
const crunch = getJSModuleOrNull("crunch");
|
|
380
|
+
if (crunch) {
|
|
381
|
+
return crunch;
|
|
398
382
|
}
|
|
399
383
|
return loadCrunch(options);
|
|
400
384
|
}
|
|
@@ -404,7 +388,7 @@
|
|
|
404
388
|
return crunchModule;
|
|
405
389
|
}
|
|
406
390
|
let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, "textures", options);
|
|
407
|
-
loadCrunchDecoder
|
|
391
|
+
loadCrunchDecoder ||= globalThis.LoadCrunchDecoder;
|
|
408
392
|
crunchModule = loadCrunchDecoder();
|
|
409
393
|
return crunchModule;
|
|
410
394
|
}
|