@mulmoclaude/shapescript-plugin 2.0.0 → 2.4.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 (54) hide show
  1. package/README.md +117 -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-BvTjfhU2.js → core-CvNYv5VF.js} +2 -2
  7. package/dist/{core-DZvhTmuk.cjs → core-DmD6zaRF.cjs} +1 -1
  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-BrJ4z8v-.cjs +324 -0
  26. package/dist/{samples-CXhuDdDd.js → samples-y59fsGq8.js} +281 -276
  27. package/dist/shapescript/builders.d.ts +17 -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 +81 -2
  36. package/dist/shapescript/parser.d.ts.map +1 -1
  37. package/dist/shapescript/text.d.ts +29 -0
  38. package/dist/shapescript/text.d.ts.map +1 -0
  39. package/dist/shapescript/toThreeJS.d.ts +159 -9
  40. package/dist/shapescript/toThreeJS.d.ts.map +1 -1
  41. package/dist/shapescript/types.d.ts +160 -17
  42. package/dist/shapescript/types.d.ts.map +1 -1
  43. package/dist/style.css +1 -1
  44. package/dist/toThreeJS-CaZGJjfO.cjs +24 -0
  45. package/dist/{toThreeJS-FsP-Na75.js → toThreeJS-OGEAi4zV.js} +6136 -3781
  46. package/dist/vue/Preview.vue.d.ts.map +1 -1
  47. package/dist/vue/View.vue.d.ts.map +1 -1
  48. package/dist/vue/index.d.ts +1 -1
  49. package/dist/vue/index.d.ts.map +1 -1
  50. package/dist/vue.cjs +37 -25
  51. package/dist/vue.js +1534 -1493
  52. package/package.json +1 -1
  53. package/dist/samples-DGD0Kjwg.cjs +0 -276
  54. package/dist/toThreeJS-MvllBF9e.cjs +0 -10
@@ -1,7 +1,22 @@
1
1
  import * as THREE from "three";
2
2
  /** Read an ordered perimeter from a triangulated planar profile. Interior
3
3
  * vertices (e.g. the centre of CircleGeometry) must never enter a loft ring. */
4
+ /** Every boundary loop of a mesh — the edges used by exactly one triangle,
5
+ * chained into closed rings — in world space. A flat face has one; a face
6
+ * with holes (a filled letter) has one per hole as well. */
7
+ export declare function boundaryLoops(mesh: THREE.Mesh): THREE.Vector3[][];
8
+ /** The single perimeter of a flat mesh, for builders that take one ring. */
4
9
  export declare function profileOf(mesh: THREE.Mesh): THREE.Vector3[];
5
- /** Straight interpolation between successive rings, with triangulated end caps. */
6
- export declare function loftGeometry(profiles: THREE.Vector3[][]): THREE.BufferGeometry;
10
+ /** Straight interpolation between successive rings, with triangulated end
11
+ * caps or, for a `closed` chain (a section swept around a loop), the last
12
+ * ring joined back to the first and no caps at all. */
13
+ export declare function loftGeometry(profiles: THREE.Vector3[][], closed?: boolean): THREE.BufferGeometry;
14
+ /** A section ring (in the XY plane, its normal +Z) placed at every point of a
15
+ * path, the way `extrude … along` sweeps it: +Z turns to the path tangent
16
+ * (mitred at corners, and the ring widened there so the walls meet), +Y to
17
+ * the path's plane normal. A `closed` path wraps the first corner too. */
18
+ export declare function sweepRings(section: THREE.Vector3[], path: THREE.Vector3[], closed: boolean): THREE.Vector3[][];
19
+ /** An OPEN path extruded: a wall of `depth` along the path with no caps, faced
20
+ * both ways as upstream draws an open surface. */
21
+ export declare function ribbonGeometry(points: THREE.Vector3[], depth: number): THREE.BufferGeometry;
7
22
  //# sourceMappingURL=builders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../src/shapescript/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;gFACgF;AAChF,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAiD3D;AA0CD,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,cAAc,CAoE9E"}
1
+ {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../src/shapescript/builders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;gFACgF;AAChF;;6DAE6D;AAC7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,CAuDjE;AAED,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAI3D;AA0CD;;wDAEwD;AACxD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAQ,GAAG,KAAK,CAAC,cAAc,CAqE9F;AAED;;;2EAG2E;AAC3E,wBAAgB,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,CAwB9G;AAgBD;mDACmD;AACnD,wBAAgB,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CA2B3F"}
@@ -1,5 +1,46 @@
1
- import { Expression, Vector3, Color } from "./types";
2
- export type Value = number | boolean | string | Value[];
1
+ import { Expression, Vector3, Color, DefineNode, SceneNode } from "./types";
2
+ import { type MeshValue, type PolygonValue, type BoundsValue, type PointValue } from "./meshValues";
3
+ import type * as THREE from "three";
4
+ export type { MeshValue, PolygonValue, BoundsValue, PointValue } from "./meshValues";
5
+ /** `1 to 5 step 2` as a value: walked by `for`, tested by `in`. */
6
+ export interface RangeValue {
7
+ kind: "range";
8
+ from: number;
9
+ to: number;
10
+ step: number;
11
+ /** Whether a `step` was written: `in` then tests only the stepped values,
12
+ * while an unstepped range contains every number between its bounds. */
13
+ stepped: boolean;
14
+ }
15
+ /** A `define name(a b) { … }` function, kept as its definition node. */
16
+ export interface FunctionValue {
17
+ kind: "function";
18
+ definition: DefineNode;
19
+ }
20
+ /** An evaluated `material { … }` block. Colours carry alpha; a texture is
21
+ * kept only so the renderer can warn about it. */
22
+ export interface MaterialValue {
23
+ kind: "material";
24
+ color?: RGBA;
25
+ opacity?: number;
26
+ metallicity?: number;
27
+ roughness?: number;
28
+ glow?: RGBA;
29
+ texture?: string;
30
+ }
31
+ export type RGBA = [number, number, number, number];
32
+ export type ObjectValue = RangeValue | FunctionValue | MaterialValue | MeshValue | PolygonValue | BoundsValue | PointValue;
33
+ export type Value = number | boolean | string | Value[] | ObjectValue;
34
+ export declare const isObjectValue: (value: Value | undefined) => value is ObjectValue;
35
+ /** What the evaluator needs from the converter: shapes as values are built
36
+ * there, and a function whose body builds shapes runs there. */
37
+ export interface EvaluatorHooks {
38
+ shape(node: SceneNode): Value;
39
+ call(fn: FunctionValue, args: Value[]): Value;
40
+ /** A geometry a builtin allocated that stays alive as a value: charged
41
+ * against the vertex budget by the converter, or refused. */
42
+ retain(geometry: THREE.BufferGeometry): void;
43
+ }
3
44
  /** Upstream's `rnd` generator, bit for bit: a 32-bit LCG kept in a double,
4
45
  * `x = (x * 1664525 + 1013904223) mod 2^32`, returning `x / 2^32`. Matching
5
46
  * it means `seed 57` scatters shapes exactly as it does in the upstream app.
@@ -27,6 +68,12 @@ export declare class SymbolTable {
27
68
  get(name: string): Value | undefined;
28
69
  has(name: string): boolean;
29
70
  }
71
+ /** Every built-in a bare call may name (`max 0 1`). */
72
+ export declare const BUILT_IN_FUNCTION_NAMES: readonly string[];
73
+ export declare function valuesEqual(a: Value, b: Value): boolean;
74
+ /** The values a `for` loop visits: a range walked by its step, a tuple's
75
+ * elements, or a lone value. The count is bounded by the caller. */
76
+ export declare function iterationValues(iterable: Value, limit: number, exceeded: () => Error): Value[];
30
77
  /** Seeds the generator behind `rnd` / `rand()` when a caller names none.
31
78
  *
32
79
  * The same script is evaluated TWICE for one visualization — once on the
@@ -42,15 +89,42 @@ export declare class SymbolTable {
42
89
  export declare const DEFAULT_RANDOM_SEED = 0;
43
90
  export declare class Evaluator {
44
91
  private symbols;
92
+ private callDepth;
93
+ /** Set by the converter, which owns geometry. */
94
+ hooks: EvaluatorHooks | undefined;
95
+ /** The same per-loop ceiling the converter applies to `for` statements. */
96
+ maxLoopIterations: number;
45
97
  constructor(symbols?: SymbolTable, seed?: number);
46
98
  private random;
47
99
  /** The `seed` command. Scoped: see `SymbolTable.reseed`. */
48
100
  reseed(seed: number): void;
49
101
  getSymbols(): SymbolTable;
50
102
  evaluate(expr: Expression | number | string | Vector3 | Color): Value;
103
+ /** `from to to [step]`, or `range step s` when `to` is absent. */
104
+ private evaluateRange;
105
+ private evaluateMaterial;
106
+ /** `inset(mesh distance)`: a new mesh value with the faces moved inward.
107
+ * Its geometry is a fresh allocation that lives on as a value, so it is
108
+ * charged the way a defined shape is. */
109
+ private inset;
110
+ /** Bind the parameters in a fresh scope, run the body's `define`s, and
111
+ * evaluate the result expression. */
112
+ private callFunction;
113
+ /** Bind parameters in a fresh scope around `run`. Public so the converter
114
+ * can run a shape-building function body under the same binding. */
115
+ withArguments<T>(params: readonly string[], args: readonly Value[], run: () => T): T;
116
+ /** A `define` of a value or a function. Custom shape blocks are stored by
117
+ * the converter, which owns their bodies. */
118
+ define(node: DefineNode): boolean;
51
119
  evaluateToNumber(expr: Expression | number): number;
52
120
  evaluateToBoolean(expr: Expression): boolean;
53
121
  evaluateToVector3(expr: Expression | Vector3): Vector3;
54
122
  evaluateToColor(expr: Expression | Color): Color;
123
+ /** A colour value with alpha, by upstream's count rules: one number is a
124
+ * luminance, two are luminance and alpha, three RGB, four RGBA; and a colour
125
+ * followed by a number (`red 0.5`, `#ff0 0.5`) is that colour with its
126
+ * alpha replaced. */
127
+ evaluateToRGBA(expr: Expression | Color): RGBA;
55
128
  }
129
+ export declare function rgbaOf(value: Value): RGBA;
56
130
  //# sourceMappingURL=evaluator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/shapescript/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC;AAExD;;;;;wDAKwD;AACxD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAc;IAC7C,OAAO,CAAC,KAAK,CAAS;gBAEV,IAAI,EAAE,MAAM;IAIxB,OAAO,CAAC,MAAM,CAAC,IAAI;IAKnB,IAAI,IAAI,MAAM;CAIf;AAOD,q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AM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAyBzC"}
@@ -0,0 +1,54 @@
1
+ import * as THREE from "three";
2
+ import type { RGBA } from "./evaluator";
3
+ /** The value types that hold geometry, shared by the evaluator (members) and
4
+ * the converter (building and placing them). */
5
+ export type Point3 = [number, number, number];
6
+ /** A `polygon { point … }`, or one face of a mesh value. */
7
+ export interface PolygonValue {
8
+ kind: "polygon";
9
+ points: Point3[];
10
+ /** Per-vertex colours when the polygon block set `color`; one per point. */
11
+ colors?: RGBA[];
12
+ }
13
+ /** A shape used as a value. The geometry is in the shape's own frame, with
14
+ * the transform it was declared with already applied. */
15
+ export interface MeshValue {
16
+ kind: "mesh";
17
+ geometry: THREE.BufferGeometry;
18
+ /** Kept when the mesh was built from polygons, so `.polygons` returns them
19
+ * in the order the script (or Euclid) produced them. */
20
+ polygons?: PolygonValue[];
21
+ name?: string;
22
+ }
23
+ /** `shape.bounds` / `polygon.bounds`. */
24
+ export interface BoundsValue {
25
+ kind: "bounds";
26
+ min: Point3;
27
+ max: Point3;
28
+ }
29
+ /** A vertex of a polygon, from `polygon.points`. */
30
+ export interface PointValue {
31
+ kind: "point";
32
+ position: Point3;
33
+ color?: RGBA;
34
+ }
35
+ export declare function boundsOf(points: readonly Point3[]): BoundsValue;
36
+ export declare function centerOf(points: readonly Point3[]): Point3;
37
+ /** Every triangle of a geometry as a polygon, in buffer order. */
38
+ export declare function trianglesOf(geometry: THREE.BufferGeometry): PolygonValue[];
39
+ export declare function meshPolygons(mesh: MeshValue): PolygonValue[];
40
+ export declare function meshPoints(mesh: MeshValue): Point3[];
41
+ /** Signed volume of a closed triangle mesh. */
42
+ export declare function meshVolume(mesh: MeshValue): number;
43
+ /** Triangulate a planar polygon (convex or not) into index triples. */
44
+ export declare function triangulatePolygon(points: readonly Point3[]): [number, number, number][];
45
+ /** Euclid's icosahedron, vertex for vertex and face for face, so that
46
+ * `icosphere.polygons` indexes the same way upstream's scripts expect. */
47
+ export declare function icosphereGeometry(radius: number, subdivisions: number): {
48
+ geometry: THREE.BufferGeometry;
49
+ polygons: PolygonValue[];
50
+ };
51
+ /** A flat-shaded, non-indexed geometry from polygons, with per-vertex
52
+ * colours when any polygon carries them. */
53
+ export declare function geometryFromPolygons(polygons: readonly PolygonValue[], withColors: boolean): THREE.BufferGeometry;
54
+ //# sourceMappingURL=meshValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meshValues.d.ts","sourceRoot":"","sources":["../../src/shapescript/meshValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC;iDACiD;AAEjD,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;CACjB;AAED;0DAC0D;AAC1D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC;IAC/B;6DACyD;IACzD,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CAU/D;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAS1D;AAED,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,GAAG,YAAY,EAAE,CAa1E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,EAAE,CAE5D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,CAKpD;AAED,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAYlD;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAsBxF;AAED;2EAC2E;AAC3E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,CA+DpI;AAED;6CAC6C;AAC7C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,KAAK,CAAC,cAAc,CAsBjH"}
@@ -0,0 +1,37 @@
1
+ import * as THREE from "three";
2
+ /** The most faces a non-convex operand may contribute pieces for. */
3
+ export declare const MAX_MINKOWSKI_PIECES = 2048;
4
+ /** The most points one hull may be built from. */
5
+ export declare const MAX_HULL_POINTS = 400000;
6
+ /** The distinct vertex positions of a geometry, in world space. */
7
+ export declare function uniquePoints(geometry: THREE.BufferGeometry, matrix: THREE.Matrix4): THREE.Vector3[];
8
+ /** The triangles of a geometry as world-space corner triples. */
9
+ export declare function worldTriangles(geometry: THREE.BufferGeometry, matrix: THREE.Matrix4): THREE.Vector3[][];
10
+ /** +1 when the triangles wind outward, −1 when a mirroring `size` or `scale`
11
+ * turned them inside out — the sign of the enclosed volume. */
12
+ export declare function windingSign(triangles: readonly THREE.Vector3[][]): number;
13
+ /** Whether every vertex lies on or behind every face plane: a convex solid,
14
+ * however its faces wind, whose Minkowski sum with another convex solid is
15
+ * the hull of their pairwise vertex sums. */
16
+ export declare function isConvex(triangles: readonly THREE.Vector3[][], points: readonly THREE.Vector3[]): boolean;
17
+ /** The convex hull of `points`. A whole sum (`smooth`) is the rounded solid
18
+ * itself, so shared vertices average their face normals. A per-face PIECE
19
+ * keeps flat normals: its rounded sides are interior once the pieces overlap,
20
+ * and averaging them into its flat top tilted that face's border — a visible
21
+ * bump along every seam of a flat face. Coplanar points (two parallel faces
22
+ * summed) give a flat sliver rather than a throw from `ConvexGeometry`; that
23
+ * is `undefined` here. */
24
+ export declare function hullGeometry(points: THREE.Vector3[], smooth: boolean): THREE.BufferGeometry | undefined;
25
+ export interface MinkowskiOperand {
26
+ geometry: THREE.BufferGeometry;
27
+ matrix: THREE.Matrix4;
28
+ }
29
+ /** `a ⊕ b`. Two convex solids sum to one hull; when one is not convex, every
30
+ * face of it is summed with the other on its own and the pieces are merged
31
+ * (their union), as upstream decomposes it. */
32
+ export declare function minkowskiSum(a: MinkowskiOperand, b: MinkowskiOperand): THREE.BufferGeometry;
33
+ /** Every face moved inward by `distance` (outward when negative): each vertex
34
+ * slides to where its faces' offset planes meet — exact at any corner where
35
+ * the planes are consistent, least-squares where more than three meet. */
36
+ export declare function insetGeometry(geometry: THREE.BufferGeometry, distance: number): THREE.BufferGeometry;
37
+ //# sourceMappingURL=minkowski.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minkowski.d.ts","sourceRoot":"","sources":["../../src/shapescript/minkowski.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,kDAAkD;AAClD,eAAO,MAAM,eAAe,SAAU,CAAC;AAIvC,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAYnG;AAED,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,EAAE,CASvG;AAED;gEACgE;AAChE,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,MAAM,CAIzE;AAED;;8CAE8C;AAC9C,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,KAAK,CAAC,OAAO,EAAE,GAAG,OAAO,CAYzG;AAED;;;;;;2BAM2B;AAC3B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,CAAC,cAAc,GAAG,SAAS,CAcvG;AAoBD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,KAAK,CAAC,cAAc,CAAC;IAC/B,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC;CACvB;AAED;;gDAEgD;AAChD,wBAAgB,YAAY,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC,cAAc,CA+B3F;AASD;;2EAE2E;AAC3E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,cAAc,CA+BpG"}
@@ -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;
@@ -33,20 +59,69 @@ export declare class Parser {
33
59
  * and `wheel { … }` a custom shape invocation that belongs to no list. */
34
60
  private parseValueList;
35
61
  private parseProperties;
62
+ /** One property statement into `properties`; false when the current token
63
+ * does not begin one (the caller decides what it is instead). */
64
+ private parseProperty;
36
65
  private parseBlockContents;
66
+ /** Run `parse` with the callable and block name sets scoped to it, so a
67
+ * `define max 5` inside a block stops shadowing the built-in at the
68
+ * block's closing brace — the parser-side mirror of the runtime scope. */
69
+ private scoped;
37
70
  private parseBlock;
38
71
  private parseShape;
39
72
  private parseCSG;
73
+ /** `for [name in] <range or tuple> { … }`. The range is an ordinary
74
+ * expression (`1 to n step 2`, or a symbol holding one), so `for 1 to 5`
75
+ * and `for i in loops` read the same way. */
40
76
  private parseForLoop;
77
+ /** A keyword that a binding in scope has claimed as a value — a shape,
78
+ * builder or control-flow word used as a parameter or loop variable.
79
+ * Property and transform commands (`size`, `color`, `scale`, …) are not
80
+ * included: `define size 1 2` must not turn a later `size` command into a
81
+ * value, and inside a block they are read as properties anyway. */
82
+ private isBoundKeyword;
83
+ /** A name bound in the current scope — loop variable, parameter, option —
84
+ * is a value there: not a callable, and not the shape it may spell. */
85
+ private bindName;
86
+ private parseLoopHeader;
41
87
  private parseIf;
42
88
  private parseSwitch;
43
89
  private parseDefine;
90
+ /** An upstream command this renderer lacks, named instead of failing on
91
+ * the brace that follows it. */
92
+ private refuseUnsupported;
93
+ /** Whether `token` opens a statement rather than an expression — used where
94
+ * either may appear, such as a function body. */
95
+ private startsStatement;
96
+ /** The body holds statements — `define`s, and shapes the function builds —
97
+ * and may end in the expression it returns. A function with no result
98
+ * expression returns what its statements built. */
99
+ private parseFunctionDefine;
44
100
  private parseDetail;
45
101
  private parseSeed;
46
102
  private parseBackground;
47
- private parseTexture;
103
+ /** `opacity` / `metallicity` / `roughness` / `glow` / `texture` / `material`
104
+ * as a scoped command. */
105
+ private parseMaterialCommand;
106
+ /** `camera { … }` / `light { … }`: the block is consumed and dropped. */
107
+ private skipIgnoredBlock;
108
+ /** `font "Name"`: consumed and dropped, as the built-in face is the only one. */
109
+ private isFontCommand;
110
+ private skipFont;
111
+ /** `text "Hello"` / `text i " apples"`, or a block of lines with options:
112
+ * `text { size 0.5; wrapwidth 3; "Hello,"; "World!" }`. */
113
+ private parseText;
114
+ /** One line of a `text` block: an option, a property, or a line of text. */
115
+ private parseTextLine;
116
+ /** An option of the text block, unless a binding of that exact spelling
117
+ * claims it — options are lowercase, like `along`, and symbols are
118
+ * case-sensitive (`define WrapWidth "W"` then `text { WrapWidth }`). */
119
+ private textOption;
48
120
  private parseGroup;
49
121
  private parseBuilder;
122
+ private isAlongOption;
123
+ /** `along <path or shape>` inside `extrude { … }`: the path the sections are swept along. */
124
+ private parseAlong;
50
125
  /** Run `parse` with the tuple-value break of `isStartOfNewValue` enabled or
51
126
  * suppressed. Whitespace-separated value lists — property values, path
52
127
  * values, the inside of a `( … )` — read ` -1` as the NEXT value; call
@@ -74,12 +149,16 @@ export declare class Parser {
74
149
  /** `point x [y]` / `curve x [y]` — absolute coordinates in the path's local
75
150
  * frame, as upstream. Y defaults to 0. */
76
151
  private parsePathPoint;
152
+ /** `arc` or `arc { angle … position … orientation … size … }` inside a path. */
153
+ private parseArc;
77
154
  /** `translate x [y]` / `scale x [y]` inside a path. A lone `translate x`
78
155
  * moves along X only; a lone `scale s` is uniform, recorded by leaving `y`
79
156
  * out rather than by copying the expression (which would evaluate it twice). */
80
157
  private parsePathVector;
81
158
  private parsePathFor;
82
159
  private parseNode;
160
+ /** `name { option value … }` after the name has been consumed. */
161
+ private parseCustomShapeCall;
83
162
  private refuseStalledToken;
84
163
  parse(): SceneNode[];
85
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shapescript/parser.ts"],"names":[],"mappings":"AAAA,OAAO,E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EAA4E;IAC5E,OAAO,CAAC,aAAa;IAwBrB;;6EAEyE;IACzE,OAAO,CAAC,UAAU;IAOlB,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;IA0KjB,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"}
@@ -0,0 +1,29 @@
1
+ import * as THREE from "three";
2
+ /** Characters per `text`, bounding the layout work before the vertex budget applies. */
3
+ export declare const MAX_TEXT_LENGTH = 2000;
4
+ export interface TextLayoutOptions {
5
+ wrapWidth?: number;
6
+ lineSpacing: number;
7
+ /** Segments per outline curve. */
8
+ curveSegments: number;
9
+ }
10
+ export interface TextLayout {
11
+ /** Filled glyphs, with their holes. */
12
+ shapes: THREE.Shape[];
13
+ /** Every outline ring, for drawing the text as strokes. */
14
+ rings: THREE.Vector2[][];
15
+ /** Characters the bundled face lacks, drawn as `?`. */
16
+ missing: string[];
17
+ }
18
+ /** Group closed rings into shapes: a ring inside an odd number of others is a
19
+ * hole of the innermost ring around it, any other ring is an outline. The
20
+ * rings' winding does not matter; the geometry classes normalise it. */
21
+ export declare function shapesFromRings(rings: readonly THREE.Vector2[][]): THREE.Shape[];
22
+ /** Lay `text` out from the origin: left margin at x = 0, first baseline at
23
+ * y = 0, later lines below it. */
24
+ export declare function layoutText(text: string, options: TextLayoutOptions): TextLayout;
25
+ /** The text of a `text` line: strings concatenate as written, other values
26
+ * print with a space between two of them (`text 1 2` is "1 2", `text 1 "" 2`
27
+ * is "12"), as upstream interpolates. */
28
+ export declare function interpolate(values: readonly unknown[], print: (value: unknown) => string): string;
29
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/shapescript/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4B/B,wFAAwF;AACxF,eAAO,MAAM,eAAe,OAAO,CAAC;AAGpC,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACzB,uDAAuD;IACvD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AA4DD;;yEAEyE;AACzE,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAchF;AAiCD;mCACmC;AACnC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAuB/E;AAED;;0CAE0C;AAC1C,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,CAcjG"}