three-cad-viewer 4.3.0 → 4.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-cad-viewer",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "type": "module",
5
5
  "description": "WebGL-based CAD viewer built on Three.js with clipping planes, measurement tools, and tree navigation",
6
6
  "repository": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "4.3.0";
1
+ export const version: string = "4.3.2";
@@ -478,12 +478,10 @@ class MaterialFactory {
478
478
  }
479
479
 
480
480
  // --- Anisotropy (brushed metal) ---
481
- if (def.anisotropy !== undefined) {
482
- material.anisotropy = def.anisotropy;
483
- }
484
- if (def.anisotropyRotation !== undefined) {
485
- material.anisotropyRotation = def.anisotropyRotation;
486
- }
481
+ // Skipped: anisotropic reflections require tangent vectors on the mesh.
482
+ // CAD tessellation never provides tangents, so Three.js falls back to
483
+ // screen-space derivative tangents which produce visible diamond-shaped
484
+ // facet artifacts on coarse meshes.
487
485
 
488
486
  // --- Textures ---
489
487
  // Resolve all texture references via TextureCache.
@@ -536,6 +534,9 @@ class MaterialFactory {
536
534
  // Skip displacement properties (not supported, would waste GPU memory)
537
535
  if (key === "displacement" || key === "displacementScale" || key === "displacementBias") continue;
538
536
 
537
+ // Skip anisotropy — requires tangent vectors that CAD meshes don't have
538
+ if (key === "anisotropy" || key === "anisotropyRotation") continue;
539
+
539
540
  // Color arrays → THREE.Color (already linear, no sRGB conversion)
540
541
  if (COLOR_ARRAY_KEYS.has(key) && Array.isArray(prop.value)) {
541
542
  const [r, g, b] = prop.value as number[];
@@ -718,8 +719,9 @@ class MaterialFactory {
718
719
  const sheenRoughnessTex = await resolve(def.sheenRoughnessMap, "sheenRoughnessTexture");
719
720
  if (sheenRoughnessTex) material.sheenRoughnessMap = sheenRoughnessTex;
720
721
 
721
- const anisotropyTex = await resolve(def.anisotropyMap, "anisotropyTexture");
722
- if (anisotropyTex) material.anisotropyMap = anisotropyTex;
722
+ // Anisotropy texture skipped — CAD meshes lack tangent vectors.
723
+ // const anisotropyTex = await resolve(def.anisotropyMap, "anisotropyTexture");
724
+ // if (anisotropyTex) material.anisotropyMap = anisotropyTex;
723
725
  }
724
726
 
725
727
  /**
@@ -68,6 +68,10 @@ class TextureCache {
68
68
  /** Whether this cache has been fully disposed */
69
69
  private _disposed = false;
70
70
 
71
+ /** Max anisotropic filtering level.
72
+ * Default 16 covers most GPUs; clamped by the driver if unsupported. */
73
+ maxAnisotropy = 16;
74
+
71
75
  // ---------------------------------------------------------------------------
72
76
  // Public API
73
77
  // ---------------------------------------------------------------------------
@@ -272,6 +276,7 @@ class TextureCache {
272
276
  texture.colorSpace = colorSpace;
273
277
  texture.wrapS = THREE.RepeatWrapping;
274
278
  texture.wrapT = THREE.RepeatWrapping;
279
+ texture.anisotropy = this.maxAnisotropy;
275
280
  resolve(texture);
276
281
  },
277
282
  undefined, // onProgress (not used)
File without changes