@toolpath/viewer 1.0.0 → 1.1.1

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.
@@ -1,5 +1,5 @@
1
- import { P as PartModel, a as PartMeshRefs } from '../normalize-DsoIyM8B.js';
2
- export { E as EnginePart, b as EnginePartProps, M as MIN_KERNEL_VERSION, c as assertSupportedKernelVersion, n as normalizePartReport, s as smoothRegionNormals } from '../normalize-DsoIyM8B.js';
1
+ import { P as PartModel, a as PartMeshRefs } from '../normalize-OULo7e0F.js';
2
+ export { E as EnginePart, b as EnginePartProps, M as MIN_KERNEL_VERSION, c as assertSupportedKernelVersion, n as normalizePartReport, s as smoothRegionNormals } from '../normalize-OULo7e0F.js';
3
3
  import { BufferGeometry } from 'three';
4
4
  import 'react';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PartModel, V as Vec3, d as ViewerTheme, e as PartModelRegion, T as TriangleRange, F as FeatureTag, R as RegionIndex, f as PartModelFeature, g as FeatureType } from './normalize-DsoIyM8B.js';
2
- export { B as BuildPickInput, C as CANDIDATE_WEIGHT, D as DEFAULT_THEME, h as DIRECTION_COLORS, E as EnginePart, i as FeatureHighlight, H as HANDLE_PIXELS, j as HIGHLIGHT_COLORS, k as HIGHLIGHT_WEIGHT, l as HOVER_WEIGHT, m as HighlightLayers, K as KnownFeatureType, N as NO_MODIFIERS, o as PICKED_SURFACE_LABEL, p as PartMesh, q as PartMeshProps, a as PartMeshRefs, r as PartObject, t as PartPick, u as PickModifiers, v as REGION_ATTRIBUTE, w as RegionHighlight, x as RegionPaint, S as SECTION_RENDER_ORDER, y as SectionAnchor, z as SectionBounds, A as SectionOptions, G as SectionPlacement, I as SectionState, J as SectionView, L as applyHighlightLayers, O as buildPick, Q as buildRegionAttribute, U as buildRegionTexels, W as createPart, X as directionColor, Y as dragPlane, Z as focusForPick, n as normalizePartReport, _ as pickedStartDepth, $ as resolveSectionPlane, a0 as resolveTheme, a1 as sectionBounds, a2 as sectionConstant, a3 as sectionDepth, a4 as sectionDepthConstant, a5 as sectionDepthRange, a6 as sectionFromPick, a7 as sectionOffset, a8 as sectionPlane, s as smoothRegionNormals, a9 as themesEqual, aa as viewDirection } from './normalize-DsoIyM8B.js';
1
+ import { P as PartModel, V as Vec3, d as ViewerTheme, e as PartModelRegion, T as TriangleRange, F as FeatureTag, R as RegionIndex, f as PartModelFeature, g as FeatureType } from './normalize-OULo7e0F.js';
2
+ export { B as BuildPickInput, C as CANDIDATE_WEIGHT, D as DEFAULT_THEME, h as DIRECTION_COLORS, E as EnginePart, i as FeatureHighlight, H as HANDLE_PIXELS, j as HIGHLIGHT_COLORS, k as HIGHLIGHT_WEIGHT, l as HOVER_WEIGHT, m as HighlightLayers, K as KnownFeatureType, o as KnownShapeKind, N as NO_MODIFIERS, p as PICKED_SURFACE_LABEL, q as PartMesh, r as PartMeshProps, a as PartMeshRefs, t as PartObject, u as PartPick, v as PickModifiers, w as REGION_ATTRIBUTE, x as RegionHighlight, y as RegionPaint, S as SECTION_RENDER_ORDER, z as SectionAnchor, A as SectionBounds, G as SectionOptions, I as SectionPlacement, J as SectionState, L as SectionView, O as ShapeKind, Q as applyHighlightLayers, U as buildPick, W as buildRegionAttribute, X as buildRegionTexels, Y as createPart, Z as directionColor, _ as dragPlane, $ as focusForPick, n as normalizePartReport, a0 as pickedStartDepth, a1 as resolveSectionPlane, a2 as resolveTheme, a3 as sectionBounds, a4 as sectionConstant, a5 as sectionDepth, a6 as sectionDepthConstant, a7 as sectionDepthRange, a8 as sectionFromPick, a9 as sectionOffset, aa as sectionPlane, s as smoothRegionNormals, ab as themesEqual, ac as viewDirection } from './normalize-OULo7e0F.js';
3
3
  import { BufferGeometry, CanvasTexture, Vector3, Box3, OrthographicCamera, PerspectiveCamera, Object3D } from 'three';
4
4
  import * as react from 'react';
5
5
  import { RefObject, ReactNode, CSSProperties } from 'react';
@@ -114,7 +114,7 @@ interface GridProps {
114
114
  * fixed cells is either invisible on a 900 mm plate or a solid wash under a
115
115
  * 12 mm insert.
116
116
  */
117
- declare const Grid: ({ step, extent, color, opacity }: GridProps) => react.JSX.Element;
117
+ declare const Grid: ({ step, extent, color, opacity }: GridProps) => react.JSX.Element | null;
118
118
  interface AxesProps {
119
119
  size?: number;
120
120
  }
@@ -336,6 +336,18 @@ interface GridSpec {
336
336
  * The plane is the *bottom* of the part, not `z = 0`: parts usually sit on
337
337
  * `z = 0` and then the two agree, but one modelled about its centre would
338
338
  * otherwise be sliced in half by its own grid.
339
+ *
340
+ * **Give this a measured box.** The plane is `box.min.z`, which is `+Infinity`
341
+ * for an empty one. Nothing else in the spec shows it — `getSize` and
342
+ * `getCenter` both short-circuit to zero for an empty `Box3` — so the step and
343
+ * the extent come back looking ordinary and {@link gridGeometry} then builds
344
+ * every vertex on a plane at infinity, which three.js reports as "Computed
345
+ * radius is NaN" once per mount.
346
+ *
347
+ * `useContentBox` hands back an empty box until the scene has been
348
+ * measured, so a caller pairing the two wants `if (box.isEmpty()) return null`
349
+ * ahead of this. That is what the package's own `Grid` does, and it is why it
350
+ * draws nothing on the opening frame rather than a grid nobody asked for.
339
351
  */
340
352
  declare function gridSpec(box: Box3): GridSpec;
341
353
  /**
package/dist/index.js CHANGED
@@ -155,6 +155,18 @@ function gridGeometry(spec) {
155
155
  geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
156
156
  return geometry;
157
157
  }
158
+ function gridFor(box, options = {}) {
159
+ if (box.isEmpty()) return null;
160
+ const spec = gridSpec(box);
161
+ const cell = options.step ?? spec.step;
162
+ return gridGeometry({
163
+ ...spec,
164
+ step: cell,
165
+ // Snapped outwards to a whole number of cells, so the part sits inside the
166
+ // grid rather than ending part-way through a square.
167
+ extent: options.extent ?? Math.ceil(spec.extent / cell) * cell
168
+ });
169
+ }
158
170
 
159
171
  // src/primitives.tsx
160
172
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -162,18 +174,9 @@ var FURNITURE = { [EXCLUDE_FROM_FRAME]: true };
162
174
  var Grid = ({ step, extent, color, opacity = 0.35 }) => {
163
175
  const theme = resolveTheme();
164
176
  const box = useContentBox();
165
- const geometry = useMemo(() => {
166
- const spec = gridSpec(box);
167
- const cell = step ?? spec.step;
168
- return gridGeometry({
169
- ...spec,
170
- step: cell,
171
- // Snapped outwards to a whole number of cells, so the part sits inside
172
- // the grid rather than ending part-way through a square.
173
- extent: extent ?? Math.ceil(spec.extent / cell) * cell
174
- });
175
- }, [box, extent, step]);
176
- useEffect(() => () => geometry.dispose(), [geometry]);
177
+ const geometry = useMemo(() => gridFor(box, { step, extent }), [box, extent, step]);
178
+ useEffect(() => () => geometry?.dispose(), [geometry]);
179
+ if (!geometry) return null;
177
180
  return /* @__PURE__ */ jsx("lineSegments", { geometry, renderOrder: -1, raycast: () => null, userData: FURNITURE, children: /* @__PURE__ */ jsx("lineBasicMaterial", { color: color ?? theme.cubeEdge, transparent: true, opacity }) });
178
181
  };
179
182
  var Axes = ({ size = 25 }) => /* @__PURE__ */ jsx("axesHelper", { args: [size], userData: FURNITURE, raycast: () => null });
@@ -818,4 +818,4 @@ declare function normalizePartReport(report: unknown): PartModel;
818
818
  */
819
819
  declare function assertSupportedKernelVersion(kernelVersion: string): void;
820
820
 
821
- export { resolveSectionPlane as $, type SectionOptions as A, type BuildPickInput as B, CANDIDATE_WEIGHT as C, DEFAULT_THEME as D, EnginePart as E, type FeatureTag as F, type SectionPlacement as G, HANDLE_PIXELS as H, type SectionState as I, SectionView as J, type KnownFeatureType as K, applyHighlightLayers as L, MIN_KERNEL_VERSION as M, NO_MODIFIERS as N, buildPick as O, type PartModel as P, buildRegionAttribute as Q, type RegionIndex as R, SECTION_RENDER_ORDER as S, type TriangleRange as T, buildRegionTexels as U, type Vec3 as V, createPart as W, directionColor as X, dragPlane as Y, focusForPick as Z, pickedStartDepth as _, type PartMeshRefs as a, resolveTheme as a0, sectionBounds as a1, sectionConstant as a2, sectionDepth as a3, sectionDepthConstant as a4, sectionDepthRange as a5, sectionFromPick as a6, sectionOffset as a7, sectionPlane as a8, themesEqual as a9, viewDirection as aa, type EnginePartProps as b, assertSupportedKernelVersion as c, type ViewerTheme as d, type PartModelRegion as e, type PartModelFeature as f, type FeatureType as g, DIRECTION_COLORS as h, type FeatureHighlight as i, HIGHLIGHT_COLORS as j, HIGHLIGHT_WEIGHT as k, HOVER_WEIGHT as l, type HighlightLayers as m, normalizePartReport as n, PICKED_SURFACE_LABEL as o, PartMesh as p, type PartMeshProps as q, type PartObject as r, smoothRegionNormals as s, type PartPick as t, type PickModifiers as u, REGION_ATTRIBUTE as v, type RegionHighlight as w, type RegionPaint as x, type SectionAnchor as y, type SectionBounds as z };
821
+ export { focusForPick as $, type SectionBounds as A, type BuildPickInput as B, CANDIDATE_WEIGHT as C, DEFAULT_THEME as D, EnginePart as E, type FeatureTag as F, type SectionOptions as G, HANDLE_PIXELS as H, type SectionPlacement as I, type SectionState as J, type KnownFeatureType as K, SectionView as L, MIN_KERNEL_VERSION as M, NO_MODIFIERS as N, type ShapeKind as O, type PartModel as P, applyHighlightLayers as Q, type RegionIndex as R, SECTION_RENDER_ORDER as S, type TriangleRange as T, buildPick as U, type Vec3 as V, buildRegionAttribute as W, buildRegionTexels as X, createPart as Y, directionColor as Z, dragPlane as _, type PartMeshRefs as a, pickedStartDepth as a0, resolveSectionPlane as a1, resolveTheme as a2, sectionBounds as a3, sectionConstant as a4, sectionDepth as a5, sectionDepthConstant as a6, sectionDepthRange as a7, sectionFromPick as a8, sectionOffset as a9, sectionPlane as aa, themesEqual as ab, viewDirection as ac, type EnginePartProps as b, assertSupportedKernelVersion as c, type ViewerTheme as d, type PartModelRegion as e, type PartModelFeature as f, type FeatureType as g, DIRECTION_COLORS as h, type FeatureHighlight as i, HIGHLIGHT_COLORS as j, HIGHLIGHT_WEIGHT as k, HOVER_WEIGHT as l, type HighlightLayers as m, normalizePartReport as n, type KnownShapeKind as o, PICKED_SURFACE_LABEL as p, PartMesh as q, type PartMeshProps as r, smoothRegionNormals as s, type PartObject as t, type PartPick as u, type PickModifiers as v, REGION_ATTRIBUTE as w, type RegionHighlight as x, type RegionPaint as y, type SectionAnchor as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolpath/viewer",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "React Three Fiber viewer for Toolpath Engine part reports",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -55,7 +55,6 @@
55
55
  "react": "19.2.0",
56
56
  "react-dom": "19.2.0",
57
57
  "three": "0.185.1",
58
- "three-stdlib": "2.36.1",
59
58
  "tsup": "8.5.1",
60
59
  "typescript": "5.9.3",
61
60
  "vitest": "4.1.10"