beckhoff-xts-viewer-3d 4.2.0 → 4.4.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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { ColorRepresentation, Shape, Curve, Vector3, CurvePath, Matrix4 } from 'three';
3
+ import { ColorRepresentation, Shape, Curve, Vector3, CurvePath, Matrix4, WebGLRenderer } from 'three';
4
4
  import { GLTF } from 'three-stdlib';
5
5
 
6
6
  /**
@@ -12,7 +12,7 @@ import { GLTF } from 'three-stdlib';
12
12
  * Run `npm run sync-version` (or any script that depends on it) to refresh
13
13
  * after bumping the package version.
14
14
  */
15
- declare const VERSION: "4.2.0";
15
+ declare const VERSION: "4.4.0";
16
16
 
17
17
  /**
18
18
  * Default CDN URL for the GLB asset bundle (`beckhoff-xts-viewer-3d-assets`).
@@ -1696,6 +1696,13 @@ interface XtsViewer3DProps {
1696
1696
  * Falls back to WebGL automatically. Default: false (experimental).
1697
1697
  */
1698
1698
  webgpu?: boolean;
1699
+ /**
1700
+ * Override the KTX2 (Basis) transcoder path used to decode compressed
1701
+ * textures in the GLB assets. Defaults to a CDN copy pinned to the
1702
+ * bundled three.js revision. Point this at a self-hosted
1703
+ * `basis_transcoder.{js,wasm}` directory for offline / air-gapped use.
1704
+ */
1705
+ ktx2TranscoderUrl?: string;
1699
1706
  };
1700
1707
  /**
1701
1708
  * Live override of the per-asset origin-correction sidecars. Useful for
@@ -2245,6 +2252,39 @@ declare function resolveGuidingRailType(moduleType: ModuleType3D): RailType3D |
2245
2252
  */
2246
2253
  declare function resolveGuidingRailGlbUrl(railType: RailType3D, override?: AssetManifest['guidingRails']): string;
2247
2254
 
2255
+ /**
2256
+ * configureGltfLoaders — wire compression decoders onto a GLTFLoader.
2257
+ *
2258
+ * The viewer ships Meshopt-compressed geometry (EXT_meshopt_compression)
2259
+ * and KTX2/Basis-compressed textures (KHR_texture_basisu). Neither decodes
2260
+ * unless the GLTFLoader has the matching decoder attached, so this module
2261
+ * centralises that wiring for both load paths:
2262
+ *
2263
+ * - the render hot-path via drei's `useGLTF` (see `useGltfClone.ts`), and
2264
+ * - the public preload API (`AssetLoader`).
2265
+ *
2266
+ * Design: pure, framework-free functions so the wiring is unit-testable with
2267
+ * fake loader / renderer objects (node has no WebGL2, so KTX2 transcoding
2268
+ * itself is exercised in the browser — see docs/performance-analysis.md).
2269
+ *
2270
+ * Meshopt geometry decodes headless (no GPU needed) and is therefore always
2271
+ * attached. KTX2 transcoding needs the live `WebGLRenderer` to detect the
2272
+ * GPU's supported compressed-texture formats, so it is only attached when a
2273
+ * renderer is provided. A loader configured this way still loads plain,
2274
+ * uncompressed GLBs unchanged — attaching decoders is backward-compatible.
2275
+ */
2276
+
2277
+ interface ConfigureLoaderOptions {
2278
+ /**
2279
+ * The live WebGLRenderer. Required for KTX2 textures — the loader must
2280
+ * detect which GPU-compressed formats the device supports. When omitted
2281
+ * (SSR / node tests), only Meshopt geometry decoding is wired up.
2282
+ */
2283
+ gl?: WebGLRenderer | null;
2284
+ /** Override the KTX2 transcoder (basis) path for this call. */
2285
+ transcoderUrl?: string;
2286
+ }
2287
+
2248
2288
  /**
2249
2289
  * AssetLoader — promise-cached GLB loader for the viewer.
2250
2290
  *
@@ -2265,6 +2305,16 @@ declare function resolveGuidingRailGlbUrl(railType: RailType3D, override?: Asset
2265
2305
  declare class AssetLoader {
2266
2306
  private readonly cache;
2267
2307
  private readonly loader;
2308
+ /**
2309
+ * Wire compression decoders (Meshopt always; KTX2 when a renderer is
2310
+ * supplied) onto the underlying GLTFLoader so Meshopt/KTX2-compressed GLBs
2311
+ * parse. Safe to call repeatedly and before/after loads — it only attaches
2312
+ * decoders and does not touch the cache. Without `gl`, only Meshopt
2313
+ * geometry is wired (KTX2 needs the renderer for GPU-format detection).
2314
+ */
2315
+ configure(options?: ConfigureLoaderOptions & {
2316
+ gl?: WebGLRenderer | null;
2317
+ }): void;
2268
2318
  /**
2269
2319
  * Load a GLB. Repeated calls for the same URL return the cached Promise.
2270
2320
  * Returns the parsed GLTF object — the consumer is responsible for
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { ColorRepresentation, Shape, Curve, Vector3, CurvePath, Matrix4 } from 'three';
3
+ import { ColorRepresentation, Shape, Curve, Vector3, CurvePath, Matrix4, WebGLRenderer } from 'three';
4
4
  import { GLTF } from 'three-stdlib';
5
5
 
6
6
  /**
@@ -12,7 +12,7 @@ import { GLTF } from 'three-stdlib';
12
12
  * Run `npm run sync-version` (or any script that depends on it) to refresh
13
13
  * after bumping the package version.
14
14
  */
15
- declare const VERSION: "4.2.0";
15
+ declare const VERSION: "4.4.0";
16
16
 
17
17
  /**
18
18
  * Default CDN URL for the GLB asset bundle (`beckhoff-xts-viewer-3d-assets`).
@@ -1696,6 +1696,13 @@ interface XtsViewer3DProps {
1696
1696
  * Falls back to WebGL automatically. Default: false (experimental).
1697
1697
  */
1698
1698
  webgpu?: boolean;
1699
+ /**
1700
+ * Override the KTX2 (Basis) transcoder path used to decode compressed
1701
+ * textures in the GLB assets. Defaults to a CDN copy pinned to the
1702
+ * bundled three.js revision. Point this at a self-hosted
1703
+ * `basis_transcoder.{js,wasm}` directory for offline / air-gapped use.
1704
+ */
1705
+ ktx2TranscoderUrl?: string;
1699
1706
  };
1700
1707
  /**
1701
1708
  * Live override of the per-asset origin-correction sidecars. Useful for
@@ -2245,6 +2252,39 @@ declare function resolveGuidingRailType(moduleType: ModuleType3D): RailType3D |
2245
2252
  */
2246
2253
  declare function resolveGuidingRailGlbUrl(railType: RailType3D, override?: AssetManifest['guidingRails']): string;
2247
2254
 
2255
+ /**
2256
+ * configureGltfLoaders — wire compression decoders onto a GLTFLoader.
2257
+ *
2258
+ * The viewer ships Meshopt-compressed geometry (EXT_meshopt_compression)
2259
+ * and KTX2/Basis-compressed textures (KHR_texture_basisu). Neither decodes
2260
+ * unless the GLTFLoader has the matching decoder attached, so this module
2261
+ * centralises that wiring for both load paths:
2262
+ *
2263
+ * - the render hot-path via drei's `useGLTF` (see `useGltfClone.ts`), and
2264
+ * - the public preload API (`AssetLoader`).
2265
+ *
2266
+ * Design: pure, framework-free functions so the wiring is unit-testable with
2267
+ * fake loader / renderer objects (node has no WebGL2, so KTX2 transcoding
2268
+ * itself is exercised in the browser — see docs/performance-analysis.md).
2269
+ *
2270
+ * Meshopt geometry decodes headless (no GPU needed) and is therefore always
2271
+ * attached. KTX2 transcoding needs the live `WebGLRenderer` to detect the
2272
+ * GPU's supported compressed-texture formats, so it is only attached when a
2273
+ * renderer is provided. A loader configured this way still loads plain,
2274
+ * uncompressed GLBs unchanged — attaching decoders is backward-compatible.
2275
+ */
2276
+
2277
+ interface ConfigureLoaderOptions {
2278
+ /**
2279
+ * The live WebGLRenderer. Required for KTX2 textures — the loader must
2280
+ * detect which GPU-compressed formats the device supports. When omitted
2281
+ * (SSR / node tests), only Meshopt geometry decoding is wired up.
2282
+ */
2283
+ gl?: WebGLRenderer | null;
2284
+ /** Override the KTX2 transcoder (basis) path for this call. */
2285
+ transcoderUrl?: string;
2286
+ }
2287
+
2248
2288
  /**
2249
2289
  * AssetLoader — promise-cached GLB loader for the viewer.
2250
2290
  *
@@ -2265,6 +2305,16 @@ declare function resolveGuidingRailGlbUrl(railType: RailType3D, override?: Asset
2265
2305
  declare class AssetLoader {
2266
2306
  private readonly cache;
2267
2307
  private readonly loader;
2308
+ /**
2309
+ * Wire compression decoders (Meshopt always; KTX2 when a renderer is
2310
+ * supplied) onto the underlying GLTFLoader so Meshopt/KTX2-compressed GLBs
2311
+ * parse. Safe to call repeatedly and before/after loads — it only attaches
2312
+ * decoders and does not touch the cache. Without `gl`, only Meshopt
2313
+ * geometry is wired (KTX2 needs the renderer for GPU-format detection).
2314
+ */
2315
+ configure(options?: ConfigureLoaderOptions & {
2316
+ gl?: WebGLRenderer | null;
2317
+ }): void;
2268
2318
  /**
2269
2319
  * Load a GLB. Repeated calls for the same URL return the cached Promise.
2270
2320
  * Returns the parsed GLTF object — the consumer is responsible for