Skip to content

Cylinder stock - #130

Merged
dementive merged 6 commits into
mainfrom
dm/cylinder-stock
Oct 2, 2026
Merged

dementive merged 6 commits into
mainfrom
dm/cylinder-stock

Conversation

@dementive

@dementive dementive commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Consolidate stock rendering into Stock, accepting exactly one of geometry, glb, box or cylinder.
  • Box and cylinder inputs accept either resolved placement or part-relative preview options:
    <Stock box={{ partGeometry, dimensions, position, positionOffset }} />
    <Stock cylinder={{ partGeometry, diameter, length, position, positionOffset }} />
  • Support setup-framed boxes and cylinders along arbitrary axes.
  • Decode caller-provided GLB bytes internally. Fetching, caching and artifact storage remain caller-owned.
  • Build stock outlines only when shown.
  • Update the viewer example with separate stock source and shape controls.

Breaking changes

Remove BoxStock and BoxStockProps. Replace them with:

// Allowance-based preview
<Stock box={{ partGeometry, allowance, offset }} />

// Fixed-dimension preview
<Stock box={{ partGeometry, dimensions, position, positionOffset, offset }} />

Existing <Stock geometry={geometry} /> usage remains supported.

StockProps is now a union type alias rather than an interface, so interface X extends StockProps no longer compiles. Use type X = StockProps & { … }, or StockAppearanceProps for the shared appearance props alone.

Public package release

  • Includes a major Changeset for @toolpath/viewer.

dementive and others added 5 commits September 30, 2026 11:12
ShapeStock keys its geometry on a JSON string of the figure and builds from
the parsed copy. JSON writes NaN and Infinity as null, so a non-finite scalar
allowance reached boxStockBounds as null and threw TypeError. The key now
encodes non-finite numbers as strings and the parse restores them, so every
non-finite figure throws RangeError.

A resolved BoxStockInput declares the preview options (offset, allowance,
dimensions, position, positionOffset) as never; they were accepted and
silently ignored.

orientedBoxStockGeometry normalises the frame axis and projects refDirection
square to it before building the basis, so a non-unit or skewed frame no
longer scales or shears the block. A zero refDirection throws RangeError.

The Changeset and README note that StockProps is now a union type alias.
@dementive
dementive merged commit 25f4eaa into main Oct 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants