three-cad-viewer 5.0.1 → 5.0.3

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.
@@ -87612,11 +87612,14 @@ float metalnessFactor = metalness;
87612
87612
  // widen + recolor the flagged segment in-shader (Option A).
87613
87613
  this.highlight?.patchEdgeMaterial(edges.material);
87614
87614
  // Internal measurement backend: record the standalone edge node's geometry
87615
- // (obj_vertices lets the hover status resolve a picked corner's coords).
87615
+ // (obj_vertices lets the hover status resolve a picked corner's coords,
87616
+ // edge_types the exact curve type — without it every edge reads as "other"
87617
+ // and a circle/arc loses its center + radius readout).
87616
87618
  this.meshGeometry.register(path, {
87617
87619
  edges: edgeData.edges,
87618
87620
  segments_per_edge: edgeData.segments_per_edge,
87619
87621
  obj_vertices: edgeData.obj_vertices,
87622
+ edge_types: edgeData.edge_types,
87620
87623
  }, group, null);
87621
87624
  }
87622
87625
  group.setEdges(edges);
@@ -88617,11 +88620,7 @@ float metalnessFactor = metalness;
88617
88620
  this.getCamera = getCamera;
88618
88621
  this.getAxes0 = getAxes0;
88619
88622
  this.onGridChange = onGridChange || null;
88620
- // Heuristics, experimentally determined
88621
- const size = bbox.max_dist_from_center();
88622
- const canvasSize = Math.min(cadWidth, height);
88623
- const scale = Math.max(1.0, 6 - Math.log2(canvasSize / 100));
88624
- this.minFontIndex = Math.round((size < 2 ? 6 : size < 1000 ? 5 : 3) * scale);
88623
+ this.minFontIndex = this.computeMinFontIndex();
88625
88624
  this.minZoomIndex = -4;
88626
88625
  this.zoomMaxIndex = 5;
88627
88626
  this.canvasHeight = 128; // Fixed height for all label textures (higher = crisper)
@@ -88645,6 +88644,27 @@ float metalnessFactor = metalness;
88645
88644
  };
88646
88645
  this.create();
88647
88646
  }
88647
+ /**
88648
+ * Heuristics, experimentally determined
88649
+ */
88650
+ computeMinFontIndex() {
88651
+ const size = this.bbox.max_dist_from_center();
88652
+ const canvasSize = Math.min(this.cadWidth, this.height);
88653
+ const scale = Math.max(1.0, 6 - Math.log2(canvasSize / 100));
88654
+ return Math.round((size < 2 ? 6 : size < 1000 ? 5 : 3) * scale);
88655
+ }
88656
+ /**
88657
+ * Update the cached canvas dimensions after the CAD view was resized.
88658
+ * The label scale is derived from these (see calculateTextScale), so the
88659
+ * caller must rescale afterwards via scaleLabels() / update(zoom, true).
88660
+ * @param cadWidth - New width of the CAD view in pixels
88661
+ * @param height - New height of the CAD view in pixels
88662
+ */
88663
+ resize(cadWidth, height) {
88664
+ this.cadWidth = cadWidth;
88665
+ this.height = height;
88666
+ this.minFontIndex = this.computeMinFontIndex();
88667
+ }
88648
88668
  /**
88649
88669
  * Calculate text scale based on camera mode and canvas size
88650
88670
  */
@@ -97314,7 +97334,7 @@ float metalnessFactor = metalness;
97314
97334
  }
97315
97335
  }
97316
97336
 
97317
- const version = "5.0.1";
97337
+ const version = "5.0.3";
97318
97338
 
97319
97339
  /**
97320
97340
  * `PickedComponent` over a GPU id-pick result. Drives the shader
@@ -108739,20 +108759,41 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
108739
108759
  "shapes" in data &&
108740
108760
  typeof data.shapes === "object");
108741
108761
  }
108762
+ /**
108763
+ * Decode every instance's buffers from base64 into TypedArrays.
108764
+ *
108765
+ * This is the leaf half of the instanced format: it knows the encoding and
108766
+ * nothing about the shapes tree. A host that receives its geometry as raw
108767
+ * binary rather than base64 skips this step and builds the `Shape[]` itself.
108768
+ */
108769
+ function decodeBuffers(instances) {
108770
+ return instances.map(decodeInstance);
108771
+ }
108772
+ /**
108773
+ * Resolve `{ ref: N }` entries in the shapes tree against decoded instances,
108774
+ * and return the tree.
108775
+ *
108776
+ * This is the structural half: the same geometry referenced N times - twenty
108777
+ * identical bolts - which every host needs whatever encoding it received the
108778
+ * buffers in. Held separate from `decodeBuffers` so that a host holding
108779
+ * TypedArrays already does not have to reimplement the walk.
108780
+ */
108781
+ function resolveInstances(shapes, decoded) {
108782
+ resolveRefs(shapes, decoded);
108783
+ return shapes;
108784
+ }
108742
108785
  /**
108743
108786
  * Decode the instanced format into a standard Shapes object.
108744
108787
  *
108745
108788
  * 1. Decode all instance buffers from base64 → TypedArrays
108746
108789
  * 2. Walk the shapes tree and replace { ref: N } with decoded instances
108747
108790
  * 3. Return the unwrapped Shapes object
108791
+ *
108792
+ * Kept as the composition of the two halves above, so existing callers see
108793
+ * no change.
108748
108794
  */
108749
108795
  function decodeInstancedFormat(data) {
108750
- // Decode all instances
108751
- const decoded = data.instances.map(decodeInstance);
108752
- // Resolve all shape references
108753
- const shapes = data.shapes;
108754
- resolveRefs(shapes, decoded);
108755
- return shapes;
108796
+ return resolveInstances(data.shapes, decodeBuffers(data.instances));
108756
108797
  }
108757
108798
 
108758
108799
  // =============================================================================
@@ -112476,6 +112517,13 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
112476
112517
  // Adapt camera to new dimensions
112477
112518
  this.rendered.camera.changeDimensions(this.bb_radius, cadWidth, height);
112478
112519
  this.controls.handleResize();
112520
+ // Rescale the grid labels explicitly: their size is derived from the
112521
+ // canvas height (and, for ortho, the frustum), both of which just
112522
+ // changed — but a resize alone never trips the zoom-based rescale gate
112523
+ // in Grid.update().
112524
+ this.rendered.gridHelper.resize(cadWidth, height);
112525
+ this.rendered.gridHelper.scaleLabels();
112526
+ this.rendered.gridHelper.update(this.rendered.camera.getZoom(), true);
112479
112527
  // Resize the post-processing composer (render targets must match viewport)
112480
112528
  this._studioManager.setSize(cadWidth, height);
112481
112529
  // update the this
@@ -115821,6 +115869,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
115821
115869
  exports.MATERIAL_PRESET_NAMES = MATERIAL_PRESET_NAMES;
115822
115870
  exports.Timer = Timer$1;
115823
115871
  exports.Viewer = Viewer;
115872
+ exports.decodeBuffers = decodeBuffers;
115824
115873
  exports.decodeInstancedFormat = decodeInstancedFormat;
115825
115874
  exports.gpuTracker = gpuTracker;
115826
115875
  exports.hasSegmentsPerEdge = hasSegmentsPerEdge;
@@ -115830,6 +115879,7 @@ void mainImage(const in vec4 inputColor, const in vec2 uv, const in float depth,
115830
115879
  exports.isMaterialXMaterial = isMaterialXMaterial;
115831
115880
  exports.isShapeBinaryFormat = isShapeBinaryFormat;
115832
115881
  exports.logger = logger;
115882
+ exports.resolveInstances = resolveInstances;
115833
115883
  exports.version = version;
115834
115884
 
115835
115885
  }));