gputex 0.4.0 → 0.6.0
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/README.md +121 -31
- package/dist/index.d.ts +330 -29
- package/dist/index.js +1815 -522
- package/dist/testing.d.ts +52 -15
- package/dist/testing.js +935 -109
- package/dist/three.d.ts +19 -69
- package/dist/three.js +1743 -666
- package/package.json +1 -1
package/dist/three.d.ts
CHANGED
|
@@ -1,74 +1,14 @@
|
|
|
1
|
-
import { TextureHint, PreferredFormat, SvgRasterSize, TextureFormat, Encoder, EncoderImageSource } from './index.js';
|
|
2
|
-
export { ASTC4x4Encoder, ASTC4x4WebGLEncoder, BC1Encoder, BC1WebGLEncoder, BC5Encoder, BC5WebGLEncoder, BC7Encoder, BC7WebGLEncoder, Capabilities, EncodeBytesResult, EncodeCallOptions, EncoderConstructor, EncoderOptions, ExtensionProvider, FeatureProvider, FormatSelection, FormatVariant, MipLevel, RasterizeSvgOptions, RawPixelSource, SelectFormatOptions, WebGLBlockEncoder, WebGLCapabilities, WebGLEncodeBytesResult, WebGLEncoderConstructor, WebGLEncoderImageSource, WebGLEncoderOptions, WebGLFormatSelection, WebGPUFeature, createWebGLContext, detectCapabilities, detectWebGLCapabilities, generateMipChain, getSharedWebGLContext, isWebGLAvailable, padToBlockMultiple, rasterizeSvg, selectFormat, selectWebGLFormat } from './index.js';
|
|
1
|
+
import { CompressResult as CompressResult$1, CompressTextureSource, CompressOptions, TextureHint, PreferredFormat, FormatQuality, SvgRasterSize, TextureFormat, Encoder, EncoderImageSource } from './index.js';
|
|
2
|
+
export { ASTC4x4Encoder, ASTC4x4WebGLEncoder, BC1Encoder, BC1WebGLEncoder, BC5Encoder, BC5WebGLEncoder, BC7Encoder, BC7EncoderOptions, BC7WebGLEncoder, Capabilities, ETC2Encoder, EncodeBytesResult, EncodeCallOptions, EncodeMipChainResult, EncodedLevelBytes, EncoderConstructor, EncoderOptions, ExtensionProvider, FeatureProvider, FormatSelection, FormatVariant, MipLevel, RasterizeSvgOptions, RawPixelSource, SelectFormatOptions, WebGLBlockEncoder, WebGLCapabilities, WebGLEncodeBytesResult, WebGLEncoderConstructor, WebGLEncoderImageSource, WebGLEncoderOptions, WebGLFormatSelection, WebGPUFeature, clearTranscodeCache, compressTextureToBytes, createWebGLContext, detectCapabilities, detectWebGLCapabilities, generateGpuMipChain, generateMipChain, getSharedWebGLContext, gpuMipLevelCount, isWebGLAvailable, padToBlockMultiple, rasterizeSvg, releaseSharedGpuResources, selectFormat, selectWebGLFormat, setTranscodeCacheLimit } from './index.js';
|
|
3
3
|
import { Texture, CompressedTexture, Loader, CompressedPixelFormat } from 'three';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* SVG works through all of these: a URL to an `.svg` file, a string of
|
|
11
|
-
* inline SVG markup (detected by a leading `<`), an SVG Blob/File, or an
|
|
12
|
-
* HTMLImageElement whose src is SVG. Vector sources are rasterised to RGBA
|
|
13
|
-
* before encoding — see the `svgSize` option.
|
|
14
|
-
*/
|
|
15
|
-
type CompressTextureSource = string | Blob | File | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageData;
|
|
16
|
-
interface CompressOptions {
|
|
17
|
-
/** How the texture will be used. Drives format selection. Default 'color'. */
|
|
18
|
-
hint?: TextureHint;
|
|
19
|
-
/**
|
|
20
|
-
* Prefer a specific format over the default choice when the device
|
|
21
|
-
* supports it; falls back to the normal selection (BC7 → ASTC → RGBA8)
|
|
22
|
-
* when it doesn't. Currently only 'bc1': half the memory of BC7 for
|
|
23
|
-
* opaque colour textures, at lower quality. Only honoured with
|
|
24
|
-
* `hint: 'color'` — BC1 can't carry real alpha or normal maps.
|
|
25
|
-
*/
|
|
26
|
-
preferredFormat?: PreferredFormat;
|
|
27
|
-
/** Pick the sRGB or linear variant of the chosen format. Default 'srgb'. */
|
|
28
|
-
colorSpace?: 'srgb' | 'linear';
|
|
29
|
-
/**
|
|
30
|
-
* Rasterisation size for SVG sources. A number scales the SVG so its
|
|
31
|
-
* longest side matches (aspect ratio preserved); `{ width, height }`
|
|
32
|
-
* rasterises at exactly that size. Default: the SVG's intrinsic size
|
|
33
|
-
* (absolute width/height attributes, else the viewBox dimensions).
|
|
34
|
-
* Ignored for non-SVG sources.
|
|
35
|
-
*/
|
|
36
|
-
svgSize?: SvgRasterSize;
|
|
37
|
-
/** Flip the image vertically before encoding. Default true (matches Three.js convention). */
|
|
38
|
-
flipY?: boolean;
|
|
39
|
-
/** Generate a full mip chain down to 1×1 on the CPU, encode every level. */
|
|
40
|
-
mipmaps?: boolean;
|
|
41
|
-
/** Reuse an existing device (e.g. Three.js's renderer device) instead
|
|
42
|
-
* of creating a new one. WebGPU path only. When provided, the encoder
|
|
43
|
-
* never destroys it. */
|
|
44
|
-
device?: GPUDevice;
|
|
45
|
-
adapter?: GPUAdapter;
|
|
46
|
-
}
|
|
47
|
-
interface CompressResult {
|
|
48
|
-
/** CompressedTexture on a compressed path; Texture on RGBA8 fallback. */
|
|
5
|
+
/** A `compressTexture()` result: a ready-to-use texture plus the same encode
|
|
6
|
+
* metadata `compressTextureToBytes()` returns (minus the raw `levels`). */
|
|
7
|
+
interface CompressResult extends Omit<CompressResult$1, 'levels' | 'fallbackBitmap'> {
|
|
8
|
+
/** `CompressedTexture` on a compressed path; a plain `Texture` on the RGBA8 fallback. */
|
|
49
9
|
texture: Texture | CompressedTexture;
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/** True iff we returned an uncompressed Texture because no encoder fit. */
|
|
53
|
-
fallbackUncompressed: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Which backend produced the result. 'webgpu' = compute path, 'webgl' =
|
|
56
|
-
* fragment-shader fallback, 'none' = uncompressed RGBA8.
|
|
57
|
-
*/
|
|
58
|
-
backend: 'webgpu' | 'webgl' | 'none';
|
|
59
|
-
/**
|
|
60
|
-
* True iff the chosen format is ASTC and the hint was 'normal'. The
|
|
61
|
-
* caller must apply the (R, W) → (x, y) swizzle in the material — ASTC
|
|
62
|
-
* has no 2-channel mode, so normal maps ride the RGBA path.
|
|
63
|
-
*/
|
|
64
|
-
astcNormalRemap: boolean;
|
|
65
|
-
width: number;
|
|
66
|
-
height: number;
|
|
67
|
-
mipLevels: number;
|
|
68
|
-
/** Wall-clock time of GPU encoding, summed across mip levels. */
|
|
69
|
-
encodeMs: number;
|
|
70
|
-
/** Release the encoder's internal GPU resources. No-op if `device` was
|
|
71
|
-
* passed in by the caller. */
|
|
10
|
+
/** Dispose the texture. The shared encoder/device survive — release those
|
|
11
|
+
* with `releaseSharedGpuResources()`. */
|
|
72
12
|
destroy(): void;
|
|
73
13
|
}
|
|
74
14
|
declare function compressTexture(source: CompressTextureSource, options?: CompressOptions): Promise<CompressResult>;
|
|
@@ -82,6 +22,12 @@ declare class GputexLoader extends Loader<Texture> {
|
|
|
82
22
|
* `CompressOptions.preferredFormat`.
|
|
83
23
|
*/
|
|
84
24
|
preferredFormat?: PreferredFormat;
|
|
25
|
+
/**
|
|
26
|
+
* Memory/fidelity trade-off: 'high' (default, BC7 / ASTC) or 'low'
|
|
27
|
+
* (BC1 / ETC2 RGB8 at half the memory, opaque colour only). See
|
|
28
|
+
* `CompressOptions.quality`.
|
|
29
|
+
*/
|
|
30
|
+
quality: FormatQuality;
|
|
85
31
|
/** Pick the sRGB or linear variant of the chosen format. Default 'srgb'. */
|
|
86
32
|
colorSpace: 'srgb' | 'linear';
|
|
87
33
|
/**
|
|
@@ -94,6 +40,10 @@ declare class GputexLoader extends Loader<Texture> {
|
|
|
94
40
|
flipY: boolean;
|
|
95
41
|
/** Generate + encode a full mip chain. Default false. */
|
|
96
42
|
mipmaps: boolean;
|
|
43
|
+
/** Reuse compressed bytes from the session's in-memory transcode cache,
|
|
44
|
+
* skipping decode + encode on repeat loads. See `CompressOptions.cache`.
|
|
45
|
+
* Default false. */
|
|
46
|
+
cache: boolean;
|
|
97
47
|
/**
|
|
98
48
|
* Optional pre-existing WebGPU device. Reusing the renderer's device
|
|
99
49
|
* avoids spinning up a second WebGPU context for encoding.
|
|
@@ -159,4 +109,4 @@ interface EncodeToTextureOptions {
|
|
|
159
109
|
*/
|
|
160
110
|
declare function encodeToTexture(encoder: Encoder, source: EncoderImageSource, { colorSpace, flipY }?: EncodeToTextureOptions): Promise<EncodeResult>;
|
|
161
111
|
|
|
162
|
-
export {
|
|
112
|
+
export { CompressOptions, type CompressResult, CompressTextureSource, type EncodeResult, type EncodeToTextureOptions, Encoder, EncoderImageSource, FormatQuality, GputexLoader, PreferredFormat, SvgRasterSize, TextureFormat, TextureHint, buildCompressedTexture, compressTexture, encodeToTexture, threeFormatFor };
|