@mulmoclaude/shapescript-plugin 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -14
- package/dist/core/definition.d.ts.map +1 -1
- package/dist/{core-CpVzK-0i.js → core-BvTjfhU2.js} +2 -2
- package/dist/{core-bcFgqR_m.cjs → core-DZvhTmuk.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/render.cjs +1 -1
- package/dist/render.js +1 -1
- package/dist/{samples-DPOGWslc.js → samples-CXhuDdDd.js} +2 -2
- package/dist/{samples-DZNAeuSZ.cjs → samples-DGD0Kjwg.cjs} +86 -20
- package/dist/shapescript/evaluator.d.ts +27 -4
- package/dist/shapescript/evaluator.d.ts.map +1 -1
- package/dist/shapescript/parser.d.ts +18 -0
- package/dist/shapescript/parser.d.ts.map +1 -1
- package/dist/shapescript/toThreeJS.d.ts +42 -2
- package/dist/shapescript/toThreeJS.d.ts.map +1 -1
- package/dist/shapescript/types.d.ts +22 -4
- package/dist/shapescript/types.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/{toThreeJS-BX_aeGdA.js → toThreeJS-FsP-Na75.js} +341 -284
- package/dist/toThreeJS-MvllBF9e.cjs +10 -0
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue.cjs +26 -7
- package/dist/vue.js +26 -7
- package/package.json +1 -1
- package/dist/toThreeJS-XGDoVISb.cjs +0 -10
package/README.md
CHANGED
|
@@ -61,15 +61,21 @@ USDZ units are metres, so `size 1` is one metre in AR.
|
|
|
61
61
|
## ShapeScript language
|
|
62
62
|
|
|
63
63
|
- **Primitives**: `cube`, `sphere`, `cylinder`, `cone`, `torus`, `circle`, `square`, `polygon`
|
|
64
|
-
- **Properties**: `position X Y Z`, `
|
|
64
|
+
- **Properties**: `position X Y Z`, `orientation ROLL YAW PITCH` (alias `rotation`), `size X Y Z`, `color R G B` (0–1), `opacity`
|
|
65
65
|
- **CSG**: `union`, `difference`, `intersection`, `xor`, `stencil`
|
|
66
66
|
- **Builders**: `extrude`, `loft`, `lathe`, `fill`, `hull`
|
|
67
67
|
- **Variables & expressions**: `define`, arithmetic / comparison / boolean operators, parentheses
|
|
68
68
|
- **Control flow**: `for … in … to … step`, `if` / `else`, `switch` / `case`
|
|
69
69
|
- **Built-ins**: `round floor ceil abs sign sqrt pow min max`, `sin cos tan asin acos atan atan2`
|
|
70
|
-
(radians), `dot cross length normalize sum`
|
|
70
|
+
(radians), `dot cross length normalize sum`, `rnd`
|
|
71
|
+
- **Commands**: `detail N`, `seed N` (both scoped to the enclosing block), `color`, and the relative
|
|
72
|
+
`rotate` / `translate` / `scale`
|
|
71
73
|
|
|
72
74
|
A function call takes **no space** before its parenthesis: `sin(x)` is a call, `sin (x)` is not.
|
|
75
|
+
Arguments are a value list, so upstream's `max(0 (j - 1))` and `max(0, j - 1)` both work; write the
|
|
76
|
+
space-separated form when a script also has to open in the upstream app. Upstream's bare
|
|
77
|
+
`max 0 (j - 1)` (no parentheses) is not supported. This parser also accepts several statements on
|
|
78
|
+
one line (`define a 1 define b 2`); upstream requires one per line, so portable scripts keep to that.
|
|
73
79
|
|
|
74
80
|
## Storage
|
|
75
81
|
|
|
@@ -125,33 +131,77 @@ hull {
|
|
|
125
131
|
}
|
|
126
132
|
extrude { polygon { sides 5 } }
|
|
127
133
|
fill { square }
|
|
128
|
-
lathe path {
|
|
134
|
+
lathe path {
|
|
135
|
+
point 0 0
|
|
136
|
+
point 1 0
|
|
137
|
+
curve 1.5 1
|
|
138
|
+
point 1 2
|
|
139
|
+
point 0 2
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Paths: absolute points, Bézier control points, a frame moved by rotate/translate/scale.
|
|
143
|
+
extrude path {
|
|
144
|
+
point 0 0
|
|
145
|
+
point 1 0
|
|
146
|
+
point 1 1
|
|
147
|
+
point 0 1
|
|
148
|
+
point 0 0
|
|
149
|
+
}
|
|
150
|
+
fill path {
|
|
151
|
+
for 0 to 8 {
|
|
152
|
+
curve 0 1
|
|
153
|
+
rotate 1 / 8
|
|
154
|
+
}
|
|
155
|
+
}
|
|
129
156
|
|
|
130
157
|
// Stencil changes surface material without cutting away the first shape.
|
|
131
158
|
stencil {
|
|
132
159
|
cube { color 1 0 0 }
|
|
133
|
-
cube {
|
|
160
|
+
cube {
|
|
161
|
+
position 0.5 0 0
|
|
162
|
+
color 0 1 0
|
|
163
|
+
}
|
|
134
164
|
}
|
|
135
165
|
|
|
136
166
|
define offsets ((1 2 3), (4 5 6))
|
|
137
167
|
cube { position offsets[0].x offsets[1].y offsets.count }
|
|
138
168
|
```
|
|
139
169
|
|
|
140
|
-
Also supported: `pi`, `tau`, `true`, `false`, scientific notation, unary `+`,
|
|
170
|
+
Also supported: `pi`, `tau` (plugin-only; upstream has no `tau`, so portable scripts write `2 * pi`), `true`, `false`, scientific notation, unary `+`,
|
|
141
171
|
short-circuit `and`/`or`, string literals, `join`/`trim`, tuple arguments to `min`/`max`,
|
|
142
|
-
zero-based tuple/string subscripts, `.count`,
|
|
172
|
+
zero-based tuple/string subscripts, `.count`, ordinal members `.first` … `.tenth`, `.last`,
|
|
173
|
+
`.allButFirst`, `.allButLast`, vector `.x/.y/.z/.w`, color
|
|
143
174
|
`.red/.green/.blue/.alpha` (or `.r/.g/.b/.a`), custom shape definitions with options,
|
|
144
175
|
and `polygon { sides N }` (integer 3–256). Lathe samples curved profiles, and inline
|
|
145
176
|
builder paths use the same parser as nested paths, including loops and definitions.
|
|
146
177
|
|
|
178
|
+
## Units and path semantics — same as upstream
|
|
179
|
+
|
|
180
|
+
Since 2.0.0 the plugin follows the [upstream ShapeScript](https://shapescript.info/mac/)
|
|
181
|
+
conventions, so a script written against the upstream docs renders the same here:
|
|
182
|
+
|
|
183
|
+
- `size` is the **diameter** of `sphere`, `cylinder`, `cone`, `circle`, `polygon` and `torus`
|
|
184
|
+
(a bare `sphere` fits the unit cube) and the edge length of `cube` / `square`.
|
|
185
|
+
- `orientation` (alias `rotation`) and `rotate` take **half-turns** as `roll yaw pitch` —
|
|
186
|
+
rotations about Z, Y and X applied in that order, `0.5` = 90°, positive clockwise (Euclid's
|
|
187
|
+
sign). A lone value is a roll; four values are `angle x y z`. Trig *functions* still use radians.
|
|
188
|
+
- Path `point` / `curve` coordinates are **absolute** in the path's frame; `rotate`, `translate`
|
|
189
|
+
and `scale` inside a path move that frame for later points. `curve` is a quadratic Bézier
|
|
190
|
+
**control point** — the outline passes through the neighbouring `point`s, and two `curve`s in
|
|
191
|
+
a row get an implicit on-curve midpoint (eight in an octagon draw a circle). A path block may
|
|
192
|
+
carry `position` / `orientation` / `size` of its own, which is how a `loft` section is placed in
|
|
193
|
+
3D; `lathe` refuses a placed profile.
|
|
194
|
+
- `rnd` uses upstream's generator (`x = x · 1664525 + 1013904223 mod 2³²`, seed 0) and `seed N`
|
|
195
|
+
reseeds it for the enclosing block only.
|
|
196
|
+
|
|
197
|
+
Deviations that remain: an *open* path whose first or last point is a `curve` treats it as a
|
|
198
|
+
corner (upstream extrapolates a tangent), and path points are 2D. The gap list lives in
|
|
199
|
+
[`plans/feat-shapescript-upstream-parity.md`](../../../plans/feat-shapescript-upstream-parity.md).
|
|
200
|
+
|
|
147
201
|
## Compatibility and limits
|
|
148
202
|
|
|
149
203
|
This is the plugin's documented modeling subset, **not complete compatibility with
|
|
150
|
-
|
|
151
|
-
conventions: primitive sphere/circle sizes specify radii; rotation/orientation properties
|
|
152
|
-
and trig functions use radians; relative rotate/orientation commands and path rotation
|
|
153
|
-
use turns (`1 = 360°`). Path point/curve coordinates are relative steps, and curve
|
|
154
|
-
control coordinates are offsets from the endpoint. Upstream uses different conventions.
|
|
204
|
+
upstream ShapeScript**.
|
|
155
205
|
|
|
156
206
|
Loft accepts ordered, closed planar sections with one perimeter each, resamples differing
|
|
157
207
|
vertex counts, interpolates linearly, and triangulates the end caps. Sections must enclose
|
|
@@ -164,9 +214,10 @@ substituting different geometry. As with other polygonal CSG engines, degenerate
|
|
|
164
214
|
self-intersecting inputs may fail.
|
|
165
215
|
|
|
166
216
|
`rnd` and `rand()` draw from a seeded generator (`randomSeed`, default
|
|
167
|
-
`DEFAULT_RANDOM_SEED`) rather than `Math.random()`:
|
|
168
|
-
on the server, which validates it, and again in the
|
|
169
|
-
unseeded generator lets those two runs take different
|
|
217
|
+
`DEFAULT_RANDOM_SEED` = 0, overridable in-script with `seed`) rather than `Math.random()`:
|
|
218
|
+
one script is evaluated twice — once on the server, which validates it, and again in the
|
|
219
|
+
browser, which renders it — and an unseeded generator lets those two runs take different
|
|
220
|
+
branches.
|
|
170
221
|
|
|
171
222
|
Conversion limits cover nodes (100,000), loop/path work (100,000 iterations), detail (3–256),
|
|
172
223
|
aggregate vertices (5,000,000, including CSG intermediates), and a coarse 30-second wall-clock
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/core/definition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC;AAE9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/core/definition.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,uBAAuB,CAAC;AAE9C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;CA8O3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as e, a as t, u as n } from "./samples-
|
|
2
|
-
import { t as r } from "./toThreeJS-
|
|
1
|
+
import { _ as e, a as t, u as n } from "./samples-CXhuDdDd.js";
|
|
2
|
+
import { t as r } from "./toThreeJS-FsP-Na75.js";
|
|
3
3
|
//#region src/export/tool.ts
|
|
4
4
|
var i = "exportShapeScriptUsdz", a = r + 3e4, o = "Export a ShapeScript model to a USDZ file (Apple's AR / 3D format, openable with AR Quick Look on iPhone, iPad and Mac) and save it under artifacts/shapes/. Returns the saved path. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file. USDZ units are metres, so a `size 1` cube becomes a one-metre object in AR — scale the model in the script if that is not what the user wants.", s = "Use exportShapeScriptUsdz when the user wants to take a 3D model out of the chat — to view it in AR, open it in a 3D app, or share the file. It saves a .usdz next to the model's .shape file and returns the path; tell the user where it is. The user can also press \"Download USDZ\" in the model's view themselves.", c = {
|
|
5
5
|
type: "object",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./samples-
|
|
1
|
+
const e=require("./samples-DGD0Kjwg.cjs"),t=require("./toThreeJS-MvllBF9e.cjs");var n=`exportShapeScriptUsdz`,r=t.t+3e4,i="Export a ShapeScript model to a USDZ file (Apple's AR / 3D format, openable with AR Quick Look on iPhone, iPad and Mac) and save it under artifacts/shapes/. Returns the saved path. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file. USDZ units are metres, so a `size 1` cube becomes a one-metre object in AR — scale the model in the script if that is not what the user wants.",a=`Use exportShapeScriptUsdz when the user wants to take a 3D model out of the chat — to view it in AR, open it in a 3D app, or share the file. It saves a .usdz next to the model's .shape file and returns the path; tell the user where it is. The user can also press "Download USDZ" in the model's view themselves.`,o={type:`object`,properties:{script:{type:`string`,description:"ShapeScript source to export. Provide either this or `path`, not both."},path:{type:`string`,description:`Path to an existing .shape file to export (e.g. one presentShapeScript saved under artifacts/shapes/).`},title:{type:`string`,description:"Name for the exported file; it is slugified into the filename. Defaults to the .shape file's own name when `path` is given."}},required:[]};function s(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function c(e){return(e.split(/[\\/]/).pop()??e).replace(/\.shape$/i,``)}async function l(t,n){let r=s(n.script),i=s(n.path),a=s(n.title);if(r&&i)throw Error("Provide either `script` or `path`, not both");if(r)return{script:r,title:a};if(!i)throw Error("Provide either `script` (inline source) or `path` (an existing .shape file)");let o=e.u(t,i);if(!o)throw Error("`path` must name a .shape file, without `.` / `..` segments");if(!await o.files.exists(o.rel))throw Error(`No ShapeScript exists at ${i}`);return{script:await o.files.read(o.rel),title:a??c(i)}}async function u(t,n){let{script:r,title:i}=await l(t,n),a=await e.a(r),{relPath:o,filePath:s}=e._(i);return await t.files.artifacts.write(o,a),{message:`Saved USDZ to ${s} (${a.byteLength} bytes). Open it with AR Quick Look or any USD viewer.`,filePath:s,bytes:a.byteLength}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-DGD0Kjwg.cjs"),t=require("./toThreeJS-MvllBF9e.cjs"),n=require("./core-DZvhTmuk.cjs");exports.EXPORT_USDZ_DESCRIPTION=n.t,exports.EXPORT_USDZ_PROMPT=n.n,exports.EXPORT_USDZ_SCHEMA=n.r,exports.EXPORT_USDZ_TOOL_NAME=n.i,exports.EXPORT_USDZ_TOOL_TIMEOUT_MS=n.a,exports.SHAPE_EXTENSIONS=e.d,exports.TOOL_DEFINITION=e.v,exports.TOOL_NAME=e.y,exports.USDZ_EXTENSION=e.n,exports.USDZ_MIME_TYPE=e.r,exports.astToThreeJS=t.r,exports.executeExportShapeScriptUsdz=n.o,exports.executePresentShapeScript=e.o,exports.executeShapeScriptDispatch=e.l,exports.isPresentableShapePath=e.f,exports.isShapeArtifactPath=e.p,exports.isShapeScriptDispatchArgs=t.zn,exports.locateShape=e.u,exports.parseShapeScript=t.In,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Bn,exports.readSaveShapeResult=t.Vn,exports.samples=e.t,exports.sceneToUsdz=e.i,exports.shapeArtifactPath=e.m,exports.shapeScriptToUsdz=e.a,exports.toArtifactsRelative=e.g,exports.usdzArtifactPath=e._;
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-
|
|
2
|
-
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-
|
|
3
|
-
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-CXhuDdDd.js";
|
|
2
|
+
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-FsP-Na75.js";
|
|
3
|
+
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-BvTjfhU2.js";
|
|
4
4
|
export { O as EXPORT_USDZ_DESCRIPTION, T as EXPORT_USDZ_PROMPT, D as EXPORT_USDZ_SCHEMA, w as EXPORT_USDZ_TOOL_NAME, C as EXPORT_USDZ_TOOL_TIMEOUT_MS, r as SHAPE_EXTENSIONS, g as TOOL_DEFINITION, _ as TOOL_NAME, l as USDZ_EXTENSION, f as USDZ_MIME_TYPE, x as astToThreeJS, E as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, S as isShapeScriptDispatchArgs, h as locateShape, y as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, b as readSaveShapeResult, m as samples, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./samples-DGD0Kjwg.cjs"),t=require("./toThreeJS-MvllBF9e.cjs"),n=require("./core-DZvhTmuk.cjs");exports.EXPORT_USDZ_DESCRIPTION=n.t,exports.EXPORT_USDZ_PROMPT=n.n,exports.EXPORT_USDZ_SCHEMA=n.r,exports.EXPORT_USDZ_TOOL_NAME=n.i,exports.EXPORT_USDZ_TOOL_TIMEOUT_MS=n.a,exports.SHAPE_EXTENSIONS=e.d,exports.TOOL_DEFINITION=e.v,exports.TOOL_NAME=e.y,exports.USDZ_EXTENSION=e.n,exports.USDZ_MIME_TYPE=e.r,exports.astToThreeJS=t.r,exports.executeExportShapeScriptUsdz=n.o,exports.executePresentShapeScript=e.o,exports.executeShapeScriptDispatch=e.l,exports.isPresentableShapePath=e.f,exports.isShapeArtifactPath=e.p,exports.isShapeScriptDispatchArgs=t.zn,exports.locateShape=e.u,exports.parseShapeScript=t.In,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Bn,exports.readSaveShapeResult=t.Vn,exports.samples=e.t,exports.sceneToUsdz=e.i,exports.shapeArtifactPath=e.m,exports.shapeScriptToUsdz=e.a,exports.toArtifactsRelative=e.g,exports.usdzArtifactPath=e._;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-
|
|
2
|
-
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-
|
|
3
|
-
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./samples-CXhuDdDd.js";
|
|
2
|
+
import { Bn as v, In as y, Vn as b, r as x, zn as S } from "./toThreeJS-FsP-Na75.js";
|
|
3
|
+
import { a as C, i as w, n as T, o as E, r as D, t as O } from "./core-BvTjfhU2.js";
|
|
4
4
|
export { O as EXPORT_USDZ_DESCRIPTION, T as EXPORT_USDZ_PROMPT, D as EXPORT_USDZ_SCHEMA, w as EXPORT_USDZ_TOOL_NAME, C as EXPORT_USDZ_TOOL_TIMEOUT_MS, r as SHAPE_EXTENSIONS, g as TOOL_DEFINITION, _ as TOOL_NAME, l as USDZ_EXTENSION, f as USDZ_MIME_TYPE, x as astToThreeJS, E as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, S as isShapeScriptDispatchArgs, h as locateShape, y as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, b as readSaveShapeResult, m as samples, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
package/dist/render.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./toThreeJS-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./toThreeJS-MvllBF9e.cjs");let l=require("node:fs/promises"),u=require("node:module"),d=require("node:url"),f=require("node:path");f=s(f,1);function p(e){let t=Math.ceil(Math.sqrt(e));return{columns:t,rows:Math.ceil(e/t)}}function m(e,t,n){return`import { AmbientLight, Box3, DirectionalLight, GridHelper, MathUtils, ObjectLoader, OrthographicCamera, PerspectiveCamera, Scene, Sphere, Vector3, WebGLRenderer } from ${JSON.stringify(e)};
|
|
2
2
|
|
|
3
3
|
const config = ${t};
|
|
4
4
|
const { columns, rows } = ${n};
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { In as e, Rn as t, r as n } from "./toThreeJS-
|
|
1
|
+
import { In as e, Rn as t, r as n } from "./toThreeJS-FsP-Na75.js";
|
|
2
2
|
import { readFile as r } from "node:fs/promises";
|
|
3
3
|
import { createRequire as i } from "node:module";
|
|
4
4
|
import { pathToFileURL as a } from "node:url";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { In as e, Ln as t, Rn as n, i as r, it as i, m as a, n as o, r as s } from "./toThreeJS-
|
|
1
|
+
import { In as e, Ln as t, Rn as n, i as r, it as i, m as a, n as o, r as s } from "./toThreeJS-FsP-Na75.js";
|
|
2
2
|
import { ARTIFACTS_ROOT as c, buildArtifactRelPath as l, classifyFilePath as u, hasUnsafePathSegment as d, slugifyArtifact as f, toWorkspaceArtifactPath as p } from "@mulmoclaude/core/artifacts";
|
|
3
3
|
//#region src/core/definition.ts
|
|
4
4
|
var m = "presentShapeScript", h = {
|
|
@@ -14,7 +14,7 @@ var m = "presentShapeScript", h = {
|
|
|
14
14
|
},
|
|
15
15
|
script: {
|
|
16
16
|
type: "string",
|
|
17
|
-
description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {
|
|
17
|
+
description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {\n size radius\n color red\n}\n\n### Control Flow:\n\nFor loops with variables:\nfor i in 1 to 5 {\n cube {\n position (i * 2) 0 0\n size 1\n }\n}\n\nFor loops with step:\nfor i in 0 to 10 step 2 {\n sphere { position 0 i 0 }\n}\n\nIf/else conditionals:\ndefine showSphere 1\nif showSphere {\n sphere { size 2 }\n} else {\n cube { size 2 }\n}\n\nSwitch statements:\ndefine shape 2\nswitch shape {\ncase 1\n cube\ncase 2\n sphere\nelse\n cone\n}\n\n### Built-in Functions:\n\nMath: round, floor, ceil, abs, sign, sqrt, pow, min, max\nTrig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)\nVector: dot, cross, length, normalize, sum\n\nIMPORTANT: Function calls require NO space between name and parenthesis:\n- sin(x) ✓ function call\n- sin (x) ✗ NOT a function call (identifier + parenthesized expression)\nSeparate arguments with spaces, as upstream does: max(0 (j - 1)), pow(2.718 (0 - x)). Commas also work\nhere (max(0, j - 1)) but NOT in the upstream ShapeScript app, so prefer spaces. Bare max 0 1 without\nparentheses is not supported.\nWrite ONE statement per line. This parser accepts \"define a 1 define b 2\" on one line; the upstream app\nrejects it, and a script that keeps to one statement per line opens in both.\n\nExamples:\nfor i in 1 to 8 {\n define angle (i * 0.785) // 45 degrees in radians\n cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }\n}\n\n### Primitives & Properties:\n\nShapes: cube, sphere, cylinder, cone, torus, circle, square, polygon (sides 3–256)\nProperties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z\nMaterials: color R G B (0-1), opacity (0-1)\n\nUNITS (same as upstream ShapeScript — https://shapescript.info/mac/):\n- size is the DIAMETER of sphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length.\n- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.\n- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.\n- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.\n\n### CSG Operations:\nunion, difference, intersection, xor, stencil\n\nExample:\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n cube { size 1.5 }\n}\n\n### Paths:\npath { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.\n- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.\n- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.\n- rotate (half-turns) / translate / scale inside a path move the frame for later points:\n path {\n for 0 to 8 {\n curve 0 1\n rotate 1 / 8\n }\n } // semicircle\n\n### Builders:\n- extrude: extrude { polygon { sides 3 } } or an inline path (size Z = depth, default 1):\n extrude path {\n point 0 0\n point 1 0\n point 0 1\n point 0 0\n }\n- fill: fill { square } or fill path { ... }\n- lathe (revolves the XY profile about Y):\n lathe path {\n point 0 0\n point 1 0\n curve 1.5 1\n point 1 2\n point 0 2\n }\n- loft (closed planar sections joined with caps):\n loft {\n square\n translate 0 0 2\n circle\n }\n- hull (convex envelope):\n hull {\n cube { position -1 0 0 }\n cube { position 1 0 0 }\n }\n- stencil preserves the first shape and paints its surface with later shapes' materials.\nLoft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.\n\n### Additional Expressions:\n- Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)\n- Scientific notation and unary plus: 1e-3, +2\n- Tuple/vector members: vector.x, vector.y, vector.z; color.red/green/blue/alpha\n- Tuple/string length: value.count; zero-based indexing: values[0]; ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast\n- String literals, join(...), trim(...); min/max also accept tuples\n- Custom shapes with options:\ndefine post {\n option height 2\n cylinder { size 0.2 height }\n}\npost { height 3 }\n- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)\n\n### Compatibility:\nThis plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units and\npath semantics follow upstream, so a script written against the upstream docs renders the same here.\nFunction calls use name(...). Imports, textures, text/fonts, lights/cameras, arbitrary objects,\nhex/named colours, and general user-defined functions are not supported.\n\n### Comments:\n// Single-line comment\n/* Multi-line\n comment */\n\n## COMPLETE EXAMPLES:\n\nLinear arrangement with expressions:\ndefine spacing 1.5\nfor i in 1 to 4 {\n cylinder {\n position ((i - 2.5) * spacing) 0 0\n size 0.4 1\n }\n}\n\nCircular pattern:\ndefine count 12\nfor i in 1 to count {\n define angle ((i / count) * 6.283) // 2 * PI\n cube {\n position (cos(angle) * 3) 0 (sin(angle) * 3)\n color (i / count) 0.5 (1 - i / count)\n size 0.5\n }\n}\n\nConditional geometry:\ndefine makeHollow 1\nif makeHollow {\n difference {\n sphere {\n size 2\n color (1 0 0)\n }\n sphere { size 1.7 }\n }\n} else {\n sphere {\n size 2\n color (1 0 0)\n }\n}\n\nMathematical visualization:\nfor x in -5 to 5 {\n for z in -5 to 5 {\n define height (sin(x * 0.5) * cos(z * 0.5) * 2)\n cube {\n position (x * 0.3) height (z * 0.3)\n size 0.25 (abs(height) + 0.1) 0.25\n color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)\n }\n }\n}"
|
|
18
18
|
},
|
|
19
19
|
path: {
|
|
20
20
|
type: "string",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./toThreeJS-
|
|
1
|
+
const e=require("./toThreeJS-MvllBF9e.cjs");let t=require("@mulmoclaude/core/artifacts");var n=`presentShapeScript`,r={type:`function`,name:n,description:"Display interactive 3D visualizations using ShapeScript with expressions, variables, control flow, and functions. A new `script` is saved to `artifacts/shapes/` and the returned `filePath` names it; pass `path` instead to present a source that already exists.",parameters:{type:`object`,properties:{title:{type:`string`,description:`Title for the 3D visualization`},script:{type:`string`,description:`ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.
|
|
2
2
|
|
|
3
3
|
## SYNTAX OVERVIEW:
|
|
4
4
|
|
|
@@ -11,13 +11,19 @@ const e=require("./toThreeJS-XGDoVISb.cjs");let t=require("@mulmoclaude/core/art
|
|
|
11
11
|
### Variables:
|
|
12
12
|
define radius 2
|
|
13
13
|
define red (1 0 0)
|
|
14
|
-
sphere {
|
|
14
|
+
sphere {
|
|
15
|
+
size radius
|
|
16
|
+
color red
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
### Control Flow:
|
|
17
20
|
|
|
18
21
|
For loops with variables:
|
|
19
22
|
for i in 1 to 5 {
|
|
20
|
-
cube {
|
|
23
|
+
cube {
|
|
24
|
+
position (i * 2) 0 0
|
|
25
|
+
size 1
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
For loops with step:
|
|
@@ -53,6 +59,11 @@ Vector: dot, cross, length, normalize, sum
|
|
|
53
59
|
IMPORTANT: Function calls require NO space between name and parenthesis:
|
|
54
60
|
- sin(x) ✓ function call
|
|
55
61
|
- sin (x) ✗ NOT a function call (identifier + parenthesized expression)
|
|
62
|
+
Separate arguments with spaces, as upstream does: max(0 (j - 1)), pow(2.718 (0 - x)). Commas also work
|
|
63
|
+
here (max(0, j - 1)) but NOT in the upstream ShapeScript app, so prefer spaces. Bare max 0 1 without
|
|
64
|
+
parentheses is not supported.
|
|
65
|
+
Write ONE statement per line. This parser accepts "define a 1 define b 2" on one line; the upstream app
|
|
66
|
+
rejects it, and a script that keeps to one statement per line opens in both.
|
|
56
67
|
|
|
57
68
|
Examples:
|
|
58
69
|
for i in 1 to 8 {
|
|
@@ -63,43 +74,89 @@ for i in 1 to 8 {
|
|
|
63
74
|
### Primitives & Properties:
|
|
64
75
|
|
|
65
76
|
Shapes: cube, sphere, cylinder, cone, torus, circle, square, polygon (sides 3–256)
|
|
66
|
-
Properties: position X Y Z,
|
|
77
|
+
Properties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z
|
|
67
78
|
Materials: color R G B (0-1), opacity (0-1)
|
|
68
79
|
|
|
80
|
+
UNITS (same as upstream ShapeScript — https://shapescript.info/mac/):
|
|
81
|
+
- size is the DIAMETER of sphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length.
|
|
82
|
+
- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.
|
|
83
|
+
- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.
|
|
84
|
+
- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.
|
|
85
|
+
|
|
69
86
|
### CSG Operations:
|
|
70
87
|
union, difference, intersection, xor, stencil
|
|
71
88
|
|
|
72
89
|
Example:
|
|
73
90
|
difference {
|
|
74
|
-
sphere {
|
|
91
|
+
sphere {
|
|
92
|
+
size 2
|
|
93
|
+
color (1 0.5 0)
|
|
94
|
+
}
|
|
75
95
|
cube { size 1.5 }
|
|
76
96
|
}
|
|
77
97
|
|
|
98
|
+
### Paths:
|
|
99
|
+
path { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.
|
|
100
|
+
- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.
|
|
101
|
+
- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.
|
|
102
|
+
- rotate (half-turns) / translate / scale inside a path move the frame for later points:
|
|
103
|
+
path {
|
|
104
|
+
for 0 to 8 {
|
|
105
|
+
curve 0 1
|
|
106
|
+
rotate 1 / 8
|
|
107
|
+
}
|
|
108
|
+
} // semicircle
|
|
109
|
+
|
|
78
110
|
### Builders:
|
|
79
|
-
- extrude: extrude { polygon { sides 3 } } or
|
|
111
|
+
- extrude: extrude { polygon { sides 3 } } or an inline path (size Z = depth, default 1):
|
|
112
|
+
extrude path {
|
|
113
|
+
point 0 0
|
|
114
|
+
point 1 0
|
|
115
|
+
point 0 1
|
|
116
|
+
point 0 0
|
|
117
|
+
}
|
|
80
118
|
- fill: fill { square } or fill path { ... }
|
|
81
|
-
- lathe
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
- lathe (revolves the XY profile about Y):
|
|
120
|
+
lathe path {
|
|
121
|
+
point 0 0
|
|
122
|
+
point 1 0
|
|
123
|
+
curve 1.5 1
|
|
124
|
+
point 1 2
|
|
125
|
+
point 0 2
|
|
126
|
+
}
|
|
127
|
+
- loft (closed planar sections joined with caps):
|
|
128
|
+
loft {
|
|
129
|
+
square
|
|
130
|
+
translate 0 0 2
|
|
131
|
+
circle
|
|
132
|
+
}
|
|
133
|
+
- hull (convex envelope):
|
|
134
|
+
hull {
|
|
135
|
+
cube { position -1 0 0 }
|
|
136
|
+
cube { position 1 0 0 }
|
|
137
|
+
}
|
|
84
138
|
- stencil preserves the first shape and paints its surface with later shapes' materials.
|
|
85
139
|
Loft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.
|
|
86
140
|
|
|
87
141
|
### Additional Expressions:
|
|
88
|
-
- Constants: pi,
|
|
142
|
+
- Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)
|
|
89
143
|
- Scientific notation and unary plus: 1e-3, +2
|
|
90
144
|
- Tuple/vector members: vector.x, vector.y, vector.z; color.red/green/blue/alpha
|
|
91
|
-
- Tuple/string length: value.count; zero-based indexing: values[0]
|
|
145
|
+
- Tuple/string length: value.count; zero-based indexing: values[0]; ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast
|
|
92
146
|
- String literals, join(...), trim(...); min/max also accept tuples
|
|
93
147
|
- Custom shapes with options:
|
|
94
|
-
define post {
|
|
148
|
+
define post {
|
|
149
|
+
option height 2
|
|
150
|
+
cylinder { size 0.2 height }
|
|
151
|
+
}
|
|
95
152
|
post { height 3 }
|
|
153
|
+
- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)
|
|
96
154
|
|
|
97
155
|
### Compatibility:
|
|
98
|
-
This plugin implements the documented modeling subset, not all upstream ShapeScript syntax
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Imports, textures, text/fonts, arbitrary objects, and general user-defined functions are not supported.
|
|
156
|
+
This plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units and
|
|
157
|
+
path semantics follow upstream, so a script written against the upstream docs renders the same here.
|
|
158
|
+
Function calls use name(...). Imports, textures, text/fonts, lights/cameras, arbitrary objects,
|
|
159
|
+
hex/named colours, and general user-defined functions are not supported.
|
|
103
160
|
|
|
104
161
|
### Comments:
|
|
105
162
|
// Single-line comment
|
|
@@ -111,7 +168,10 @@ Imports, textures, text/fonts, arbitrary objects, and general user-defined funct
|
|
|
111
168
|
Linear arrangement with expressions:
|
|
112
169
|
define spacing 1.5
|
|
113
170
|
for i in 1 to 4 {
|
|
114
|
-
cylinder {
|
|
171
|
+
cylinder {
|
|
172
|
+
position ((i - 2.5) * spacing) 0 0
|
|
173
|
+
size 0.4 1
|
|
174
|
+
}
|
|
115
175
|
}
|
|
116
176
|
|
|
117
177
|
Circular pattern:
|
|
@@ -129,11 +189,17 @@ Conditional geometry:
|
|
|
129
189
|
define makeHollow 1
|
|
130
190
|
if makeHollow {
|
|
131
191
|
difference {
|
|
132
|
-
sphere {
|
|
192
|
+
sphere {
|
|
193
|
+
size 2
|
|
194
|
+
color (1 0 0)
|
|
195
|
+
}
|
|
133
196
|
sphere { size 1.7 }
|
|
134
197
|
}
|
|
135
198
|
} else {
|
|
136
|
-
sphere {
|
|
199
|
+
sphere {
|
|
200
|
+
size 2
|
|
201
|
+
color (1 0 0)
|
|
202
|
+
}
|
|
137
203
|
}
|
|
138
204
|
|
|
139
205
|
Mathematical visualization:
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { Expression, Vector3, Color } from "./types";
|
|
2
2
|
export type Value = number | boolean | string | Value[];
|
|
3
|
+
/** Upstream's `rnd` generator, bit for bit: a 32-bit LCG kept in a double,
|
|
4
|
+
* `x = (x * 1664525 + 1013904223) mod 2^32`, returning `x / 2^32`. Matching
|
|
5
|
+
* it means `seed 57` scatters shapes exactly as it does in the upstream app.
|
|
6
|
+
* A class, not a closure, because scopes SHARE it: a nested block advances
|
|
7
|
+
* its parent's sequence, but `seed` inside the block replaces only the
|
|
8
|
+
* block's own reference (see `SymbolTable.reseed`). */
|
|
9
|
+
export declare class RandomSequence {
|
|
10
|
+
private static readonly MODULUS;
|
|
11
|
+
private state;
|
|
12
|
+
constructor(seed: number);
|
|
13
|
+
private static wrap;
|
|
14
|
+
next(): number;
|
|
15
|
+
}
|
|
3
16
|
export declare class SymbolTable {
|
|
4
17
|
private scopes;
|
|
5
|
-
constructor();
|
|
18
|
+
constructor(seed?: number);
|
|
19
|
+
private innermost;
|
|
6
20
|
pushScope(): void;
|
|
7
21
|
popScope(): void;
|
|
22
|
+
/** `seed N`: a fresh sequence for THIS scope only. The parent keeps the
|
|
23
|
+
* sequence it had, so `rnd` after the closing brace carries on from there. */
|
|
24
|
+
reseed(seed: number): void;
|
|
25
|
+
nextRandom(): number;
|
|
8
26
|
set(name: string, value: Value): void;
|
|
9
27
|
get(name: string): Value | undefined;
|
|
10
28
|
has(name: string): boolean;
|
|
@@ -17,12 +35,17 @@ export declare class SymbolTable {
|
|
|
17
35
|
* can take different branches, so `if rnd < .5 { cube } else { … }` could
|
|
18
36
|
* validate clean and then fail in the viewport, which is exactly the failure
|
|
19
37
|
* the validation exists to prevent. A seeded generator makes both runs agree,
|
|
20
|
-
* and re-rendering a model on every keystroke stops reshuffling it.
|
|
21
|
-
|
|
38
|
+
* and re-rendering a model on every keystroke stops reshuffling it.
|
|
39
|
+
*
|
|
40
|
+
* Zero, like upstream, so a script's `rnd` values here are the ones the
|
|
41
|
+
* upstream app shows for it. */
|
|
42
|
+
export declare const DEFAULT_RANDOM_SEED = 0;
|
|
22
43
|
export declare class Evaluator {
|
|
23
44
|
private symbols;
|
|
24
|
-
private readonly random;
|
|
25
45
|
constructor(symbols?: SymbolTable, seed?: number);
|
|
46
|
+
private random;
|
|
47
|
+
/** The `seed` command. Scoped: see `SymbolTable.reseed`. */
|
|
48
|
+
reseed(seed: number): void;
|
|
26
49
|
getSymbols(): SymbolTable;
|
|
27
50
|
evaluate(expr: Expression | number | string | Vector3 | Color): Value;
|
|
28
51
|
evaluateToNumber(expr: Expression | number): number;
|
|
@@ -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,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,
|
|
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,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAe;gBAEjB,IAAI,GAAE,MAA4B;IAK9C,OAAO,CAAC,SAAS;IAMjB,SAAS,IAAI,IAAI;IAKjB,QAAQ,IAAI,IAAI;IAMhB;mFAC+E;IAC/E,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI1B,UAAU,IAAI,MAAM;IAIpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAIrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAWpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG3B;AAoID;;;;;;;;;;;iCAWiC;AACjC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAc;gBAEjB,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM;IAKhD,OAAO,CAAC,MAAM;IAId,4DAA4D;IAC5D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B,UAAU,IAAI,WAAW;IAIzB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK;IA6MrE,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM;IAKnD,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAK5C,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO;IAmBtD,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK;CAkBjD"}
|
|
@@ -42,6 +42,7 @@ export declare class Parser {
|
|
|
42
42
|
private parseSwitch;
|
|
43
43
|
private parseDefine;
|
|
44
44
|
private parseDetail;
|
|
45
|
+
private parseSeed;
|
|
45
46
|
private parseBackground;
|
|
46
47
|
private parseTexture;
|
|
47
48
|
private parseGroup;
|
|
@@ -61,6 +62,23 @@ export declare class Parser {
|
|
|
61
62
|
private isStartOfNewValue;
|
|
62
63
|
private parsePathValue;
|
|
63
64
|
private parsePath;
|
|
65
|
+
/** `{ … }` of a path or of a `for` inside one. Both accept the same
|
|
66
|
+
* commands, so one reader serves both instead of two drifting copies.
|
|
67
|
+
* Only the path itself (not a loop inside it) may carry the transform
|
|
68
|
+
* options, which land in `properties`. */
|
|
69
|
+
private parsePathBody;
|
|
70
|
+
/** `position` / `orientation` (alias `rotation`) / `size` inside a path
|
|
71
|
+
* block, as upstream allows on any shape. Returns false for anything else. */
|
|
72
|
+
private parsePathProperty;
|
|
73
|
+
private parsePathCommand;
|
|
74
|
+
/** `point x [y]` / `curve x [y]` — absolute coordinates in the path's local
|
|
75
|
+
* frame, as upstream. Y defaults to 0. */
|
|
76
|
+
private parsePathPoint;
|
|
77
|
+
/** `translate x [y]` / `scale x [y]` inside a path. A lone `translate x`
|
|
78
|
+
* moves along X only; a lone `scale s` is uniform, recorded by leaving `y`
|
|
79
|
+
* out rather than by copying the expression (which would evaluate it twice). */
|
|
80
|
+
private parsePathVector;
|
|
81
|
+
private parsePathFor;
|
|
64
82
|
private parseNode;
|
|
65
83
|
private refuseStalledToken;
|
|
66
84
|
parse(): SceneNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shapescript/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,SAAS,
|
|
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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
17
|
+
/** Starting seed for `rnd` / `rand()`, which a `seed` command in the script
|
|
18
|
+
* overrides. Defaults to `DEFAULT_RANDOM_SEED`, which is what keeps server
|
|
19
|
+
* validation and browser rendering on the same branch. */
|
|
19
20
|
randomSeed?: number;
|
|
20
21
|
}
|
|
21
22
|
export declare const DEFAULT_MAX_NODES = 100000;
|
|
@@ -105,6 +106,11 @@ export declare class Converter {
|
|
|
105
106
|
* definition and fall back to a unit size of their own. */
|
|
106
107
|
private requireExtent;
|
|
107
108
|
private createGeometry;
|
|
109
|
+
/** A plugin extension (upstream has no torus). `size` is the OVERALL
|
|
110
|
+
* diameter, tube included, so it follows the same rule as the other curved
|
|
111
|
+
* primitives: the ring radius is what is left once the tube is subtracted.
|
|
112
|
+
* `outerRadius` (ring) and `innerRadius` (tube) override the derivation. */
|
|
113
|
+
private createTorus;
|
|
108
114
|
private materialColor;
|
|
109
115
|
private createMaterial;
|
|
110
116
|
private convertCSG;
|
|
@@ -118,6 +124,15 @@ export declare class Converter {
|
|
|
118
124
|
private currentTransform;
|
|
119
125
|
private applyCurrentTransform;
|
|
120
126
|
private applyExplicitTransforms;
|
|
127
|
+
/** An upstream rotation value as a quaternion.
|
|
128
|
+
*
|
|
129
|
+
* `roll yaw pitch` are HALF-TURNS (0.5 = 90°) about Z, Y and X, applied in
|
|
130
|
+
* that order, and positive is clockwise looking down each axis toward the
|
|
131
|
+
* origin — Euclid stores the negated angle, so the sign is flipped here to
|
|
132
|
+
* match. A lone number is a roll (`orientation 0.25` = 45° about Z, not a
|
|
133
|
+
* uniform tuple like `size`), and four numbers are `angle x y z`. */
|
|
134
|
+
private rotationOf;
|
|
135
|
+
private rotationComponents;
|
|
121
136
|
private handleDetail;
|
|
122
137
|
private handleColorCommand;
|
|
123
138
|
private handleRotateCommand;
|
|
@@ -135,6 +150,31 @@ export declare class Converter {
|
|
|
135
150
|
private requireEnclosedArea;
|
|
136
151
|
private convertExtrude;
|
|
137
152
|
private buildPath;
|
|
153
|
+
/** Bake the path's own `position` / `orientation` / `size` into geometry
|
|
154
|
+
* built from it. Baked rather than set on the mesh so the consuming
|
|
155
|
+
* builder's own options (an `extrude { position … }`) still apply on top,
|
|
156
|
+
* the way they do upstream where the path is a placed shape. */
|
|
157
|
+
private placePath;
|
|
158
|
+
/** Run the path's commands and return its points in path space.
|
|
159
|
+
*
|
|
160
|
+
* Coordinates are ABSOLUTE, as upstream: `point 1 0` is at x=1 however many
|
|
161
|
+
* points came before it. What `translate`, `rotate` and `scale` move is the
|
|
162
|
+
* path's local frame, which every later point is placed through — so
|
|
163
|
+
* `for 0 to 8 { curve 0 1 rotate 1 / 8 }` walks a semicircle. The frame is
|
|
164
|
+
* post-multiplied like the shape transform, and checked after every command
|
|
165
|
+
* because individually finite operands can still overflow it. */
|
|
166
|
+
private collectPathPoints;
|
|
167
|
+
private runPathLoop;
|
|
168
|
+
/** Join path points into an outline, treating `curve` points as upstream does.
|
|
169
|
+
*
|
|
170
|
+
* A `curve` is the CONTROL point of a quadratic Bézier; the outline passes
|
|
171
|
+
* through the `point`s on either side of it, not through the control point
|
|
172
|
+
* itself. Two `curve`s in a row get an implicit on-curve point halfway
|
|
173
|
+
* between them, which is how eight controls in an octagon draw a circle.
|
|
174
|
+
* A closed path (first and last point equal) may start on a control point.
|
|
175
|
+
* An OPEN path's first and last points are taken as corners even when they
|
|
176
|
+
* are `curve`s — upstream extrapolates a tangent there; this does not. */
|
|
177
|
+
private shapeFromPathPoints;
|
|
138
178
|
private convertLathe;
|
|
139
179
|
/** A lathe profile is only a solid once it is SAMPLED.
|
|
140
180
|
*
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"toThreeJS.d.ts","sourceRoot":"","sources":["../../src/shapescript/toThree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