parametrics: add custom field kind + restore fence Length / Curve
User noticed the auto-derived fence inspector was missing the legacy
panel's Length + Curve sliders, and the section labelling was wrong
(Posts → Structure). Both Length and Curve are awkward for the
parametrics field model:
- **Length** doesn't map to a single node key — it's derived from
`start`/`end`, and editing it moves `end` along the existing
direction.
- **Curve** maps to `curveOffset` but the slider's min/max are
bounded per-node by the chord length, plus updates need
`normalizeWallCurveOffset`.
Adds a `kind: 'custom'` field with a kind-supplied
`component: ComponentType<{ node, onUpdate }>`. The inspector mounts
it and lets the kind own rendering + update logic. `key` becomes a
free-form React key/label since it no longer needs to map to a node
property.
Fence parametrics now mirrors the legacy layout 1:1:
- Style (segmented controls + showInfill toggle).
- Dimensions (Length, Curve, Height, Thickness).
- Structure (Base Height, Top Rail, Post Spacing, Post Size, Ground
Clear, Edge Inset).
Length + Curve live in fence/inspector-editors.tsx.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
80199dc890
commit
282cb22585
@@ -1,34 +1,21 @@
|
||||
import type { ParametricDescriptor } from '@pascal-app/core'
|
||||
import { FenceCurveEditor, FenceLengthEditor } from './inspector-editors'
|
||||
import type { FenceNode } from './schema'
|
||||
|
||||
/**
|
||||
* Inspector descriptor for fence.
|
||||
* Inspector descriptor for fence. Mirrors the legacy `FencePanel`
|
||||
* layout 1:1:
|
||||
* - **Style** (segmented controls): style, baseStyle, showInfill toggle.
|
||||
* - **Dimensions**: Length (derived from start/end), Curve (sagitta
|
||||
* with dynamic bounds), Height, Thickness.
|
||||
* - **Structure**: Base Height, Top Rail, Post Spacing, Post Size,
|
||||
* Ground Clear, Edge Inset.
|
||||
*
|
||||
* Mirrors the legacy `fence-panel.tsx` controls but rendered by the
|
||||
* generic `<ParametricInspector>`. Endpoints (`start` / `end`) and
|
||||
* `curveOffset` are edited via floor-plan affordances and 3D handles,
|
||||
* not number inputs — kept out of parametrics.
|
||||
* Length + Curve use the `custom` field kind because they don't map
|
||||
* to single number fields with static bounds — see `inspector-editors.tsx`.
|
||||
*/
|
||||
export const fenceParametrics: ParametricDescriptor<FenceNode> = {
|
||||
groups: [
|
||||
{
|
||||
label: 'Dimensions',
|
||||
fields: [
|
||||
{ key: 'height', kind: 'number', unit: 'm', min: 0.4, max: 3.5, step: 0.05 },
|
||||
{ key: 'thickness', kind: 'number', unit: 'm', min: 0.02, max: 0.3, step: 0.005 },
|
||||
{ key: 'baseHeight', kind: 'number', unit: 'm', min: 0, max: 0.6, step: 0.01 },
|
||||
{ key: 'groundClearance', kind: 'number', unit: 'm', min: 0, max: 0.5, step: 0.01 },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Posts',
|
||||
fields: [
|
||||
{ key: 'postSpacing', kind: 'number', unit: 'm', min: 0.5, max: 5, step: 0.1 },
|
||||
{ key: 'postSize', kind: 'number', unit: 'm', min: 0.04, max: 0.4, step: 0.01 },
|
||||
{ key: 'topRailHeight', kind: 'number', unit: 'm', min: 0, max: 0.2, step: 0.005 },
|
||||
{ key: 'edgeInset', kind: 'number', unit: 'm', min: 0, max: 0.1, step: 0.005 },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Style',
|
||||
fields: [
|
||||
@@ -47,5 +34,25 @@ export const fenceParametrics: ParametricDescriptor<FenceNode> = {
|
||||
{ key: 'showInfill', kind: 'boolean' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Dimensions',
|
||||
fields: [
|
||||
{ key: 'length', kind: 'custom', component: FenceLengthEditor },
|
||||
{ key: 'curve', kind: 'custom', component: FenceCurveEditor },
|
||||
{ key: 'height', kind: 'number', unit: 'm', min: 0.4, max: 4, step: 0.05 },
|
||||
{ key: 'thickness', kind: 'number', unit: 'm', min: 0.03, max: 0.5, step: 0.005 },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Structure',
|
||||
fields: [
|
||||
{ key: 'baseHeight', kind: 'number', unit: 'm', min: 0.04, max: 1, step: 0.01 },
|
||||
{ key: 'topRailHeight', kind: 'number', unit: 'm', min: 0.01, max: 0.25, step: 0.005 },
|
||||
{ key: 'postSpacing', kind: 'number', unit: 'm', min: 0.2, max: 5, step: 0.05 },
|
||||
{ key: 'postSize', kind: 'number', unit: 'm', min: 0.01, max: 0.4, step: 0.005 },
|
||||
{ key: 'groundClearance', kind: 'number', unit: 'm', min: 0, max: 0.6, step: 0.005 },
|
||||
{ key: 'edgeInset', kind: 'number', unit: 'm', min: 0.005, max: 0.25, step: 0.005 },
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user