@mulmoclaude/shapescript-plugin 2.0.0 → 2.3.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.
Files changed (52) hide show
  1. package/README.md +112 -26
  2. package/dist/core/definition.d.ts.map +1 -1
  3. package/dist/core/index.d.ts +2 -1
  4. package/dist/core/index.d.ts.map +1 -1
  5. package/dist/core/plugin.d.ts.map +1 -1
  6. package/dist/{core-DZvhTmuk.cjs → core-BBgBeYYe.cjs} +1 -1
  7. package/dist/{core-BvTjfhU2.js → core-yB1Eiacr.js} +2 -2
  8. package/dist/core.cjs +1 -1
  9. package/dist/core.js +4 -4
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/lang/de.d.ts.map +1 -1
  13. package/dist/lang/en.d.ts.map +1 -1
  14. package/dist/lang/es.d.ts.map +1 -1
  15. package/dist/lang/fr.d.ts.map +1 -1
  16. package/dist/lang/ja.d.ts.map +1 -1
  17. package/dist/lang/ko.d.ts.map +1 -1
  18. package/dist/lang/messages.d.ts +4 -0
  19. package/dist/lang/messages.d.ts.map +1 -1
  20. package/dist/lang/ptBR.d.ts.map +1 -1
  21. package/dist/lang/zh.d.ts.map +1 -1
  22. package/dist/render/page.d.ts.map +1 -1
  23. package/dist/render.cjs +8 -4
  24. package/dist/render.js +14 -10
  25. package/dist/{samples-CXhuDdDd.js → samples-CT-c9o1S.js} +281 -276
  26. package/dist/samples-D2_jOmoh.cjs +319 -0
  27. package/dist/shapescript/builders.d.ts +12 -2
  28. package/dist/shapescript/builders.d.ts.map +1 -1
  29. package/dist/shapescript/evaluator.d.ts +76 -2
  30. package/dist/shapescript/evaluator.d.ts.map +1 -1
  31. package/dist/shapescript/meshValues.d.ts +54 -0
  32. package/dist/shapescript/meshValues.d.ts.map +1 -0
  33. package/dist/shapescript/minkowski.d.ts +37 -0
  34. package/dist/shapescript/minkowski.d.ts.map +1 -0
  35. package/dist/shapescript/parser.d.ts +66 -2
  36. package/dist/shapescript/parser.d.ts.map +1 -1
  37. package/dist/shapescript/toThreeJS.d.ts +144 -8
  38. package/dist/shapescript/toThreeJS.d.ts.map +1 -1
  39. package/dist/shapescript/types.d.ts +145 -17
  40. package/dist/shapescript/types.d.ts.map +1 -1
  41. package/dist/style.css +1 -1
  42. package/dist/{toThreeJS-FsP-Na75.js → toThreeJS-CKjSbEnA.js} +6670 -4712
  43. package/dist/toThreeJS-Cs0UJm82.cjs +10 -0
  44. package/dist/vue/Preview.vue.d.ts.map +1 -1
  45. package/dist/vue/View.vue.d.ts.map +1 -1
  46. package/dist/vue/index.d.ts +1 -1
  47. package/dist/vue/index.d.ts.map +1 -1
  48. package/dist/vue.cjs +35 -25
  49. package/dist/vue.js +1532 -1493
  50. package/package.json +1 -1
  51. package/dist/samples-DGD0Kjwg.cjs +0 -276
  52. package/dist/toThreeJS-MvllBF9e.cjs +0 -10
@@ -3,6 +3,18 @@ export declare class Parser {
3
3
  /** Whether the expression being parsed is one value of a whitespace-separated
4
4
  * list. See `withValueList`. */
5
5
  private valueList;
6
+ /** Names a bare call may use (`max 0 1`, `sqrt 9`): the built-ins plus every
7
+ * `define name(…)` seen so far, minus names a plain `define` shadows. Lexical
8
+ * and unscoped — a shadow inside a block outlives the block, which only
9
+ * matters to a script that reuses a function's name for a number. */
10
+ private callable;
11
+ /** Custom block names, so a user-defined `light` is still invoked rather
12
+ * than skipped as the upstream light source. */
13
+ private blocks;
14
+ /** Names a plain `define` gave a value, so a keyword reused as a symbol
15
+ * (`define hull (0.2 0.2 0.2)` then `color hull`) reads as that symbol
16
+ * rather than as the shape or builder it spells. */
17
+ private values;
6
18
  private tokens;
7
19
  private pos;
8
20
  constructor(tokens: Token[]);
@@ -14,18 +26,32 @@ export declare class Parser {
14
26
  private expectIdentifier;
15
27
  private skipNewlines;
16
28
  private parseExpression;
29
+ /** `a to b [step s]` after a full expression, or `range step s` to re-step a
30
+ * range held in a symbol. Lowest precedence of all, so `1 to n - 1` runs to
31
+ * `n - 1`; only a whole expression (minPrec 0) can become a range. */
32
+ private parseRangeTail;
17
33
  private parsePrimary;
18
34
  /** The body of a `( … )`, with the opening paren already consumed.
19
35
  *
20
36
  * Both a grouped expression and a space- or comma-separated tuple live here,
21
37
  * so its elements are read as a VALUE LIST: `(1 +2 +3)` is three components,
22
38
  * the same as `1 +2 +3` written without the parens. */
39
+ /** Line breaks inside parentheses carry no meaning (literals.md): a tuple of
40
+ * tuples may be laid out one row per line, and an expression may continue
41
+ * on the next line. Dropping the NEWLINE tokens up to the matching `)` lets
42
+ * the one-line rules decide, with the break counted as whitespace. */
43
+ private stripNewlinesInParens;
23
44
  private parseParenthesized;
24
45
  /** `(1, 2, 3)` — a trailing comma before the `)` ends the list. */
25
46
  private parseCommaSeparated;
26
- /** `(1 2 3)` — components held apart by nothing but whitespace. */
47
+ /** `(1 2 3)` — components held apart by whitespace, line breaks included. */
27
48
  private parseSpaceSeparated;
28
49
  private parseAtom;
50
+ /** `for [name in] iterable { expression }` — the tuple of every result. */
51
+ private parseForExpression;
52
+ /** `if condition { expression } else { expression }`. */
53
+ private parseIfExpression;
54
+ private parseBracedExpression;
29
55
  private getPrecedence;
30
56
  private tokenTypeToOperator;
31
57
  private parseVectorOrExpression;
@@ -34,19 +60,53 @@ export declare class Parser {
34
60
  private parseValueList;
35
61
  private parseProperties;
36
62
  private parseBlockContents;
63
+ /** Run `parse` with the callable and block name sets scoped to it, so a
64
+ * `define max 5` inside a block stops shadowing the built-in at the
65
+ * block's closing brace — the parser-side mirror of the runtime scope. */
66
+ private scoped;
37
67
  private parseBlock;
38
68
  private parseShape;
39
69
  private parseCSG;
70
+ /** `for [name in] <range or tuple> { … }`. The range is an ordinary
71
+ * expression (`1 to n step 2`, or a symbol holding one), so `for 1 to 5`
72
+ * and `for i in loops` read the same way. */
40
73
  private parseForLoop;
74
+ /** A keyword that a binding in scope has claimed as a value — a shape,
75
+ * builder or control-flow word used as a parameter or loop variable.
76
+ * Property and transform commands (`size`, `color`, `scale`, …) are not
77
+ * included: `define size 1 2` must not turn a later `size` command into a
78
+ * value, and inside a block they are read as properties anyway. */
79
+ private isBoundKeyword;
80
+ /** A name bound in the current scope — loop variable, parameter, option —
81
+ * is a value there: not a callable, and not the shape it may spell. */
82
+ private bindName;
83
+ private parseLoopHeader;
41
84
  private parseIf;
42
85
  private parseSwitch;
43
86
  private parseDefine;
87
+ /** An upstream command this renderer lacks, named instead of failing on
88
+ * the brace that follows it. */
89
+ private refuseUnsupported;
90
+ /** Whether `token` opens a statement rather than an expression — used where
91
+ * either may appear, such as a function body. */
92
+ private startsStatement;
93
+ /** The body holds statements — `define`s, and shapes the function builds —
94
+ * and may end in the expression it returns. A function with no result
95
+ * expression returns what its statements built. */
96
+ private parseFunctionDefine;
44
97
  private parseDetail;
45
98
  private parseSeed;
46
99
  private parseBackground;
47
- private parseTexture;
100
+ /** `opacity` / `metallicity` / `roughness` / `glow` / `texture` / `material`
101
+ * as a scoped command. */
102
+ private parseMaterialCommand;
103
+ /** `camera { … }` / `light { … }`: the block is consumed and dropped. */
104
+ private skipIgnoredBlock;
48
105
  private parseGroup;
49
106
  private parseBuilder;
107
+ private isAlongOption;
108
+ /** `along <path or shape>` inside `extrude { … }`: the path the sections are swept along. */
109
+ private parseAlong;
50
110
  /** Run `parse` with the tuple-value break of `isStartOfNewValue` enabled or
51
111
  * suppressed. Whitespace-separated value lists — property values, path
52
112
  * values, the inside of a `( … )` — read ` -1` as the NEXT value; call
@@ -74,12 +134,16 @@ export declare class Parser {
74
134
  /** `point x [y]` / `curve x [y]` — absolute coordinates in the path's local
75
135
  * frame, as upstream. Y defaults to 0. */
76
136
  private parsePathPoint;
137
+ /** `arc` or `arc { angle … position … orientation … size … }` inside a path. */
138
+ private parseArc;
77
139
  /** `translate x [y]` / `scale x [y]` inside a path. A lone `translate x`
78
140
  * moves along X only; a lone `scale s` is uniform, recorded by leaving `y`
79
141
  * out rather than by copying the expression (which would evaluate it twice). */
80
142
  private parsePathVector;
81
143
  private parsePathFor;
82
144
  private parseNode;
145
+ /** `name { option value … }` after the name has been consumed. */
146
+ private parseCustomShapeCall;
83
147
  private refuseStalledToken;
84
148
  parse(): SceneNode[];
85
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shapescript/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,SAAS,EA4BV,MAAM,SAAS,CAAC;AA2djB,qBAAa,MAAM;IACjB;qCACiC;IACjC,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,GAAG,CAAK;gBAEJ,MAAM,EAAE,KAAK,EAAE;IAO3B,OAAO,CAAC,EAAE;IAMV,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;IAgCvB,OAAO,CAAC,YAAY;IAqBpB;;;;4DAIwD;IACxD,OAAO,CAAC,kBAAkB;IAiB1B,mEAAmE;IACnE,OAAO,CAAC,mBAAmB;IAQ3B,mEAAmE;IACnE,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,SAAS;IA4FjB,OAAO,CAAC,aAAa;IA0BrB,OAAO,CAAC,mBAAmB;IAmC3B,OAAO,CAAC,uBAAuB;IAI/B;+EAC2E;IAC3E,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,eAAe;IA8DvB,OAAO,CAAC,kBAAkB;IAgB1B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,QAAQ;IAYhB,OAAO,CAAC,YAAY;IA2EpB,OAAO,CAAC,OAAO;IA8Bf,OAAO,CAAC,WAAW;IA8EnB,OAAO,CAAC,WAAW;IA8DnB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,SAAS;IA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;IAC3B,OAAO,CAAC,oBAAoB;IAM5B,yEAAyE;IACzE,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,YAAY;IA6CpB,OAAO,CAAC,aAAa;IAIrB,6FAA6F;IAC7F,OAAO,CAAC,UAAU;IAUlB;;;iFAG6E;IAC7E,OAAO,CAAC,aAAa;IAUrB;;gEAE4D;IAC5D,OAAO,CAAC,WAAW;IAcnB;iDAC6C;IAC7C,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,SAAS;IAOjB;;;+CAG2C;IAC3C,OAAO,CAAC,aAAa;IAmBrB;mFAC+E;IAC/E,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,gBAAgB;IAgCxB;+CAC2C;IAC3C,OAAO,CAAC,cAAc;IAQtB,gFAAgF;IAChF,OAAO,CAAC,QAAQ;IA6BhB;;qFAEiF;IACjF,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,SAAS;IAsKjB,kEAAkE;IAClE,OAAO,CAAC,oBAAoB;IA2C5B,OAAO,CAAC,kBAAkB;IAM1B,KAAK,IAAI,SAAS,EAAE;CAerB;AAGD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAmB5D"}
@@ -1,5 +1,17 @@
1
1
  import * as THREE from "three";
2
2
  import { SceneNode } from "./types";
3
+ import { RGBA } from "./evaluator";
4
+ /** What a conversion reports besides geometry. Stored on the root group's
5
+ * `userData` so both viewers and the tool result can read it. */
6
+ export interface ShapeScriptSceneInfo {
7
+ /** `background r g b a` from the script's root, when set. */
8
+ background?: RGBA;
9
+ /** Commands that were accepted but not rendered (`texture`, `camera`, …). */
10
+ warnings: string[];
11
+ /** Every `print`, one line each. */
12
+ logs: string[];
13
+ }
14
+ export declare function sceneInfoOf(group: THREE.Object3D): ShapeScriptSceneInfo;
3
15
  export interface ConversionOptions {
4
16
  wireframe?: boolean;
5
17
  /** Hard ceiling on the objects one script may produce. See
@@ -43,6 +55,22 @@ export declare class Converter {
43
55
  /** When this conversion began, checked against `maxDurationMs` on every node. */
44
56
  private readonly startedAt;
45
57
  private transformStack;
58
+ /** > 0 while building a builder's operands, where a bare `path` must be a
59
+ * flat mesh for `profileOf`; at the scene level it draws as a line. */
60
+ private operandDepth;
61
+ private readonly warnings;
62
+ private readonly warningSet;
63
+ private readonly logs;
64
+ private background;
65
+ private sceneDepth;
66
+ /** While set, polygons and shape values produced by statements are
67
+ * collected here instead of entering the scene: the body of `mesh { }`,
68
+ * and a function body whose result is what it built. */
69
+ private valueSink;
70
+ /** Geometries that live on as values (defined shapes, function results,
71
+ * `inset` results). Never in the scene themselves — placing one clones it —
72
+ * so they are released together once the conversion is over. */
73
+ private retained;
46
74
  constructor(options?: ConversionOptions);
47
75
  convert(nodes: SceneNode[]): THREE.Group;
48
76
  private get maxNodes();
@@ -70,11 +98,23 @@ export declare class Converter {
70
98
  * one primitive is bounded by `MAX_DETAIL²`, so the allocation that trips the
71
99
  * limit is small, and it is freed before the refusal propagates. */
72
100
  private makeMesh;
73
- /** Expand a `for … from to to step` range without materialising it first.
74
- * The array used to be built up front, so an absurd bound exhausted memory
75
- * before a single node existed and the budget below never got a turn. */
76
- private rangeIterations;
77
101
  private convertNode;
102
+ /** A `path` handed to a builder: the flat face it encloses, which `profileOf`
103
+ * reads the perimeter back from. */
104
+ private convertPathProfile;
105
+ /** A `detail` inside a path applies to that path alone, as inside any
106
+ * block: restore the enclosing level once its points are read. */
107
+ private withPathDetail;
108
+ /** A `path` in the scene draws as a stroke, as upstream: `fill` makes a
109
+ * face of it, and a builder consumes it. Open paths are allowed here. */
110
+ private convertPathLine;
111
+ private lineFromPath;
112
+ /** Deduplicated and capped: a `texture` inside a 100k-iteration loop must
113
+ * not turn the warning list into a transcript, nor the check into a scan. */
114
+ private warn;
115
+ /** `background` at the root: a colour is kept for the viewer, a texture
116
+ * file cannot be loaded here. */
117
+ private handleBackground;
78
118
  /** Build `group` inside a fresh symbol + transform scope.
79
119
  *
80
120
  * The `catch` is not tidiness: nothing downstream can reach a group that was
@@ -95,8 +135,56 @@ export declare class Converter {
95
135
  * the loop is five too many. */
96
136
  private addChildren;
97
137
  private convertBlock;
138
+ /** A control-flow body: `for`, `if` and `switch` scope SYMBOLS only. Their
139
+ * `translate` / `rotate` / `color` carry on past the closing brace, as
140
+ * upstream (scope.md, "Conditional Scope") — a loop that rotates each
141
+ * iteration leaves the frame where the last one ended. */
142
+ private inSymbolScope;
143
+ /** Wrap a finished geometry in a mesh with the node's material and
144
+ * placement. `scaleBySize` is for builders and groups, whose `size` scales
145
+ * the result; a primitive's `size` is already in its geometry. */
98
146
  private finishMesh;
147
+ /** Run `build` with the shape's own `detail` / `smoothing` in force, then
148
+ * restore the enclosing values. */
149
+ private withShapeOptions;
99
150
  private convertShape;
151
+ /** Run `build` with produced values going to `sink` rather than the scene. */
152
+ private captureValues;
153
+ /** A value a statement produced: collected when a sink is open, otherwise
154
+ * a shape is placed in the scene and anything else is an error, as
155
+ * upstream's "unused value" is. */
156
+ private placeValue;
157
+ private transformedForCapture;
158
+ private convertExpressionStatement;
159
+ /** Place a mesh value in the scene with the current material and frame.
160
+ * Its own vertex colours win over the material colour, as upstream. */
161
+ private placeMesh;
162
+ private placePolygons;
163
+ /** A geometry that stays alive as a value (a `define`d shape, a function's
164
+ * result) counts against the vertex budget for good, since a script can
165
+ * keep making them: refuse when it would overflow, then count it. */
166
+ private chargeRetained;
167
+ /** Build `nodes` at the origin in a throwaway group, collecting the values
168
+ * their statements produced and the geometry of every mesh they built (in
169
+ * the group's frame). The group is disposed and its vertex charge refunded;
170
+ * what is returned is the caller's to charge. */
171
+ private buildScratch;
172
+ /** `mesh { … }`: every polygon its body produces, and every mesh it builds,
173
+ * merged into one mesh in the current frame. */
174
+ private convertMesh;
175
+ /** `polygon { point … }`: one face from explicit 3D vertices, with `color`
176
+ * per vertex, loops and defines, as in a path block. */
177
+ private polygonValue;
178
+ /** `point 1 2 3`, or `point v` where `v` is a tuple. */
179
+ private pointCoordinates;
180
+ private meshesIn;
181
+ /** A shape as a value: built at the origin in a scratch group, its meshes
182
+ * merged into one geometry the script can read members of and place. A
183
+ * polygon block or a function that returned one is that value itself. */
184
+ private shapeValue;
185
+ /** A function whose body builds shapes: run it at the origin with its
186
+ * parameters bound, and return what it built — one value, or a tuple. */
187
+ private callShapeFunction;
100
188
  /** A solid whose extent is zero in any dimension draws nothing.
101
189
  *
102
190
  * `sphere { size 0 }` built a mesh with an empty bounding box, and
@@ -106,19 +194,35 @@ export declare class Converter {
106
194
  * definition and fall back to a unit size of their own. */
107
195
  private requireExtent;
108
196
  private createGeometry;
197
+ /** `roundrect { size w h radius r }`: the corner radius is `r` times the
198
+ * smaller side (default 0.25), as upstream. */
199
+ private createRoundrect;
109
200
  /** A plugin extension (upstream has no torus). `size` is the OVERALL
110
201
  * diameter, tube included, so it follows the same rule as the other curved
111
202
  * primitives: the ring radius is what is left once the tube is subtracted.
112
203
  * `outerRadius` (ring) and `innerRadius` (tube) override the derivation. */
113
204
  private createTorus;
114
- private materialColor;
205
+ /** The material state a shape's own properties produce on top of `base`:
206
+ * a `material` bundle first, then the individual properties, the way the
207
+ * same commands would apply in order inside its block. */
208
+ private materialFor;
209
+ private applyColor;
210
+ /** `glow` takes a colour or a brightness; the alpha is ignored upstream. */
211
+ private glowColor;
212
+ private warnTexture;
213
+ private applyMaterialValue;
115
214
  private createMaterial;
116
215
  private convertCSG;
117
216
  private convertForLoop;
217
+ /** Expand a loop's iterable without materialising an absurd range first:
218
+ * the walk stops at the budget rather than after allocating past it. */
219
+ private iterations;
118
220
  private convertIf;
119
221
  private convertSwitch;
120
222
  private handleDefine;
121
223
  private convertCustomShape;
224
+ /** Post-multiply a shape's `position` / `orientation` / `size` into a frame. */
225
+ private applyPlacement;
122
226
  private pushTransform;
123
227
  private popTransform;
124
228
  private currentTransform;
@@ -135,6 +239,7 @@ export declare class Converter {
135
239
  private rotationComponents;
136
240
  private handleDetail;
137
241
  private handleColorCommand;
242
+ private handleMaterialCommand;
138
243
  private handleRotateCommand;
139
244
  private handleOrientationCommand;
140
245
  private handleTranslateCommand;
@@ -148,7 +253,25 @@ export declare class Converter {
148
253
  * path. Sampled at the same resolution the geometry will use, so a curve
149
254
  * that only looks flat at low detail is not rejected. */
150
255
  private requireEnclosedArea;
256
+ /** `size` on an extrude: X and Y scale the profile, Z is the depth. The
257
+ * depth goes into the geometry (centred on the profile plane, as
258
+ * upstream), so the mesh keeps a unit Z scale. */
259
+ private extrudeProperties;
151
260
  private convertExtrude;
261
+ /** Path samples as 3D points, refused when they would not survive the trip
262
+ * into a Float32 position attribute. */
263
+ private finitePoints;
264
+ /** `extrude { section … along path }`: every planar child is a section swept
265
+ * along the path — its +Z turned to the path's tangent — and the sections
266
+ * are joined into one solid, capped at the ends of an open path. `size`
267
+ * scales the result as a whole, as on any shape. */
268
+ private convertExtrudeAlong;
269
+ /** A planar child's perimeter as a section in the XY plane, wound
270
+ * counter-clockwise so the swept walls face outward. */
271
+ private sectionOf;
272
+ /** The points of the `along` path — a stroke for an open path, a planar
273
+ * shape's perimeter for a closed one — built in a scratch group. */
274
+ private sweepPathOf;
152
275
  private buildPath;
153
276
  /** Bake the path's own `position` / `orientation` / `size` into geometry
154
277
  * built from it. Baked rather than set on the mesh so the consuming
@@ -164,6 +287,11 @@ export declare class Converter {
164
287
  * post-multiplied like the shape transform, and checked after every command
165
288
  * because individually finite operands can still overflow it. */
166
289
  private collectPathPoints;
290
+ private placePathPoint;
291
+ /** `arc { angle a }`: `a` half-turns clockwise from +Y at radius `size / 2`,
292
+ * placed by its own position/orientation, sampled as corners at the current
293
+ * detail (upstream's own segment count for the span). */
294
+ private placeArc;
167
295
  private runPathLoop;
168
296
  /** Join path points into an outline, treating `curve` points as upstream does.
169
297
  *
@@ -190,20 +318,28 @@ export declare class Converter {
190
318
  private buildOperands;
191
319
  private buildFromChildren;
192
320
  private convertLoft;
321
+ private buildLoft;
193
322
  private planarShape;
194
323
  private convertFill;
324
+ /** `minkowski { a b … }`: the children summed left to right, each solid
325
+ * swept over every point of the next. The result keeps the first child's
326
+ * colour, as upstream keeps its material. */
327
+ private convertMinkowski;
195
328
  private convertHull;
196
329
  private evaluateNumber;
330
+ /** A `position`: one value is X alone (`position 1` is `1 0 0`, as
331
+ * upstream and as `translate` here), the rest are padded with zeros. */
197
332
  private evaluateVector3;
333
+ /** A `size`: one value is uniform, two are `x y x` (a cylinder's diameter
334
+ * and height), three are as given — Euclid's `Vector(size:)`. */
335
+ private evaluateSize;
336
+ private evaluateRGBA;
198
337
  private evaluateTranslateVector;
199
- private evaluateColor;
200
338
  /** Colour channels get the same treatment as sizes and translations.
201
339
  * `new THREE.Color(Infinity, …)` throws nothing — it serialises as
202
340
  * `[null, null, null]`, so validation reported success and the browser was
203
341
  * handed a material it cannot draw. */
204
342
  private requireFiniteColor;
205
- private evaluateVector3OrColor;
206
- private valuesEqual;
207
343
  }
208
344
  export declare function astToThreeJS(nodes: SceneNode[], options?: ConversionOptions): THREE.Group;
209
345
  //# sourceMappingURL=toThreeJS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toThreeJS.d.ts","sourceRoot":"","sources":["../../src/shapescript/toThreeJS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EACL,SAAS,EA4BV,MAAM,SAAS,CAAC;AAqBjB,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;+BAC2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;yCACqC;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;kCAC8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;qCACiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;+DAE2D;IAC3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AMjB;yEACqE;IACrE,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,SAAS;IAIjB;;;qEAGiE;IACjE,OAAO,CAAC,SAAS;IAQjB;;;;;;;sEAOkE;IAClE,OAAO,CAAC,iBAAiB;IAoEzB,OAAO,CAAC,cAAc;IAMtB;;8DAE0D;IAC1D,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,WAAW;IAgBnB;;;;;;;;+EAQ2E;IAC3E,OAAO,CAAC,mBAAmB;IAkC3B,OAAO,CAAC,YAAY;IAMpB;;;;;4EAKwE;IACxE,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,UAAU;IAqDlB;;kDAE8C;IAC9C,OAAO,CAAC,aAAa;IA4BrB,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;IAuBnB;;kDAE8C;IAC9C,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,cAAc;IAQtB;6EACyE;IACzE,OAAO,CAAC,eAAe;IAUvB;sEACkE;IAClE,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,uBAAuB;IAiB/B;;;4CAGwC;IACxC,OAAO,CAAC,kBAAkB;CAI3B;AAwGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,iBAAsB,GAAG,KAAK,CAAC,KAAK,CAG7F"}
@@ -1,6 +1,26 @@
1
1
  export type Vector3 = [number, number, number];
2
2
  export type Color = [number, number, number];
3
- export type Expression = NumberLiteral | StringLiteral | IdentifierExpr | BinaryExpr | UnaryExpr | FunctionCall | MemberAccess | SubscriptExpr | TupleExpr;
3
+ export type Expression = NumberLiteral | StringLiteral | IdentifierExpr | BinaryExpr | UnaryExpr | FunctionCall | MemberAccess | SubscriptExpr | TupleExpr | RangeExpr | MaterialExpr | ShapeExpr | ForExpr | IfExpr;
4
+ /** A shape used as a value: `define ico icosphere { detail 0 }`. Built by the
5
+ * converter into a mesh value the script can read members of and place. */
6
+ export interface ShapeExpr {
7
+ type: "shape";
8
+ node: SceneNode;
9
+ }
10
+ /** `for v in iterable { expr }` as a value: the tuple of every iteration's result. */
11
+ export interface ForExpr {
12
+ type: "for";
13
+ variable: string;
14
+ iterable: Expression;
15
+ body: Expression;
16
+ }
17
+ /** `if cond { a } else { b }` as a value. */
18
+ export interface IfExpr {
19
+ type: "if";
20
+ condition: Expression;
21
+ then: Expression;
22
+ else?: Expression;
23
+ }
4
24
  export interface NumberLiteral {
5
25
  type: "number";
6
26
  value: number;
@@ -43,21 +63,64 @@ export interface TupleExpr {
43
63
  type: "tuple";
44
64
  elements: Expression[];
45
65
  }
46
- export type SceneNode = ShapeNode | CSGNode | BlockNode | ForLoopNode | IfNode | SwitchNode | DefineNode | ExtrudeNode | LoftNode | LatheNode | FillNode | HullNode | GroupNode | DetailNode | SeedNode | PathNode | BackgroundNode | TextureNode | ColorNode | RotateNode | OrientationNode | TranslateNode | ScaleNode | CustomShapeNode;
66
+ /** `from to to [step s]`, or `existing step s` when `to` is absent a range
67
+ * value a `for` loop walks and the `in` operator tests, as upstream. */
68
+ export interface RangeExpr {
69
+ type: "range";
70
+ from: Expression;
71
+ to?: Expression;
72
+ step?: Expression;
73
+ }
74
+ /** `material { color … roughness … }` — a bundle of material properties that
75
+ * `define` can name and the `material` command re-applies. */
76
+ export interface MaterialExpr {
77
+ type: "material";
78
+ properties: MaterialProperties;
79
+ }
80
+ export interface MaterialProperties {
81
+ color?: Color | Expression;
82
+ opacity?: number | Expression;
83
+ metallicity?: number | Expression;
84
+ roughness?: number | Expression;
85
+ glow?: Color | Expression;
86
+ texture?: Expression;
87
+ }
88
+ export type SceneNode = ShapeNode | CSGNode | BlockNode | ForLoopNode | IfNode | SwitchNode | DefineNode | ExtrudeNode | LoftNode | LatheNode | FillNode | HullNode | MinkowskiNode | GroupNode | DetailNode | SeedNode | PathNode | BackgroundNode | MaterialNode | SmoothingNode | PrintNode | AssertNode | IgnoredNode | MeshNode | ExpressionStatementNode | ColorNode | RotateNode | OrientationNode | TranslateNode | ScaleNode | CustomShapeNode;
47
89
  export interface ShapeNode {
48
90
  type: "shape";
49
- primitive: "cube" | "sphere" | "cylinder" | "cone" | "torus" | "circle" | "square" | "polygon";
91
+ primitive: ShapePrimitive;
50
92
  properties: ShapeProperties;
51
93
  children?: SceneNode[];
94
+ /** `polygon { point … }`: explicit vertices (3D), with `color` and loops,
95
+ * making a single face rather than a regular polygon. */
96
+ points?: PathCommand[];
97
+ }
98
+ /** `mesh { polygon { … } … }` — a mesh assembled from polygon values. */
99
+ export interface MeshNode {
100
+ type: "mesh";
101
+ children: SceneNode[];
102
+ }
103
+ /** A bare expression as a statement: a call that returns a shape (`face data`
104
+ * inside `mesh`), or the value a function body ends with. */
105
+ export interface ExpressionStatementNode {
106
+ type: "expression";
107
+ value: Expression;
52
108
  }
53
- export interface ShapeProperties {
109
+ export type ShapePrimitive = "cube" | "sphere" | "icosphere" | "cylinder" | "cone" | "torus" | "circle" | "square" | "roundrect" | "polygon";
110
+ export interface ShapeProperties extends MaterialProperties {
54
111
  position?: Vector3 | Expression;
55
112
  rotation?: Vector3 | Expression;
56
113
  orientation?: Vector3 | Expression;
57
114
  size?: Vector3 | Expression;
58
- color?: Color | Expression;
59
- opacity?: number | Expression;
115
+ /** `material name` inside a block: every property of the named bundle. */
116
+ material?: Expression;
117
+ /** Per-shape `detail` / `smoothing`, as upstream allows inside any block. */
118
+ detail?: number | Expression;
119
+ smoothing?: number | Expression;
120
+ name?: Expression;
60
121
  sides?: number | Expression;
122
+ /** `roundrect` corner radius, as a proportion of the smaller side. */
123
+ radius?: number | Expression;
61
124
  radiusTop?: number | Expression;
62
125
  radiusBottom?: number | Expression;
63
126
  height?: number | Expression;
@@ -73,15 +136,13 @@ export interface BlockNode {
73
136
  type: "block";
74
137
  children: SceneNode[];
75
138
  }
139
+ /** `for v in <iterable> { … }`. The iterable is one expression: a range
140
+ * (`1 to 5 step 2`, or a symbol holding one) or a tuple of values. */
76
141
  export interface ForLoopNode {
77
142
  type: "for";
78
143
  variable: string;
79
- from: Expression | number;
80
- to: Expression | number;
81
- step?: Expression | number;
82
- iterableValues?: Expression;
144
+ iterable: Expression;
83
145
  body: SceneNode[];
84
- transforms?: TransformNode[];
85
146
  }
86
147
  export interface IfNode {
87
148
  type: "if";
@@ -108,6 +169,10 @@ export interface DefineNode {
108
169
  value?: Expression;
109
170
  options?: OptionNode[];
110
171
  body?: SceneNode[];
172
+ /** `define name(a b) { … }` — a function. `body` holds its statements
173
+ * (defines, or shapes it builds) and `value` the expression it ends with,
174
+ * if any; a function with no final expression returns what it built. */
175
+ params?: string[];
111
176
  }
112
177
  export interface OptionNode {
113
178
  type: "option";
@@ -127,10 +192,34 @@ export interface BackgroundNode {
127
192
  type: "background";
128
193
  value: Expression;
129
194
  }
130
- export interface TextureNode {
131
- type: "texture";
195
+ /** A scoped material command: `opacity 0.5`, `metallicity 1`, `roughness 0.2`,
196
+ * `glow red`, `texture "file.png"` (warned, not rendered) or `material name`. */
197
+ export interface MaterialNode {
198
+ type: "material";
199
+ property: "opacity" | "metallicity" | "roughness" | "glow" | "texture" | "material";
200
+ value: Expression;
201
+ }
202
+ /** `smoothing N` — 0 draws every edge sharp (flat shading); anything else smooth. */
203
+ export interface SmoothingNode {
204
+ type: "smoothing";
205
+ value: Expression;
206
+ }
207
+ /** `print a b …` — logged, and returned to the agent with the tool result. */
208
+ export interface PrintNode {
209
+ type: "print";
210
+ value: Expression;
211
+ }
212
+ /** `assert condition` — a failing assertion stops the script. */
213
+ export interface AssertNode {
214
+ type: "assert";
132
215
  value: Expression;
133
216
  }
217
+ /** A block upstream renders but this renderer does not (`camera`, `light`):
218
+ * parsed and skipped, with a warning naming it. */
219
+ export interface IgnoredNode {
220
+ type: "ignored";
221
+ command: string;
222
+ }
134
223
  export interface ColorNode {
135
224
  type: "color";
136
225
  value: Expression;
@@ -161,6 +250,8 @@ export interface ExtrudeNode {
161
250
  path?: PathNode;
162
251
  properties: ShapeProperties;
163
252
  children?: SceneNode[];
253
+ /** `along <path>`: sweep the children (as sections) along this path. */
254
+ along?: SceneNode;
164
255
  }
165
256
  export interface LoftNode {
166
257
  type: "loft";
@@ -182,6 +273,12 @@ export interface HullNode {
182
273
  properties: ShapeProperties;
183
274
  children: SceneNode[];
184
275
  }
276
+ /** `minkowski { a b … }`: the Minkowski sum of its children, left to right. */
277
+ export interface MinkowskiNode {
278
+ type: "minkowski";
279
+ properties: ShapeProperties;
280
+ children: SceneNode[];
281
+ }
185
282
  export interface GroupNode {
186
283
  type: "group";
187
284
  children: SceneNode[];
@@ -194,11 +291,29 @@ export interface PathNode {
194
291
  * `loft` section is placed in 3D without a wrapping `fill`. */
195
292
  properties?: ShapeProperties;
196
293
  }
197
- export type PathCommand = DefineNode | PointCommand | CurveCommand | RotateCommand | TranslateCommand | ScaleCommand | DetailPathCommand | ForLoopPathCommand;
294
+ export type PathCommand = DefineNode | PointCommand | CurveCommand | ArcCommand | RotateCommand | TranslateCommand | ScaleCommand | DetailPathCommand | ColorPathCommand | ForLoopPathCommand;
295
+ /** `color …` inside a path or polygon block: the colour of the points that follow. */
296
+ export interface ColorPathCommand {
297
+ type: "color";
298
+ value: Expression;
299
+ }
198
300
  export interface PointCommand {
199
301
  type: "point";
200
302
  x: number | Expression;
201
303
  y: number | Expression;
304
+ /** A third coordinate is accepted for upstream compatibility; paths here are
305
+ * planar, so it must be zero. */
306
+ z?: Expression;
307
+ }
308
+ /** `arc { angle A [position] [orientation] [size] }` inside a path: a circular
309
+ * arc of `angle` half-turns, clockwise from +Y, radius `size / 2` (default
310
+ * 0.5), sampled at the current detail. */
311
+ export interface ArcCommand {
312
+ type: "arc";
313
+ angle?: Expression;
314
+ position?: Expression;
315
+ orientation?: Expression;
316
+ size?: Expression;
202
317
  }
203
318
  /** A quadratic Bézier CONTROL point. The curve passes through the neighbouring
204
319
  * `point`s, not through this one; two `curve`s in a row get an implicit
@@ -207,6 +322,7 @@ export interface CurveCommand {
207
322
  type: "curve";
208
323
  x: number | Expression;
209
324
  y: number | Expression;
325
+ z?: Expression;
210
326
  }
211
327
  export interface RotateCommand {
212
328
  type: "rotate";
@@ -231,14 +347,14 @@ export interface DetailPathCommand {
231
347
  export interface ForLoopPathCommand {
232
348
  type: "for";
233
349
  variable: string;
234
- from: number | Expression;
235
- to: number | Expression;
236
- step?: number | Expression;
350
+ iterable: Expression;
237
351
  commands: PathCommand[];
238
352
  }
239
353
  export declare enum TokenType {
240
354
  CUBE = "CUBE",
241
355
  SPHERE = "SPHERE",
356
+ ICOSPHERE = "ICOSPHERE",
357
+ ROUNDRECT = "ROUNDRECT",
242
358
  CYLINDER = "CYLINDER",
243
359
  CONE = "CONE",
244
360
  TORUS = "TORUS",
@@ -250,14 +366,24 @@ export declare enum TokenType {
250
366
  LATHE = "LATHE",
251
367
  FILL = "FILL",
252
368
  HULL = "HULL",
369
+ MINKOWSKI = "MINKOWSKI",
253
370
  GROUP = "GROUP",
371
+ MESH = "MESH",
254
372
  PATH = "PATH",
255
373
  POINT = "POINT",
256
374
  CURVE = "CURVE",
375
+ ARC = "ARC",
257
376
  DETAIL = "DETAIL",
377
+ SMOOTHING = "SMOOTHING",
258
378
  SEED = "SEED",
259
379
  BACKGROUND = "BACKGROUND",
260
380
  TEXTURE = "TEXTURE",
381
+ MATERIAL = "MATERIAL",
382
+ METALLICITY = "METALLICITY",
383
+ ROUGHNESS = "ROUGHNESS",
384
+ GLOW = "GLOW",
385
+ PRINT = "PRINT",
386
+ ASSERT = "ASSERT",
261
387
  UNION = "UNION",
262
388
  DIFFERENCE = "DIFFERENCE",
263
389
  INTERSECTION = "INTERSECTION",
@@ -285,6 +411,8 @@ export declare enum TokenType {
285
411
  NUMBER = "NUMBER",
286
412
  IDENTIFIER = "IDENTIFIER",
287
413
  STRING = "STRING",
414
+ /** `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA`; the value is the digits. */
415
+ HEXCOLOR = "HEXCOLOR",
288
416
  PLUS = "PLUS",
289
417
  MINUS = "MINUS",
290
418
  STAR = "STAR",