@genart-dev/plugin-construction 0.1.0
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/README.md +263 -0
- package/dist/index.cjs +2900 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +211 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +2842 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# @genart-dev/plugin-construction
|
|
2
|
+
|
|
3
|
+
Drawing construction guides plugin for [genart.dev](https://genart.dev) — 3D form primitives (box, cylinder, sphere, cone, wedge, egg), cross-contour lines, value/shadow studies, envelope block-ins, and form intersections. All layers are non-destructive guide overlays. Includes MCP tools for AI-agent control.
|
|
4
|
+
|
|
5
|
+
Part of [genart.dev](https://genart.dev) — a generative art platform with an MCP server, desktop app, and IDE extensions.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @genart-dev/plugin-construction
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import constructionPlugin from "@genart-dev/plugin-construction";
|
|
17
|
+
import { createDefaultRegistry } from "@genart-dev/core";
|
|
18
|
+
|
|
19
|
+
const registry = createDefaultRegistry();
|
|
20
|
+
registry.registerPlugin(constructionPlugin);
|
|
21
|
+
|
|
22
|
+
// Or access individual layer types and math utilities
|
|
23
|
+
import {
|
|
24
|
+
formLayerType,
|
|
25
|
+
crossContourLayerType,
|
|
26
|
+
valueShapesLayerType,
|
|
27
|
+
envelopeLayerType,
|
|
28
|
+
intersectionLayerType,
|
|
29
|
+
constructionMcpTools,
|
|
30
|
+
rotationMatrix,
|
|
31
|
+
projectedEllipse,
|
|
32
|
+
lightDirection,
|
|
33
|
+
computeEnvelope,
|
|
34
|
+
approximateIntersection,
|
|
35
|
+
} from "@genart-dev/plugin-construction";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Layer Types (5)
|
|
39
|
+
|
|
40
|
+
### Common Guide Properties
|
|
41
|
+
|
|
42
|
+
Shared by all five layer types:
|
|
43
|
+
|
|
44
|
+
| Property | Type | Default | Description |
|
|
45
|
+
|----------|------|---------|-------------|
|
|
46
|
+
| `guideColor` | color | `"rgba(0,200,255,0.5)"` | Guide line color |
|
|
47
|
+
| `lineWidth` | number | `1` | Line width in pixels (0.5-5) |
|
|
48
|
+
| `dashPattern` | string | `"6,4"` | CSS dash pattern |
|
|
49
|
+
|
|
50
|
+
### Construction Form (`construction:form`, guide)
|
|
51
|
+
|
|
52
|
+
3D form primitive with Euler rotation, projection, cross-contours, and hidden-edge rendering. Supports 6 form types: box, cylinder, sphere, cone, wedge, and egg/ovoid.
|
|
53
|
+
|
|
54
|
+
| Property | Type | Default | Description |
|
|
55
|
+
|----------|------|---------|-------------|
|
|
56
|
+
| `formType` | select | `"box"` | box / cylinder / sphere / cone / wedge / egg |
|
|
57
|
+
| `position` | point | `{x:0.5, y:0.5}` | Normalized position (0-1) |
|
|
58
|
+
| `formSize` | number | `0.25` | Overall size (0.05-0.6) |
|
|
59
|
+
| `sizeX` | number | `1.0` | Width scale (0.2-3.0) |
|
|
60
|
+
| `sizeY` | number | `1.0` | Height scale (0.2-3.0) |
|
|
61
|
+
| `sizeZ` | number | `1.0` | Depth scale (0.2-3.0) |
|
|
62
|
+
| `rotationX` | number | `15` | X rotation in degrees (-90 to 90) |
|
|
63
|
+
| `rotationY` | number | `30` | Y rotation in degrees (-180 to 180) |
|
|
64
|
+
| `rotationZ` | number | `0` | Z rotation in degrees (-180 to 180) |
|
|
65
|
+
| `projection` | select | `"orthographic"` | orthographic / weak-perspective |
|
|
66
|
+
| `showCrossContours` | boolean | `true` | Show cross-contour lines |
|
|
67
|
+
| `crossContourCount` | number | `5` | Number of cross-contour lines (1-12) |
|
|
68
|
+
| `showAxes` | boolean | `true` | Show XYZ axes |
|
|
69
|
+
| `axisLength` | number | `1.2` | Axis length multiplier (0.5-2.0) |
|
|
70
|
+
| `showHiddenEdges` | boolean | `true` | Show hidden edges |
|
|
71
|
+
| `hiddenEdgeStyle` | select | `"dashed"` | dashed / dotted / faint / hidden |
|
|
72
|
+
| `hiddenEdgeAlpha` | number | `0.3` | Hidden edge opacity (0-0.8) |
|
|
73
|
+
| `edgeColor` | color | `"rgba(0,200,255,0.7)"` | Edge line color |
|
|
74
|
+
| `contourColor` | color | `"rgba(100,255,100,0.5)"` | Cross-contour color |
|
|
75
|
+
| `axisColors` | string | `"red,green,blue"` | Axis colors (X,Y,Z comma-separated) |
|
|
76
|
+
|
|
77
|
+
### Cross-Contour Lines (`construction:cross-contour`, guide)
|
|
78
|
+
|
|
79
|
+
Draws cross-contour lines over an arbitrary outline and axis path, revealing surface curvature on any organic shape.
|
|
80
|
+
|
|
81
|
+
| Property | Type | Default | Description |
|
|
82
|
+
|----------|------|---------|-------------|
|
|
83
|
+
| `outline` | string | `"[]"` | Outline points JSON (normalized 0-1) |
|
|
84
|
+
| `axis` | string | `"[]"` | Central axis path JSON (normalized 0-1) |
|
|
85
|
+
| `contourCount` | number | `8` | Number of contour lines (2-20) |
|
|
86
|
+
| `curvature` | number | `0.5` | Curvature (0=flat, 0.5=cylindrical, 1=spherical) |
|
|
87
|
+
| `curvatureVariation` | string | `"[]"` | Per-contour curvature overrides JSON |
|
|
88
|
+
| `contourStyle` | select | `"elliptical"` | elliptical / angular / organic |
|
|
89
|
+
| `showAxis` | boolean | `true` | Show central axis |
|
|
90
|
+
| `showOutline` | boolean | `true` | Show outline |
|
|
91
|
+
| `wrapDirection` | select | `"perpendicular"` | perpendicular / custom |
|
|
92
|
+
| `contourSpacing` | select | `"even"` | even / perspective |
|
|
93
|
+
|
|
94
|
+
### Value Shapes Study (`construction:value-shapes`, guide)
|
|
95
|
+
|
|
96
|
+
Light/shadow value study overlay with terminator, cast shadow, occlusion shadow, and configurable value zones.
|
|
97
|
+
|
|
98
|
+
| Property | Type | Default | Description |
|
|
99
|
+
|----------|------|---------|-------------|
|
|
100
|
+
| `formData` | string | `"[]"` | Form definitions JSON |
|
|
101
|
+
| `lightAzimuth` | number | `315` | Light direction 0-360 degrees |
|
|
102
|
+
| `lightElevation` | number | `45` | Light elevation 10-80 degrees |
|
|
103
|
+
| `lightIntensity` | number | `0.8` | Light intensity (0.1-1.0) |
|
|
104
|
+
| `showLightIndicator` | boolean | `true` | Show light direction indicator |
|
|
105
|
+
| `valueGrouping` | select | `"three-value"` | two-value / three-value / five-value |
|
|
106
|
+
| `shadowColor` | color | `"rgba(0,0,0,0.3)"` | Shadow zone color |
|
|
107
|
+
| `lightColor` | color | `"rgba(255,255,200,0.15)"` | Light zone color |
|
|
108
|
+
| `halftoneColor` | color | `"rgba(0,0,0,0.12)"` | Halftone zone color |
|
|
109
|
+
| `highlightColor` | color | `"rgba(255,255,255,0.25)"` | Highlight zone color |
|
|
110
|
+
| `reflectedLightColor` | color | `"rgba(100,100,120,0.15)"` | Reflected light color |
|
|
111
|
+
| `showTerminator` | boolean | `true` | Show terminator line |
|
|
112
|
+
| `terminatorWidth` | number | `2` | Terminator line width (1-5) |
|
|
113
|
+
| `showCastShadow` | boolean | `true` | Show cast shadow |
|
|
114
|
+
| `showOcclusionShadow` | boolean | `true` | Show occlusion shadow |
|
|
115
|
+
| `showZoneLabels` | boolean | `false` | Show value zone labels |
|
|
116
|
+
| `groundPlaneY` | number | `0.8` | Ground plane Y position (0-1) |
|
|
117
|
+
|
|
118
|
+
### Envelope Block-In (`construction:envelope`, guide)
|
|
119
|
+
|
|
120
|
+
Straight-line envelope (convex hull or fitted polygon) with angle annotations, plumb/level lines, comparative measurements, and recursive subdivisions.
|
|
121
|
+
|
|
122
|
+
| Property | Type | Default | Description |
|
|
123
|
+
|----------|------|---------|-------------|
|
|
124
|
+
| `envelopePath` | string | `"[]"` | Envelope vertex points JSON (normalized 0-1) |
|
|
125
|
+
| `envelopeStyle` | select | `"tight"` | tight (convex hull) / loose (expanded) / fitted (as given) |
|
|
126
|
+
| `showAngles` | boolean | `true` | Show angle annotations |
|
|
127
|
+
| `angleThreshold` | number | `10` | Min angle deviation to annotate (5-45) |
|
|
128
|
+
| `showPlumbLine` | boolean | `true` | Show vertical plumb line |
|
|
129
|
+
| `plumbLinePoint` | point | `{x:0.5, y:0}` | Plumb line reference point |
|
|
130
|
+
| `showLevelLines` | boolean | `false` | Show horizontal level lines |
|
|
131
|
+
| `levelLinePoints` | string | `"[]"` | Level line Y positions JSON |
|
|
132
|
+
| `showMeasurements` | boolean | `false` | Show comparative measurements |
|
|
133
|
+
| `measurementPairs` | string | `"[]"` | Measurement segment pairs JSON |
|
|
134
|
+
| `showSubdivisions` | boolean | `false` | Show midpoint subdivisions |
|
|
135
|
+
| `subdivisionDepth` | number | `1` | Subdivision recursion depth (0-3) |
|
|
136
|
+
| `envelopeColor` | color | `"rgba(255,200,0,0.6)"` | Envelope line color |
|
|
137
|
+
| `plumbColor` | color | `"rgba(0,255,0,0.4)"` | Plumb/level line color |
|
|
138
|
+
| `measureColor` | color | `"rgba(255,100,100,0.5)"` | Measurement color |
|
|
139
|
+
|
|
140
|
+
### Form Intersection (`construction:intersection`, guide)
|
|
141
|
+
|
|
142
|
+
Intersection lines between two or more overlapping 3D forms, computed by surface sampling.
|
|
143
|
+
|
|
144
|
+
| Property | Type | Default | Description |
|
|
145
|
+
|----------|------|---------|-------------|
|
|
146
|
+
| `forms` | string | `"[]"` | Form definitions JSON (min 2) |
|
|
147
|
+
| `showForms` | boolean | `true` | Render the forms |
|
|
148
|
+
| `showIntersectionLines` | boolean | `true` | Show intersection curves |
|
|
149
|
+
| `intersectionWidth` | number | `2.5` | Intersection line width (1-6) |
|
|
150
|
+
| `intersectionColor` | color | `"rgba(255,50,50,0.8)"` | Intersection line color |
|
|
151
|
+
| `intersectionStyle` | select | `"solid"` | solid / bold / emphasized |
|
|
152
|
+
| `showFormLabels` | boolean | `false` | Show A/B/C labels |
|
|
153
|
+
| `transitionType` | select | `"hard"` | hard / soft / mixed |
|
|
154
|
+
|
|
155
|
+
## Test Render
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
16-panel montage showing all layer types with variations:
|
|
160
|
+
- **Row 1**: Box, cylinder, sphere, cone — default rotations with cross-contours and axes
|
|
161
|
+
- **Row 2**: Wedge, egg/ovoid, box (extreme rotation), cylinder (weak-perspective foreshortening)
|
|
162
|
+
- **Row 3**: Cross-contour lines on organic shape, 3-value study, 5-value study (full shadow anatomy), envelope block-in with angles and plumb line
|
|
163
|
+
- **Row 4**: Box+sphere intersection, cylinder+cone intersection (soft), multi-form scene, construction exercise
|
|
164
|
+
|
|
165
|
+
Regenerate with `node render-test-construction.cjs` (requires `canvas` dev dependency).
|
|
166
|
+
|
|
167
|
+
## MCP Tools (8)
|
|
168
|
+
|
|
169
|
+
| Tool | Description |
|
|
170
|
+
|------|-------------|
|
|
171
|
+
| `add_construction_form` | Add a 3D construction form guide layer (box, cylinder, sphere, cone, wedge, egg) |
|
|
172
|
+
| `add_construction_scene` | Add multiple 3D construction forms arranged as a scene |
|
|
173
|
+
| `add_cross_contours` | Add cross-contour lines over an outline + axis path |
|
|
174
|
+
| `add_value_study` | Add a light/shadow value study overlay with terminator and value zones |
|
|
175
|
+
| `add_envelope` | Add a straight-line envelope block-in with angle and measurement annotations |
|
|
176
|
+
| `add_form_intersection` | Add intersection lines between two or more overlapping 3D forms |
|
|
177
|
+
| `generate_construction_exercise` | Generate a random construction exercise with forms at varying difficulty |
|
|
178
|
+
| `clear_construction_guides` | Remove all `construction:*` layers from the layer stack |
|
|
179
|
+
|
|
180
|
+
## Math Overview
|
|
181
|
+
|
|
182
|
+
### Euler Rotation
|
|
183
|
+
|
|
184
|
+
Forms are rotated using ZYX Euler angles: **R = Rz * Ry * Rx**. The X rotation is clamped to [-90, 90] to avoid gimbal lock. The 3x3 rotation matrix transforms vertices, normals, and light directions in a single multiply.
|
|
185
|
+
|
|
186
|
+
### Ellipse Projection
|
|
187
|
+
|
|
188
|
+
A 3D circle viewed at an angle projects to an ellipse. The minor axis equals `radius * |cos(tilt)|` where tilt is the angle between the circle's normal and the view direction. This drives cross-contour rendering on cylinders, cones, spheres, and eggs — each form generates ellipses at regular intervals along its axis.
|
|
189
|
+
|
|
190
|
+
### Shadow Anatomy
|
|
191
|
+
|
|
192
|
+
Light is defined by azimuth (0-360) and elevation (10-80) which convert to a 3D direction vector. On a sphere:
|
|
193
|
+
- **Terminator**: great circle perpendicular to the light direction, rendered as a projected ellipse
|
|
194
|
+
- **Value zones**: the sphere surface is divided into highlight, light, halftone, core shadow, and reflected light regions based on the angle between the surface normal and light direction
|
|
195
|
+
- **Cast shadow**: projected onto the ground plane using `shadowLength = radius / tan(elevation)`
|
|
196
|
+
|
|
197
|
+
### Envelope Geometry
|
|
198
|
+
|
|
199
|
+
Envelopes use Andrew's monotone chain convex hull algorithm. Angle annotations compute the interior angle at each vertex using the dot product of adjacent edge vectors. Plumb lines (vertical) and level lines (horizontal) provide alignment references. Comparative measurements report ratios between segment pairs.
|
|
200
|
+
|
|
201
|
+
### Form Intersection
|
|
202
|
+
|
|
203
|
+
Intersection curves between two forms are approximated by sampling both surfaces in 3D, finding pairs of surface points within a distance threshold, and connecting the midpoints into a curve ordered by nearest-neighbor traversal.
|
|
204
|
+
|
|
205
|
+
## Exported API
|
|
206
|
+
|
|
207
|
+
### Layer Types
|
|
208
|
+
- `formLayerType` — Construction form (box/cylinder/sphere/cone/wedge/egg)
|
|
209
|
+
- `crossContourLayerType` — Cross-contour lines on arbitrary outlines
|
|
210
|
+
- `valueShapesLayerType` — Value/shadow study overlay
|
|
211
|
+
- `envelopeLayerType` — Envelope block-in with annotations
|
|
212
|
+
- `intersectionLayerType` — Form intersection lines
|
|
213
|
+
- `constructionMcpTools` — Array of all 8 MCP tool definitions
|
|
214
|
+
|
|
215
|
+
### Rotation Math (`math/rotation`)
|
|
216
|
+
- `rotationMatrix(rxDeg, ryDeg, rzDeg)` — Build ZYX Euler rotation matrix
|
|
217
|
+
- `rotate3D(point, matrix)` — Transform Vec3 by Mat3
|
|
218
|
+
- `project(point, projection, focalLength)` — Project 3D to 2D
|
|
219
|
+
- `transformPoint(point, rx, ry, rz, projection, focalLength)` — Rotate + project in one call
|
|
220
|
+
- `transformedNormalZ(normal, matrix)` — Z component of transformed normal (face visibility)
|
|
221
|
+
- `identityMatrix()`, `multiplyMat3(a, b)` — Matrix utilities
|
|
222
|
+
- `normalize3(v)`, `dot3(a, b)`, `cross3(a, b)` — Vector operations
|
|
223
|
+
- `clamp(v, min, max)` — Numeric clamp
|
|
224
|
+
|
|
225
|
+
### Ellipse Math (`math/ellipse`)
|
|
226
|
+
- `projectedEllipse(center, radius, normalTilt, axisRotation)` — Circle-to-ellipse projection
|
|
227
|
+
- `drawEllipse(ctx, cx, cy, rx, ry, rotation)` — Draw ellipse arc
|
|
228
|
+
- `drawEllipseWithHidden(ctx, params, frontHalf, hiddenAlpha, hiddenDash)` — Draw with visible/hidden split
|
|
229
|
+
- `ellipsePoints(params, segments)` — Sample points along ellipse
|
|
230
|
+
|
|
231
|
+
### Shadow Math (`math/shadow`)
|
|
232
|
+
- `lightDirection(light)` — 3D light direction from azimuth + elevation
|
|
233
|
+
- `lightDirection2D(light)` — 2D light indicator direction
|
|
234
|
+
- `sphereTerminator(center, radius, light, matrix)` — Terminator ellipse on sphere
|
|
235
|
+
- `castShadow(center, radius, light, groundY)` — Cast shadow polygon
|
|
236
|
+
- `sphereValueZones(center, radius, light, matrix, grouping)` — Value zone paths
|
|
237
|
+
|
|
238
|
+
### Envelope Math (`math/envelope`)
|
|
239
|
+
- `computeEnvelope(points, style)` — Convex hull / expanded / fitted envelope
|
|
240
|
+
- `envelopeAngles(vertices)` — Interior angles at each vertex
|
|
241
|
+
- `plumbLine(referencePoint, bounds)` — Vertical reference line
|
|
242
|
+
- `levelLine(referencePoint, bounds)` — Horizontal reference line
|
|
243
|
+
- `comparativeMeasure(segment1, segment2)` — Segment length ratio
|
|
244
|
+
|
|
245
|
+
### Intersection Math (`math/intersection`)
|
|
246
|
+
- `approximateIntersection(form1, form2, samples)` — Intersection curve between two forms
|
|
247
|
+
|
|
248
|
+
## Related Packages
|
|
249
|
+
|
|
250
|
+
| Package | Purpose |
|
|
251
|
+
|---------|---------|
|
|
252
|
+
| [`@genart-dev/core`](https://github.com/genart-dev/core) | Plugin host, layer system (dependency) |
|
|
253
|
+
| [`@genart-dev/plugin-perspective`](https://github.com/genart-dev/plugin-perspective) | Perspective grids and floor planes |
|
|
254
|
+
| [`@genart-dev/plugin-layout-guides`](https://github.com/genart-dev/plugin-layout-guides) | Composition guides (rule of thirds, golden ratio, grid) |
|
|
255
|
+
| [`@genart-dev/mcp-server`](https://github.com/genart-dev/mcp-server) | MCP server that surfaces plugin tools to AI agents |
|
|
256
|
+
|
|
257
|
+
## Support
|
|
258
|
+
|
|
259
|
+
Questions, bugs, or feedback — [support@genart.dev](mailto:support@genart.dev) or [open an issue](https://github.com/genart-dev/plugin-construction/issues).
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MIT
|