• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 20352100062

18 Dec 2025 09:37PM UTC coverage: 63.485% (+0.06%) from 63.426%
20352100062

push

github

web-flow
feat: LoaderOptions.core - improved loader type safety (#3112)

7255 of 9672 branches covered (75.01%)

Branch coverage included in aggregate %.

570 of 658 new or added lines in 65 files covered. (86.63%)

8 existing lines in 4 files now uncovered.

67412 of 107942 relevant lines covered (62.45%)

3436.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.75
/modules/textures/src/compressed-texture-loader.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
import type {Loader, LoaderWithParser, StrictLoaderOptions} from '@loaders.gl/loader-utils';
1✔
6
import {VERSION} from './lib/utils/version';
1✔
7
import {parseCompressedTexture} from './lib/parsers/parse-compressed-texture';
1✔
8
import {parseBasis} from './lib/parsers/parse-basis';
1✔
9

1✔
10
/** Options for the CompressedTextureLoader */
1✔
11
export type CompressedTextureLoaderOptions = StrictLoaderOptions & {
1✔
12
  'compressed-texture'?: {
1✔
13
    /** @deprecated Specify path to libraries */
1✔
14
    libraryPath?: string;
1✔
15
    /** Whether to use Basis decoding */
1✔
16
    useBasis?: boolean;
1✔
17
    /** Override the URL to the worker bundle (by default loads from unpkg.com) */
1✔
18
    workerUrl?: string;
1✔
19
  };
1✔
20
};
1✔
21

1✔
22
/**
1✔
23
 * Worker Loader for KTX, DDS, and PVR texture container formats
1✔
24
 */
1✔
25
export const CompressedTextureWorkerLoader = {
1✔
26
  dataType: null as unknown as any,
1✔
27
  batchType: null as never,
1✔
28

1✔
29
  name: 'Texture Containers',
1✔
30
  id: 'compressed-texture',
1✔
31
  module: 'textures',
1✔
32
  version: VERSION,
1✔
33
  worker: true,
1✔
34
  extensions: [
1✔
35
    'ktx',
1✔
36
    'ktx2',
1✔
37
    'dds', // WEBGL_compressed_texture_s3tc, WEBGL_compressed_texture_atc
1✔
38
    'pvr' // WEBGL_compressed_texture_pvrtc
1✔
39
  ],
1✔
40
  mimeTypes: [
1✔
41
    'image/ktx2',
1✔
42
    'image/ktx',
1✔
43
    'image/vnd-ms.dds',
1✔
44
    'image/x-dds',
1✔
45
    'application/octet-stream'
1✔
46
  ],
1✔
47
  binary: true,
1✔
48
  options: {
1✔
49
    'compressed-texture': {
1✔
50
      libraryPath: 'libs/',
1✔
51
      useBasis: false
1✔
52
    }
1✔
53
  }
1✔
54
} as const satisfies Loader<any, never, CompressedTextureLoaderOptions>;
1✔
55

1✔
56
/**
1✔
57
 * Loader for KTX, DDS, and PVR texture container formats
1✔
58
 */
1✔
59
export const CompressedTextureLoader = {
1✔
60
  ...CompressedTextureWorkerLoader,
1✔
61
  parse: async (arrayBuffer: ArrayBuffer, options?: CompressedTextureLoaderOptions) => {
1✔
NEW
62
    options = {...options};
×
63
    if (options?.['compressed-texture']?.useBasis) {
×
64
      options.basis = {
×
65
        format: {
×
66
          alpha: 'BC3',
×
67
          noAlpha: 'BC1'
×
68
        },
×
69
        ...options.basis,
×
70
        containerFormat: 'ktx2',
×
71
        module: 'encoder'
×
72
      };
×
73
      const result = await parseBasis(arrayBuffer, options);
×
74
      return result[0];
×
75
    }
×
76
    return parseCompressedTexture(arrayBuffer);
×
77
  }
×
78
} as const satisfies LoaderWithParser<any, never, CompressedTextureLoaderOptions>;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc