@cadit-app/script-params 0.5.3 → 0.5.4
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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/sceneOutput.d.ts +424 -0
- package/dist/sceneOutput.d.ts.map +1 -0
- package/dist/sceneOutput.js +92 -0
- package/dist/sceneOutput.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,4 +28,6 @@ export { getExporterMetadata, getExportersMetadata, } from './exporters';
|
|
|
28
28
|
export type { ScriptConfig, ScriptModule, InferParams, } from './script';
|
|
29
29
|
export { defineParams, createMain, } from './script';
|
|
30
30
|
export { schemaToArray, getDefaults, isScriptModule, getParams, getExporters, embedParams, } from './utils';
|
|
31
|
+
export type { BezierPoint2D, PathPoint2D, SculptPoint, Color, ShapeBase, RectInput, TriangleInput, StarInput, CircleInput, PolyPointsInput, HeartInput, PolygonInput, CompoundPathInput, TextInput, ShapeInput, ShapeDefinition, SceneObject2DPolygon, SceneObject2DRect, SceneObject2DCircle, SceneObject2DEllipse, SceneObject2D, SceneObject3DBox, SceneObject3DCylinder, SceneObject3DSphere, SceneObject3DExtrusion, SceneObject3D, SceneObject, AnyShape, SceneOutput, } from './sceneOutput';
|
|
32
|
+
export { rect, circle, star, triangle, regularPolygon, heart, polygon, text, createSceneOutput, isSceneOutput, } from './sceneOutput';
|
|
31
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,YAAY,EACV,YAAY,EAEZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EAEd,YAAY,EACZ,YAAY,EAEZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAEhB,YAAY,EACZ,cAAc,EACd,aAAa,EAEb,cAAc,EACd,aAAa,EAEb,gBAAgB,EAChB,kBAAkB,EAElB,YAAY,EACZ,cAAc,GACf,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,OAAO,EACP,OAAO,EACP,WAAW,EACX,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,UAAU,EACV,MAAM,GACP,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,UAAU,GACX,MAAM,UAAU,CAAC;AAMlB,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAMrB,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,EACZ,UAAU,GACX,MAAM,UAAU,CAAC;AAMlB,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,YAAY,EACV,YAAY,EAEZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EAEd,YAAY,EACZ,YAAY,EAEZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAEhB,YAAY,EACZ,cAAc,EACd,aAAa,EAEb,cAAc,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AGR,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,4 +27,6 @@ export { defineParams, createMain, } from './script';
|
|
|
27
27
|
// Utility Functions
|
|
28
28
|
// =============================================================================
|
|
29
29
|
export { schemaToArray, getDefaults, isScriptModule, getParams, getExporters, embedParams, } from './utils';
|
|
30
|
+
// Helper functions for creating shapes
|
|
31
|
+
export { rect, circle, star, triangle, regularPolygon, heart, polygon, text, createSceneOutput, isSceneOutput, } from './sceneOutput';
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA+DH,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,UAAU,GACX,MAAM,UAAU,CAAC;AAalB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAYrB,OAAO,EACL,YAAY,EACZ,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA+DH,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,UAAU,GACX,MAAM,UAAU,CAAC;AAalB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAYrB,OAAO,EACL,YAAY,EACZ,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,SAAS,CAAC;AAmDjB,uCAAuC;AACvC,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,KAAK,EACL,OAAO,EACP,IAAI,EACJ,iBAAiB,EACjB,aAAa,GACd,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene output types for CADit scripts.
|
|
3
|
+
*
|
|
4
|
+
* These types allow scripts to output CADit scene objects (2D shapes, 3D primitives)
|
|
5
|
+
* instead of a single code object. Supports full CADit features like twist and sculpt.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic shape output with helper functions
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
10
|
+
*
|
|
11
|
+
* export default defineParams({
|
|
12
|
+
* params: {
|
|
13
|
+
* size: { type: 'number', default: 20 },
|
|
14
|
+
* },
|
|
15
|
+
* main: (p) => createSceneOutput([
|
|
16
|
+
* rect(p.size, p.size, { position: { x: 0, y: 0 }, height: 10 }),
|
|
17
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 }, twist: 0.5 }),
|
|
18
|
+
* ]),
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Using sculpt for organic shapes
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { defineParams, createSceneOutput, circle } from '@cadit-app/script-params';
|
|
25
|
+
*
|
|
26
|
+
* export default defineParams({
|
|
27
|
+
* params: {},
|
|
28
|
+
* main: () => createSceneOutput([
|
|
29
|
+
* circle(15, {
|
|
30
|
+
* height: 30,
|
|
31
|
+
* sculpt: [
|
|
32
|
+
* { pos: 0, scale: 0.5 },
|
|
33
|
+
* { pos: 0.5, scale: 1.2 },
|
|
34
|
+
* { pos: 1, scale: 0.5 },
|
|
35
|
+
* ],
|
|
36
|
+
* }),
|
|
37
|
+
* ]),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
/** A point in 2D space */
|
|
42
|
+
export interface Point2D {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
}
|
|
46
|
+
/** A bezier control point with handles */
|
|
47
|
+
export interface BezierPoint2D extends Point2D {
|
|
48
|
+
/** Incoming handle offset (relative to point) */
|
|
49
|
+
handleIn?: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
/** Outgoing handle offset (relative to point) */
|
|
54
|
+
handleOut?: {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
};
|
|
58
|
+
/** Node type for editing behavior */
|
|
59
|
+
nodeType?: 'smooth' | 'corner' | 'auto-smooth';
|
|
60
|
+
}
|
|
61
|
+
/** A path point - either simple or with bezier handles */
|
|
62
|
+
export type PathPoint2D = Point2D | BezierPoint2D;
|
|
63
|
+
/**
|
|
64
|
+
* A sculpt point defines scale at a position along the extrusion height.
|
|
65
|
+
* Used to create vase-like, tapered, or bulging shapes.
|
|
66
|
+
*/
|
|
67
|
+
export interface SculptPoint {
|
|
68
|
+
/** Position along extrusion (0 = bottom, 1 = top) */
|
|
69
|
+
pos: number;
|
|
70
|
+
/** Scale factor at this position (1 = original size) */
|
|
71
|
+
scale: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Color specification - can be hex number, RGB array, or CSS hex string.
|
|
75
|
+
* @example 0xff0000, [255, 0, 0], '#ff0000', '#f00'
|
|
76
|
+
*/
|
|
77
|
+
export type Color = number | [number, number, number] | string;
|
|
78
|
+
/**
|
|
79
|
+
* Base properties shared by all CADit shapes.
|
|
80
|
+
* All properties are optional with sensible defaults.
|
|
81
|
+
*/
|
|
82
|
+
export interface ShapeBase {
|
|
83
|
+
/** Position of shape center */
|
|
84
|
+
position?: Point2D;
|
|
85
|
+
/** Rotation in radians */
|
|
86
|
+
rotation?: number;
|
|
87
|
+
/** Fill color */
|
|
88
|
+
color?: Color;
|
|
89
|
+
/** Whether shape is filled (vs outline). Default: true */
|
|
90
|
+
fill?: boolean;
|
|
91
|
+
/** 3D extrusion height in mm. Default: 2 */
|
|
92
|
+
height?: number;
|
|
93
|
+
/** Z position (vertical offset). Default: 0 */
|
|
94
|
+
z?: number;
|
|
95
|
+
/** Twist angle for 3D extrusion in radians. Default: 0 */
|
|
96
|
+
twist?: number;
|
|
97
|
+
/** Sculpt profile for varying scale along extrusion. Default: uniform */
|
|
98
|
+
sculpt?: SculptPoint[];
|
|
99
|
+
}
|
|
100
|
+
/** Rectangle shape */
|
|
101
|
+
export interface RectInput extends ShapeBase {
|
|
102
|
+
type: 'RECT';
|
|
103
|
+
width: number;
|
|
104
|
+
rectHeight: number;
|
|
105
|
+
}
|
|
106
|
+
/** Triangle shape */
|
|
107
|
+
export interface TriangleInput extends ShapeBase {
|
|
108
|
+
type: 'TRIANGLE';
|
|
109
|
+
width: number;
|
|
110
|
+
triangleHeight: number;
|
|
111
|
+
}
|
|
112
|
+
/** Star shape */
|
|
113
|
+
export interface StarInput extends ShapeBase {
|
|
114
|
+
type: 'STAR';
|
|
115
|
+
rays: number;
|
|
116
|
+
outerRadius: number;
|
|
117
|
+
innerRadius: number;
|
|
118
|
+
}
|
|
119
|
+
/** Circle shape */
|
|
120
|
+
export interface CircleInput extends ShapeBase {
|
|
121
|
+
type: 'CIRCLE';
|
|
122
|
+
radius: number;
|
|
123
|
+
segments?: number;
|
|
124
|
+
}
|
|
125
|
+
/** Regular polygon (hexagon, pentagon, etc.) */
|
|
126
|
+
export interface PolyPointsInput extends ShapeBase {
|
|
127
|
+
type: 'POLY_POINTS';
|
|
128
|
+
numPoints: number;
|
|
129
|
+
radius: number;
|
|
130
|
+
}
|
|
131
|
+
/** Heart shape */
|
|
132
|
+
export interface HeartInput extends ShapeBase {
|
|
133
|
+
type: 'HEART';
|
|
134
|
+
width: number;
|
|
135
|
+
heartHeight: number;
|
|
136
|
+
}
|
|
137
|
+
/** Custom polygon from points */
|
|
138
|
+
export interface PolygonInput extends ShapeBase {
|
|
139
|
+
type: 'POLYGON';
|
|
140
|
+
points: PathPoint2D[];
|
|
141
|
+
holes?: PathPoint2D[][];
|
|
142
|
+
}
|
|
143
|
+
/** Compound path (similar to polygon) */
|
|
144
|
+
export interface CompoundPathInput extends ShapeBase {
|
|
145
|
+
type: 'COMPOUND_PATH';
|
|
146
|
+
points: PathPoint2D[];
|
|
147
|
+
holes?: PathPoint2D[][];
|
|
148
|
+
}
|
|
149
|
+
/** Text shape */
|
|
150
|
+
export interface TextInput extends ShapeBase {
|
|
151
|
+
type: 'TEXT';
|
|
152
|
+
text: string;
|
|
153
|
+
fontFamily?: string;
|
|
154
|
+
fontStyle?: string;
|
|
155
|
+
fontWeight?: number;
|
|
156
|
+
}
|
|
157
|
+
/** Union of all CADit shape inputs */
|
|
158
|
+
export type ShapeInput = RectInput | TriangleInput | StarInput | CircleInput | PolyPointsInput | HeartInput | PolygonInput | CompoundPathInput | TextInput;
|
|
159
|
+
/** Alias for ShapeInput */
|
|
160
|
+
export type ShapeDefinition = ShapeInput;
|
|
161
|
+
/** Create a rectangle */
|
|
162
|
+
export declare function rect(width: number, rectHeight: number, options?: Omit<RectInput, 'type' | 'width' | 'rectHeight'>): RectInput;
|
|
163
|
+
/** Create a circle */
|
|
164
|
+
export declare function circle(radius: number, options?: Omit<CircleInput, 'type' | 'radius'>): CircleInput;
|
|
165
|
+
/** Create a star */
|
|
166
|
+
export declare function star(outerRadius: number, innerRadius: number, rays: number, options?: Omit<StarInput, 'type' | 'rays' | 'outerRadius' | 'innerRadius'>): StarInput;
|
|
167
|
+
/** Create a triangle */
|
|
168
|
+
export declare function triangle(width: number, triangleHeight: number, options?: Omit<TriangleInput, 'type' | 'width' | 'triangleHeight'>): TriangleInput;
|
|
169
|
+
/** Create a regular polygon (hexagon, pentagon, etc.) */
|
|
170
|
+
export declare function regularPolygon(numPoints: number, radius: number, options?: Omit<PolyPointsInput, 'type' | 'numPoints' | 'radius'>): PolyPointsInput;
|
|
171
|
+
/** Create a heart shape */
|
|
172
|
+
export declare function heart(width: number, heartHeight: number, options?: Omit<HeartInput, 'type' | 'width' | 'heartHeight'>): HeartInput;
|
|
173
|
+
/** Create a custom polygon from points */
|
|
174
|
+
export declare function polygon(points: PathPoint2D[], options?: Omit<PolygonInput, 'type' | 'points'>): PolygonInput;
|
|
175
|
+
/** Create a text shape */
|
|
176
|
+
export declare function text(content: string, options?: Omit<TextInput, 'type' | 'text'>): TextInput;
|
|
177
|
+
/**
|
|
178
|
+
* A 2D polygon scene object (legacy format).
|
|
179
|
+
*/
|
|
180
|
+
export interface SceneObject2DPolygon {
|
|
181
|
+
type: '2d-polygon';
|
|
182
|
+
points: (Point2D | BezierPoint2D)[];
|
|
183
|
+
holes?: (Point2D | BezierPoint2D)[][];
|
|
184
|
+
position?: {
|
|
185
|
+
x?: number;
|
|
186
|
+
y?: number;
|
|
187
|
+
z?: number;
|
|
188
|
+
};
|
|
189
|
+
rotation?: number;
|
|
190
|
+
scale?: number | {
|
|
191
|
+
x: number;
|
|
192
|
+
y: number;
|
|
193
|
+
};
|
|
194
|
+
fillColor?: string | [number, number, number];
|
|
195
|
+
strokeColor?: string | [number, number, number];
|
|
196
|
+
strokeWidth?: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A 2D rectangle scene object (legacy format).
|
|
200
|
+
*/
|
|
201
|
+
export interface SceneObject2DRect {
|
|
202
|
+
type: '2d-rect';
|
|
203
|
+
/** Width of the rectangle */
|
|
204
|
+
width: number;
|
|
205
|
+
/** Height of the rectangle */
|
|
206
|
+
height: number;
|
|
207
|
+
/** Corner radius for rounded corners */
|
|
208
|
+
cornerRadius?: number;
|
|
209
|
+
/** Position (center of rectangle) */
|
|
210
|
+
position?: {
|
|
211
|
+
x?: number;
|
|
212
|
+
y?: number;
|
|
213
|
+
z?: number;
|
|
214
|
+
};
|
|
215
|
+
/** Rotation in radians */
|
|
216
|
+
rotation?: number;
|
|
217
|
+
/** Fill color */
|
|
218
|
+
fillColor?: string | [number, number, number];
|
|
219
|
+
/** Stroke color */
|
|
220
|
+
strokeColor?: string | [number, number, number];
|
|
221
|
+
/** Stroke width */
|
|
222
|
+
strokeWidth?: number;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A 2D circle scene object.
|
|
226
|
+
*/
|
|
227
|
+
export interface SceneObject2DCircle {
|
|
228
|
+
type: '2d-circle';
|
|
229
|
+
/** Radius of the circle */
|
|
230
|
+
radius: number;
|
|
231
|
+
/** Number of segments (more = smoother, default 32) */
|
|
232
|
+
segments?: number;
|
|
233
|
+
/** Position (center of circle) */
|
|
234
|
+
position?: {
|
|
235
|
+
x?: number;
|
|
236
|
+
y?: number;
|
|
237
|
+
z?: number;
|
|
238
|
+
};
|
|
239
|
+
/** Fill color */
|
|
240
|
+
fillColor?: string | [number, number, number];
|
|
241
|
+
/** Stroke color */
|
|
242
|
+
strokeColor?: string | [number, number, number];
|
|
243
|
+
/** Stroke width */
|
|
244
|
+
strokeWidth?: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A 2D ellipse scene object.
|
|
248
|
+
*/
|
|
249
|
+
export interface SceneObject2DEllipse {
|
|
250
|
+
type: '2d-ellipse';
|
|
251
|
+
/** Horizontal radius */
|
|
252
|
+
radiusX: number;
|
|
253
|
+
/** Vertical radius */
|
|
254
|
+
radiusY: number;
|
|
255
|
+
/** Number of segments (more = smoother, default 32) */
|
|
256
|
+
segments?: number;
|
|
257
|
+
/** Position (center of ellipse) */
|
|
258
|
+
position?: {
|
|
259
|
+
x?: number;
|
|
260
|
+
y?: number;
|
|
261
|
+
z?: number;
|
|
262
|
+
};
|
|
263
|
+
/** Rotation in radians */
|
|
264
|
+
rotation?: number;
|
|
265
|
+
/** Fill color */
|
|
266
|
+
fillColor?: string | [number, number, number];
|
|
267
|
+
/** Stroke color */
|
|
268
|
+
strokeColor?: string | [number, number, number];
|
|
269
|
+
/** Stroke width */
|
|
270
|
+
strokeWidth?: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A 3D box scene object.
|
|
274
|
+
*/
|
|
275
|
+
export interface SceneObject3DBox {
|
|
276
|
+
type: '3d-box';
|
|
277
|
+
/** Width (X dimension) */
|
|
278
|
+
width: number;
|
|
279
|
+
/** Height (Y dimension) */
|
|
280
|
+
height: number;
|
|
281
|
+
/** Depth (Z dimension) */
|
|
282
|
+
depth: number;
|
|
283
|
+
/** Position (center of box) */
|
|
284
|
+
position?: {
|
|
285
|
+
x?: number;
|
|
286
|
+
y?: number;
|
|
287
|
+
z?: number;
|
|
288
|
+
};
|
|
289
|
+
/** Rotation in radians (Euler angles) */
|
|
290
|
+
rotation?: {
|
|
291
|
+
x?: number;
|
|
292
|
+
y?: number;
|
|
293
|
+
z?: number;
|
|
294
|
+
};
|
|
295
|
+
/** Scale factor */
|
|
296
|
+
scale?: number | {
|
|
297
|
+
x: number;
|
|
298
|
+
y: number;
|
|
299
|
+
z: number;
|
|
300
|
+
};
|
|
301
|
+
/** Material color */
|
|
302
|
+
color?: string | [number, number, number];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* A 3D cylinder scene object.
|
|
306
|
+
*/
|
|
307
|
+
export interface SceneObject3DCylinder {
|
|
308
|
+
type: '3d-cylinder';
|
|
309
|
+
/** Radius at the top */
|
|
310
|
+
radiusTop?: number;
|
|
311
|
+
/** Radius at the bottom */
|
|
312
|
+
radiusBottom?: number;
|
|
313
|
+
/** Radius (same as radiusTop and radiusBottom, used when both are equal) */
|
|
314
|
+
radius?: number;
|
|
315
|
+
/** Height of the cylinder */
|
|
316
|
+
height: number;
|
|
317
|
+
/** Number of radial segments (default 32) */
|
|
318
|
+
segments?: number;
|
|
319
|
+
/** Position (center of cylinder) */
|
|
320
|
+
position?: {
|
|
321
|
+
x?: number;
|
|
322
|
+
y?: number;
|
|
323
|
+
z?: number;
|
|
324
|
+
};
|
|
325
|
+
/** Rotation in radians */
|
|
326
|
+
rotation?: {
|
|
327
|
+
x?: number;
|
|
328
|
+
y?: number;
|
|
329
|
+
z?: number;
|
|
330
|
+
};
|
|
331
|
+
/** Material color */
|
|
332
|
+
color?: string | [number, number, number];
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A 3D sphere scene object.
|
|
336
|
+
*/
|
|
337
|
+
export interface SceneObject3DSphere {
|
|
338
|
+
type: '3d-sphere';
|
|
339
|
+
/** Radius of the sphere */
|
|
340
|
+
radius: number;
|
|
341
|
+
/** Number of segments (default 32) */
|
|
342
|
+
segments?: number;
|
|
343
|
+
/** Position (center of sphere) */
|
|
344
|
+
position?: {
|
|
345
|
+
x?: number;
|
|
346
|
+
y?: number;
|
|
347
|
+
z?: number;
|
|
348
|
+
};
|
|
349
|
+
/** Material color */
|
|
350
|
+
color?: string | [number, number, number];
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* A 3D extrusion from a 2D shape.
|
|
354
|
+
*/
|
|
355
|
+
export interface SceneObject3DExtrusion {
|
|
356
|
+
type: '3d-extrusion';
|
|
357
|
+
/** The 2D shape to extrude */
|
|
358
|
+
shape: SceneObject2DPolygon | SceneObject2DRect | SceneObject2DCircle | SceneObject2DEllipse;
|
|
359
|
+
/** Extrusion height */
|
|
360
|
+
height: number;
|
|
361
|
+
/** Position */
|
|
362
|
+
position?: {
|
|
363
|
+
x?: number;
|
|
364
|
+
y?: number;
|
|
365
|
+
z?: number;
|
|
366
|
+
};
|
|
367
|
+
/** Rotation in radians */
|
|
368
|
+
rotation?: {
|
|
369
|
+
x?: number;
|
|
370
|
+
y?: number;
|
|
371
|
+
z?: number;
|
|
372
|
+
};
|
|
373
|
+
/** Material color */
|
|
374
|
+
color?: string | [number, number, number];
|
|
375
|
+
}
|
|
376
|
+
/** All legacy 2D scene object types */
|
|
377
|
+
export type SceneObject2D = SceneObject2DPolygon | SceneObject2DRect | SceneObject2DCircle | SceneObject2DEllipse;
|
|
378
|
+
/** All legacy 3D scene object types */
|
|
379
|
+
export type SceneObject3D = SceneObject3DBox | SceneObject3DCylinder | SceneObject3DSphere | SceneObject3DExtrusion;
|
|
380
|
+
/** Any legacy scene object */
|
|
381
|
+
export type SceneObject = SceneObject2D | SceneObject3D;
|
|
382
|
+
/** Any shape that can be output (CADit native or legacy) */
|
|
383
|
+
export type AnyShape = ShapeInput | SceneObject;
|
|
384
|
+
/**
|
|
385
|
+
* The result of a scene output script.
|
|
386
|
+
* Contains an array of shapes to be added to the CADit scene.
|
|
387
|
+
*/
|
|
388
|
+
export interface SceneOutput {
|
|
389
|
+
/** Marker to identify this as a scene output result */
|
|
390
|
+
readonly __sceneOutput: true;
|
|
391
|
+
/** The shapes to add to the scene */
|
|
392
|
+
objects: AnyShape[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Create a scene output result from shapes.
|
|
396
|
+
*
|
|
397
|
+
* Accepts either:
|
|
398
|
+
* - An array of shapes (recommended): `createSceneOutput([rect(...), circle(...)])`
|
|
399
|
+
* - Legacy object format: `createSceneOutput({ objects: [...] })`
|
|
400
|
+
*
|
|
401
|
+
* @example Using helper functions (recommended)
|
|
402
|
+
* ```typescript
|
|
403
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
404
|
+
*
|
|
405
|
+
* export default defineParams({
|
|
406
|
+
* params: {
|
|
407
|
+
* size: { type: 'number', default: 20 },
|
|
408
|
+
* },
|
|
409
|
+
* main: (p) => createSceneOutput([
|
|
410
|
+
* rect(p.size, p.size, { height: 10 }),
|
|
411
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 } }),
|
|
412
|
+
* ]),
|
|
413
|
+
* });
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
export declare function createSceneOutput(shapes: AnyShape[]): SceneOutput;
|
|
417
|
+
export declare function createSceneOutput(config: {
|
|
418
|
+
objects: AnyShape[];
|
|
419
|
+
}): SceneOutput;
|
|
420
|
+
/**
|
|
421
|
+
* Type guard to check if a value is a SceneOutput.
|
|
422
|
+
*/
|
|
423
|
+
export declare function isSceneOutput(value: unknown): value is SceneOutput;
|
|
424
|
+
//# sourceMappingURL=sceneOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneOutput.d.ts","sourceRoot":"","sources":["../src/sceneOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,0BAA0B;AAC1B,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,iDAAiD;IACjD,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,iDAAiD;IACjD,SAAS,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,qCAAqC;IACrC,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAC;CAChD;AAED,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,aAAa,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,KAAK,EAAE,MA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B,QAAQ,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAMD,uCAAuC;AACvC,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,oBAAoB,CAAC;AAEzB,uCAAuC;AACvC,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,CAAC;AAE3B,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,aAAa,CAAC;AAExD,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAMhD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC;IAC7B,qCAAqC;IACrC,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;AACnE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG,WAAW,CAAC;AAShF;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAOlE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scene output types for CADit scripts.
|
|
3
|
+
*
|
|
4
|
+
* These types allow scripts to output CADit scene objects (2D shapes, 3D primitives)
|
|
5
|
+
* instead of a single code object. Supports full CADit features like twist and sculpt.
|
|
6
|
+
*
|
|
7
|
+
* @example Basic shape output with helper functions
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineParams, createSceneOutput, rect, circle } from '@cadit-app/script-params';
|
|
10
|
+
*
|
|
11
|
+
* export default defineParams({
|
|
12
|
+
* params: {
|
|
13
|
+
* size: { type: 'number', default: 20 },
|
|
14
|
+
* },
|
|
15
|
+
* main: (p) => createSceneOutput([
|
|
16
|
+
* rect(p.size, p.size, { position: { x: 0, y: 0 }, height: 10 }),
|
|
17
|
+
* circle(p.size / 2, { position: { x: 40, y: 0 }, twist: 0.5 }),
|
|
18
|
+
* ]),
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Using sculpt for organic shapes
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { defineParams, createSceneOutput, circle } from '@cadit-app/script-params';
|
|
25
|
+
*
|
|
26
|
+
* export default defineParams({
|
|
27
|
+
* params: {},
|
|
28
|
+
* main: () => createSceneOutput([
|
|
29
|
+
* circle(15, {
|
|
30
|
+
* height: 30,
|
|
31
|
+
* sculpt: [
|
|
32
|
+
* { pos: 0, scale: 0.5 },
|
|
33
|
+
* { pos: 0.5, scale: 1.2 },
|
|
34
|
+
* { pos: 1, scale: 0.5 },
|
|
35
|
+
* ],
|
|
36
|
+
* }),
|
|
37
|
+
* ]),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
// =============================================================================
|
|
42
|
+
// Helper Functions for Creating Shapes
|
|
43
|
+
// =============================================================================
|
|
44
|
+
/** Create a rectangle */
|
|
45
|
+
export function rect(width, rectHeight, options = {}) {
|
|
46
|
+
return { type: 'RECT', width, rectHeight, ...options };
|
|
47
|
+
}
|
|
48
|
+
/** Create a circle */
|
|
49
|
+
export function circle(radius, options = {}) {
|
|
50
|
+
return { type: 'CIRCLE', radius, ...options };
|
|
51
|
+
}
|
|
52
|
+
/** Create a star */
|
|
53
|
+
export function star(outerRadius, innerRadius, rays, options = {}) {
|
|
54
|
+
return { type: 'STAR', rays, outerRadius, innerRadius, ...options };
|
|
55
|
+
}
|
|
56
|
+
/** Create a triangle */
|
|
57
|
+
export function triangle(width, triangleHeight, options = {}) {
|
|
58
|
+
return { type: 'TRIANGLE', width, triangleHeight, ...options };
|
|
59
|
+
}
|
|
60
|
+
/** Create a regular polygon (hexagon, pentagon, etc.) */
|
|
61
|
+
export function regularPolygon(numPoints, radius, options = {}) {
|
|
62
|
+
return { type: 'POLY_POINTS', numPoints, radius, ...options };
|
|
63
|
+
}
|
|
64
|
+
/** Create a heart shape */
|
|
65
|
+
export function heart(width, heartHeight, options = {}) {
|
|
66
|
+
return { type: 'HEART', width, heartHeight, ...options };
|
|
67
|
+
}
|
|
68
|
+
/** Create a custom polygon from points */
|
|
69
|
+
export function polygon(points, options = {}) {
|
|
70
|
+
return { type: 'POLYGON', points, ...options };
|
|
71
|
+
}
|
|
72
|
+
/** Create a text shape */
|
|
73
|
+
export function text(content, options = {}) {
|
|
74
|
+
return { type: 'TEXT', text: content, ...options };
|
|
75
|
+
}
|
|
76
|
+
export function createSceneOutput(input) {
|
|
77
|
+
const objects = Array.isArray(input) ? input : input.objects;
|
|
78
|
+
return {
|
|
79
|
+
__sceneOutput: true,
|
|
80
|
+
objects,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Type guard to check if a value is a SceneOutput.
|
|
85
|
+
*/
|
|
86
|
+
export function isSceneOutput(value) {
|
|
87
|
+
return (typeof value === 'object' &&
|
|
88
|
+
value !== null &&
|
|
89
|
+
'__sceneOutput' in value &&
|
|
90
|
+
value.__sceneOutput === true);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=sceneOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneOutput.js","sourceRoot":"","sources":["../src/sceneOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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