@mulmoclaude/shapescript-plugin 1.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 +61 -0
- package/dist/core/definition.d.ts +21 -0
- package/dist/core/definition.d.ts.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/plugin.d.ts +8 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/samples.d.ts +3 -0
- package/dist/core/samples.d.ts.map +1 -0
- package/dist/core/types.d.ts +22 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/lang/de.d.ts +4 -0
- package/dist/lang/de.d.ts.map +1 -0
- package/dist/lang/en.d.ts +4 -0
- package/dist/lang/en.d.ts.map +1 -0
- package/dist/lang/es.d.ts +4 -0
- package/dist/lang/es.d.ts.map +1 -0
- package/dist/lang/fr.d.ts +4 -0
- package/dist/lang/fr.d.ts.map +1 -0
- package/dist/lang/index.d.ts +7 -0
- package/dist/lang/index.d.ts.map +1 -0
- package/dist/lang/ja.d.ts +4 -0
- package/dist/lang/ja.d.ts.map +1 -0
- package/dist/lang/ko.d.ts +4 -0
- package/dist/lang/ko.d.ts.map +1 -0
- package/dist/lang/messages.d.ts +11 -0
- package/dist/lang/messages.d.ts.map +1 -0
- package/dist/lang/ptBR.d.ts +4 -0
- package/dist/lang/ptBR.d.ts.map +1 -0
- package/dist/lang/zh.d.ts +4 -0
- package/dist/lang/zh.d.ts.map +1 -0
- package/dist/shapescript/dispose.d.ts +16 -0
- package/dist/shapescript/dispose.d.ts.map +1 -0
- package/dist/shapescript/evaluator.d.ts +22 -0
- package/dist/shapescript/evaluator.d.ts.map +1 -0
- package/dist/shapescript/parser.d.ts +40 -0
- package/dist/shapescript/parser.d.ts.map +1 -0
- package/dist/shapescript/toThreeJS.d.ts +124 -0
- package/dist/shapescript/toThreeJS.d.ts.map +1 -0
- package/dist/shapescript/types.d.ts +304 -0
- package/dist/shapescript/types.d.ts.map +1 -0
- package/dist/style.css +3 -0
- package/dist/toThreeJS-CtWReTrz.cjs +169 -0
- package/dist/toThreeJS-DjFysw4f.js +11745 -0
- package/dist/vue/Preview.vue.d.ts +9 -0
- package/dist/vue/Preview.vue.d.ts.map +1 -0
- package/dist/vue/View.vue.d.ts +13 -0
- package/dist/vue/View.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +20 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue.cjs +4185 -0
- package/dist/vue.js +6741 -0
- package/package.json +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @mulmoclaude/shapescript-plugin
|
|
2
|
+
|
|
3
|
+
`presentShapeScript` — interactive 3D visualizations authored in the **ShapeScript** language.
|
|
4
|
+
The plugin ships its own ShapeScript parser / evaluator and a Three.js renderer (CSG via
|
|
5
|
+
`three-bvh-csg`), so a model is described as text and rendered in the chat canvas.
|
|
6
|
+
|
|
7
|
+
Ported from [`@gui-chat-plugin/present3d`](https://github.com/receptron/GUIChatPluginPresent3D)
|
|
8
|
+
(MIT, same authors). The tool is named `presentShapeScript` here — the upstream `present3D`
|
|
9
|
+
name, and the `Present3D*` type names, are renamed throughout.
|
|
10
|
+
|
|
11
|
+
## Exports
|
|
12
|
+
|
|
13
|
+
| Entry | Contents |
|
|
14
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
15
|
+
| `.` | `TOOL_NAME`, `TOOL_DEFINITION`, `executePresentShapeScript`, `pluginCore`, `samples`, `parseShapeScript`, `astToThreeJS` |
|
|
16
|
+
| `./vue` | the `ToolPlugin` (View + Preview + `SYSTEM_PROMPT`), plus everything on `.` |
|
|
17
|
+
| `./style.css` | the compiled component styles (Vite lib mode does not auto-inject them) |
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import type { ToolContext } from "gui-chat-protocol";
|
|
21
|
+
import { executePresentShapeScript } from "@mulmoclaude/shapescript-plugin";
|
|
22
|
+
|
|
23
|
+
// The handler does not read the context; the host passes its own.
|
|
24
|
+
const context = {} as ToolContext;
|
|
25
|
+
|
|
26
|
+
const result = await executePresentShapeScript(context, {
|
|
27
|
+
title: "Circular Pattern",
|
|
28
|
+
script: `
|
|
29
|
+
define count 12
|
|
30
|
+
for i in 1 to count {
|
|
31
|
+
define angle ((i / count) * 6.283)
|
|
32
|
+
cube {
|
|
33
|
+
position (cos(angle) * 3) 0 (sin(angle) * 3)
|
|
34
|
+
color (i / count) 0.5 (1 - i / count)
|
|
35
|
+
size 0.5
|
|
36
|
+
}
|
|
37
|
+
}`,
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## ShapeScript language
|
|
42
|
+
|
|
43
|
+
- **Primitives**: `cube`, `sphere`, `cylinder`, `cone`, `torus`, `circle`, `square`, `polygon`
|
|
44
|
+
- **Properties**: `position X Y Z`, `rotation X Y Z`, `size X Y Z`, `color R G B` (0–1), `opacity`
|
|
45
|
+
- **CSG**: `union`, `difference`, `intersection`, `xor`, `stencil`
|
|
46
|
+
- **Builders**: `extrude`, `loft`, `lathe`, `fill`, `hull`
|
|
47
|
+
- **Variables & expressions**: `define`, arithmetic / comparison / boolean operators, parentheses
|
|
48
|
+
- **Control flow**: `for … in … to … step`, `if` / `else`, `switch` / `case`
|
|
49
|
+
- **Built-ins**: `round floor ceil abs sign sqrt pow min max`, `sin cos tan asin acos atan atan2`
|
|
50
|
+
(radians), `dot cross length normalize sum`
|
|
51
|
+
|
|
52
|
+
A function call takes **no space** before its parenthesis: `sin(x)` is a call, `sin (x)` is not.
|
|
53
|
+
|
|
54
|
+
## Scripts
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
yarn build # vite build + d.ts emit
|
|
58
|
+
yarn typecheck # vue-tsc --noEmit
|
|
59
|
+
yarn lint
|
|
60
|
+
yarn test # node:test — tool execute + parser + Three.js conversion
|
|
61
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const TOOL_NAME = "presentShapeScript";
|
|
2
|
+
export declare const TOOL_DEFINITION: {
|
|
3
|
+
type: "function";
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
title: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
script: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;CA4I3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { PresentShapeScriptData, PresentShapeScriptArgs, PresentShapeScriptResult, PresentShapeScriptRenderedResult } from "./types";
|
|
2
|
+
export { TOOL_NAME, TOOL_DEFINITION } from "./definition";
|
|
3
|
+
export { pluginCore, presentShapeScript, executePresentShapeScript } from "./plugin";
|
|
4
|
+
export { samples } from "./samples";
|
|
5
|
+
export { parseShapeScript } from "../shapescript/parser";
|
|
6
|
+
export { astToThreeJS } from "../shapescript/toThreeJS";
|
|
7
|
+
export type { SceneNode } from "../shapescript/types";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAC1I,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ToolContext, ToolPluginCore } from "gui-chat-protocol";
|
|
2
|
+
import type { PresentShapeScriptArgs, PresentShapeScriptData, PresentShapeScriptRenderedResult } from "./types";
|
|
3
|
+
import { TOOL_NAME, TOOL_DEFINITION } from "./definition";
|
|
4
|
+
export declare const presentShapeScript: (_context: ToolContext, args: PresentShapeScriptArgs) => Promise<PresentShapeScriptRenderedResult>;
|
|
5
|
+
export declare const pluginCore: ToolPluginCore<PresentShapeScriptData, unknown, PresentShapeScriptArgs>;
|
|
6
|
+
export { TOOL_NAME, TOOL_DEFINITION };
|
|
7
|
+
export declare const executePresentShapeScript: (_context: ToolContext, args: PresentShapeScriptArgs) => Promise<PresentShapeScriptRenderedResult>;
|
|
8
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/core/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAChH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK1D,eAAO,MAAM,kBAAkB,GAAU,UAAU,WAAW,EAAE,MAAM,sBAAsB,KAAG,OAAO,CAAC,gCAAgC,CAkBtI,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAM9F,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AACtC,eAAO,MAAM,yBAAyB,aA7Ba,WAAW,QAAQ,sBAAsB,KAAG,OAAO,CAAC,gCAAgC,CA6B5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samples.d.ts","sourceRoot":"","sources":["../../src/core/samples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,OAAO,EAAE,UAAU,EA2D/B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ToolResult } from "gui-chat-protocol";
|
|
2
|
+
export interface PresentShapeScriptData {
|
|
3
|
+
script: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PresentShapeScriptArgs {
|
|
6
|
+
title: string;
|
|
7
|
+
script: string;
|
|
8
|
+
}
|
|
9
|
+
export type PresentShapeScriptResult = ToolResult<PresentShapeScriptData>;
|
|
10
|
+
/** The success shape of `presentShapeScript`.
|
|
11
|
+
*
|
|
12
|
+
* `data` is REQUIRED here, not optional as on `ToolResult`, because it is the
|
|
13
|
+
* host's render-eligibility signal: MulmoClaude's MCP bridge only pushes a
|
|
14
|
+
* tool result into the session — the event the canvas renders the View from —
|
|
15
|
+
* when the handler set `data`. A result without it is a narrate-only call, so
|
|
16
|
+
* the LLM would report success while the user saw no 3D view at all. Typing it
|
|
17
|
+
* as required means dropping it cannot compile.
|
|
18
|
+
*/
|
|
19
|
+
export type PresentShapeScriptRenderedResult = PresentShapeScriptResult & {
|
|
20
|
+
data: PresentShapeScriptData;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAE1E;;;;;;;;GAQG;AACH,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,IAAI,EAAE,sBAAsB,CAAC;CAC9B,CAAC"}
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./toThreeJS-CtWReTrz.cjs");exports.TOOL_DEFINITION=e.Ln,exports.TOOL_NAME=e.Rn,exports.astToThreeJS=e.t,exports.executePresentShapeScript=e.Pn,exports.parseShapeScript=e.Mn,exports.pluginCore=e.Fn,exports.presentShapeScript=e.In,exports.samples=e.Nn;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Fn as e, In as t, Ln as n, Mn as r, Nn as i, Pn as a, Rn as o, t as s } from "./toThreeJS-DjFysw4f.js";
|
|
2
|
+
export { n as TOOL_DEFINITION, o as TOOL_NAME, s as astToThreeJS, a as executePresentShapeScript, r as parseShapeScript, e as pluginCore, t as presentShapeScript, i as samples };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./toThreeJS-CtWReTrz.cjs");require("./core.cjs"),exports.TOOL_DEFINITION=e.Ln,exports.TOOL_NAME=e.Rn,exports.astToThreeJS=e.t,exports.executePresentShapeScript=e.Pn,exports.parseShapeScript=e.Mn,exports.pluginCore=e.Fn,exports.presentShapeScript=e.In,exports.samples=e.Nn;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Fn as e, In as t, Ln as n, Mn as r, Nn as i, Pn as a, Rn as o, t as s } from "./toThreeJS-DjFysw4f.js";
|
|
2
|
+
import "./core.js";
|
|
3
|
+
export { n as TOOL_DEFINITION, o as TOOL_NAME, s as astToThreeJS, a as executePresentShapeScript, r as parseShapeScript, e as pluginCore, t as presentShapeScript, i as samples };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"de.d.ts","sourceRoot":"","sources":["../../src/lang/de.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/lang/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../src/lang/es.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/lang/fr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Messages } from "./messages";
|
|
2
|
+
/** Reactive message bundle for the active host locale. The plugin carries its
|
|
3
|
+
* own translations (no host i18n dependency); it reads the locale off the
|
|
4
|
+
* injected `BrowserPluginRuntime.locale` ref and falls back to English. */
|
|
5
|
+
export declare const useT: () => import("vue").ComputedRef<Messages>;
|
|
6
|
+
export type { Messages };
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lang/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAY3C;;4EAE4E;AAC5E,eAAO,MAAM,IAAI,2CAAuB,CAAC;AAEzC,YAAY,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ja.d.ts","sourceRoot":"","sources":["../../src/lang/ja.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ko.d.ts","sourceRoot":"","sources":["../../src/lang/ko.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/lang/messages.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ptBR.d.ts","sourceRoot":"","sources":["../../src/lang/ptBR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,IAAI,EAAE,QASX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh.d.ts","sourceRoot":"","sources":["../../src/lang/zh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,QAAA,MAAM,EAAE,EAAE,QAST,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
/** Release the GPU-side resources of `root` and everything under it. The object
|
|
3
|
+
* must already be detached (or about to be) — this does not touch parents. */
|
|
4
|
+
export declare function disposeObject3D(root: THREE.Object3D): void;
|
|
5
|
+
/** Free every object in `scratch` except the resources `keep` still draws with.
|
|
6
|
+
*
|
|
7
|
+
* For intermediates that never reach the scene — the cloned meshes and Brushes
|
|
8
|
+
* a CSG block builds, and the operands each `evaluate()` consumes. Nothing
|
|
9
|
+
* disposes those otherwise, since scene teardown only walks what was added to
|
|
10
|
+
* the scene. `keep` is excluded by RESOURCE, not by identity, because the
|
|
11
|
+
* survivor routinely shares a geometry or material with a discarded operand. */
|
|
12
|
+
export declare function disposeScratch(scratch: readonly THREE.Object3D[], keep: THREE.Object3D): void;
|
|
13
|
+
/** Detach `root` from `parent` and free it. Safe with a null/undefined root so
|
|
14
|
+
* callers can hand over a ref that has not been filled in yet. */
|
|
15
|
+
export declare function removeAndDispose(parent: THREE.Object3D | undefined, root: THREE.Object3D | null | undefined): void;
|
|
16
|
+
//# sourceMappingURL=dispose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/shapescript/dispose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAsD/B;+EAC+E;AAC/E,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAE1D;AAED;;;;;;iFAMiF;AACjF,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAQ7F;AAED;mEACmE;AACnE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAIlH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Expression, Vector3, Color } from "./types";
|
|
2
|
+
export type Value = number | boolean | string | Value[];
|
|
3
|
+
export declare class SymbolTable {
|
|
4
|
+
private scopes;
|
|
5
|
+
constructor();
|
|
6
|
+
pushScope(): void;
|
|
7
|
+
popScope(): void;
|
|
8
|
+
set(name: string, value: Value): void;
|
|
9
|
+
get(name: string): Value | undefined;
|
|
10
|
+
has(name: string): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class Evaluator {
|
|
13
|
+
private symbols;
|
|
14
|
+
constructor(symbols?: SymbolTable);
|
|
15
|
+
getSymbols(): SymbolTable;
|
|
16
|
+
evaluate(expr: Expression | number | string | Vector3 | Color): Value;
|
|
17
|
+
evaluateToNumber(expr: Expression | number): number;
|
|
18
|
+
evaluateToBoolean(expr: Expression): boolean;
|
|
19
|
+
evaluateToVector3(expr: Expression | Vector3): Vector3;
|
|
20
|
+
evaluateToColor(expr: Expression | Color): Color;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -0,0 +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,CAA4B;;IAM1C,SAAS,IAAI,IAAI;IAIjB,QAAQ,IAAI,IAAI;IAMhB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAMrC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAWpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAG3B;AAsHD,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAc;gBAEjB,OAAO,CAAC,EAAE,WAAW;IAIjC,UAAU,IAAI,WAAW;IAIzB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK;IA0LrE,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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Token, SceneNode } from "./types";
|
|
2
|
+
export declare class Parser {
|
|
3
|
+
private tokens;
|
|
4
|
+
private pos;
|
|
5
|
+
constructor(tokens: Token[]);
|
|
6
|
+
private at;
|
|
7
|
+
private current;
|
|
8
|
+
private peek;
|
|
9
|
+
private advance;
|
|
10
|
+
private expect;
|
|
11
|
+
private expectIdentifier;
|
|
12
|
+
private skipNewlines;
|
|
13
|
+
private parseExpression;
|
|
14
|
+
private parsePrimary;
|
|
15
|
+
private getPrecedence;
|
|
16
|
+
private tokenTypeToOperator;
|
|
17
|
+
private parseVectorOrExpression;
|
|
18
|
+
private parseProperties;
|
|
19
|
+
private parseBlockContents;
|
|
20
|
+
private parseBlock;
|
|
21
|
+
private parseShape;
|
|
22
|
+
private parseCSG;
|
|
23
|
+
private parseForLoop;
|
|
24
|
+
private parseIf;
|
|
25
|
+
private parseSwitch;
|
|
26
|
+
private parseDefine;
|
|
27
|
+
private parseDetail;
|
|
28
|
+
private parseBackground;
|
|
29
|
+
private parseTexture;
|
|
30
|
+
private parseGroup;
|
|
31
|
+
private parseBuilder;
|
|
32
|
+
private parsePathValue;
|
|
33
|
+
private isStartOfNewValue;
|
|
34
|
+
private parsePathPrimary;
|
|
35
|
+
private parsePath;
|
|
36
|
+
private parseNode;
|
|
37
|
+
parse(): SceneNode[];
|
|
38
|
+
}
|
|
39
|
+
export declare function parseShapeScript(script: string): SceneNode[];
|
|
40
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shapescript/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,SAAS,EAsBV,MAAM,SAAS,CAAC;AAkejB,qBAAa,MAAM;IACjB,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;IA2BvB,OAAO,CAAC,YAAY;IAoIpB,OAAO,CAAC,aAAa;IA0BrB,OAAO,CAAC,mBAAmB;IAmC3B,OAAO,CAAC,uBAAuB;IAuD/B,OAAO,CAAC,eAAe;IAsDvB,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,eAAe;IAWvB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,YAAY;IA8IpB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,gBAAgB;IAoExB,OAAO,CAAC,SAAS;IA+NjB,OAAO,CAAC,SAAS;IA2JjB,KAAK,IAAI,SAAS,EAAE;CAarB;AAGD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAmB5D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { SceneNode } from "./types";
|
|
3
|
+
export interface ConversionOptions {
|
|
4
|
+
wireframe?: boolean;
|
|
5
|
+
/** Hard ceiling on the objects one script may produce. See
|
|
6
|
+
* `DEFAULT_MAX_NODES`. */
|
|
7
|
+
maxNodes?: number;
|
|
8
|
+
/** Hard ceiling on the iterations one `for` may run. See
|
|
9
|
+
* `DEFAULT_MAX_LOOP_ITERATIONS`. */
|
|
10
|
+
maxLoopIterations?: number;
|
|
11
|
+
/** Hard ceiling on the vertices one script may allocate in total. See
|
|
12
|
+
* `DEFAULT_MAX_VERTICES`. */
|
|
13
|
+
maxVertices?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_MAX_NODES = 20000;
|
|
16
|
+
export declare const DEFAULT_MAX_LOOP_ITERATIONS = 100000;
|
|
17
|
+
export declare const MIN_DETAIL = 3;
|
|
18
|
+
export declare const MAX_DETAIL = 256;
|
|
19
|
+
export declare const DEFAULT_MAX_VERTICES = 2000000;
|
|
20
|
+
/** Its own class so `convertCSG`'s fallback can rethrow it instead of swallowing
|
|
21
|
+
* it: catching a budget error there would rebuild the same runaway children as
|
|
22
|
+
* a plain group, which is the work the budget exists to refuse. */
|
|
23
|
+
export declare class ShapeScriptLimitError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class Converter {
|
|
27
|
+
private options;
|
|
28
|
+
private evaluator;
|
|
29
|
+
private symbols;
|
|
30
|
+
private detailLevel;
|
|
31
|
+
/** Objects produced so far, checked against `maxNodes` on every node. */
|
|
32
|
+
private nodeCount;
|
|
33
|
+
/** Vertices allocated so far, checked against `maxVertices` on every mesh. */
|
|
34
|
+
private vertexCount;
|
|
35
|
+
private transformStack;
|
|
36
|
+
constructor(options?: ConversionOptions);
|
|
37
|
+
convert(nodes: SceneNode[]): THREE.Group;
|
|
38
|
+
private get maxNodes();
|
|
39
|
+
private get maxLoopIterations();
|
|
40
|
+
private get maxVertices();
|
|
41
|
+
/** Charge an ESTIMATE before the allocation happens.
|
|
42
|
+
*
|
|
43
|
+
* `makeMesh` charges what a geometry actually holds, which is too late for a
|
|
44
|
+
* constructor whose inputs already predict something enormous:
|
|
45
|
+
* `LatheGeometry` over a 100k-point profile at `detail 256` allocates ~25M
|
|
46
|
+
* vertices — hundreds of MB on the UI thread — before there is anything to
|
|
47
|
+
* measure. Where the count is predictable, refuse first. */
|
|
48
|
+
/** Pre-flight charge for a geometry built from a path.
|
|
49
|
+
*
|
|
50
|
+
* `Shape.curves` is a plain array, so reading its length allocates nothing —
|
|
51
|
+
* unlike `getPoints()`, which would build the very buffer we are trying to
|
|
52
|
+
* refuse. A path may hold up to `maxLoopIterations` points, and at high
|
|
53
|
+
* detail the constructor multiplies that again, so `ExtrudeGeometry` and
|
|
54
|
+
* `ShapeGeometry` need the same treatment `LatheGeometry` got. */
|
|
55
|
+
private chargePathEstimate;
|
|
56
|
+
private chargeEstimate;
|
|
57
|
+
/** Every mesh in the scene is built here, so the AGGREGATE vertex count is
|
|
58
|
+
* bounded and not merely the node count. Charged after the geometry exists —
|
|
59
|
+
* one primitive is bounded by `MAX_DETAIL²`, so the allocation that trips the
|
|
60
|
+
* limit is small, and it is freed before the refusal propagates. */
|
|
61
|
+
private makeMesh;
|
|
62
|
+
/** Expand a `for … from to to step` range without materialising it first.
|
|
63
|
+
* The array used to be built up front, so an absurd bound exhausted memory
|
|
64
|
+
* before a single node existed and the budget below never got a turn. */
|
|
65
|
+
private rangeIterations;
|
|
66
|
+
private convertNode;
|
|
67
|
+
/** Build `group` inside a fresh symbol + transform scope.
|
|
68
|
+
*
|
|
69
|
+
* The `catch` is not tidiness: nothing downstream can reach a group that was
|
|
70
|
+
* never returned. The CSG caller records a child only once conversion
|
|
71
|
+
* returns, and the Vue callers assign the root only once `astToThreeJS`
|
|
72
|
+
* returns — so a body that throws midway (a budget refusal, a bad
|
|
73
|
+
* expression) strands whatever it had already built, with no owner to
|
|
74
|
+
* dispose it. The `finally` is the other half: a throw must not leave the
|
|
75
|
+
* scope frames behind for whatever runs next. */
|
|
76
|
+
private inScope;
|
|
77
|
+
/** The frame half on its own, for builders that return a single mesh rather
|
|
78
|
+
* than a group: there is nothing to dispose (a geometry that trips the
|
|
79
|
+
* budget is freed by `makeMesh`), but a throw must still not leave the
|
|
80
|
+
* symbol and transform frames behind for whatever runs next. */
|
|
81
|
+
private inFrame;
|
|
82
|
+
/** Convert each child and add whatever it produced to `group`. Every block
|
|
83
|
+
* form ends up doing exactly this, and jscpd was right that six copies of
|
|
84
|
+
* the loop is five too many. */
|
|
85
|
+
private addChildren;
|
|
86
|
+
private convertBlock;
|
|
87
|
+
private convertShape;
|
|
88
|
+
private createGeometry;
|
|
89
|
+
private materialColor;
|
|
90
|
+
private createMaterial;
|
|
91
|
+
private convertCSG;
|
|
92
|
+
private convertForLoop;
|
|
93
|
+
private convertIf;
|
|
94
|
+
private convertSwitch;
|
|
95
|
+
private handleDefine;
|
|
96
|
+
private convertCustomShape;
|
|
97
|
+
private pushTransform;
|
|
98
|
+
private popTransform;
|
|
99
|
+
private currentTransform;
|
|
100
|
+
private applyCurrentTransform;
|
|
101
|
+
private applyExplicitTransforms;
|
|
102
|
+
private handleDetail;
|
|
103
|
+
private handleColorCommand;
|
|
104
|
+
private handleRotateCommand;
|
|
105
|
+
private handleOrientationCommand;
|
|
106
|
+
private handleTranslateCommand;
|
|
107
|
+
private handleScaleCommand;
|
|
108
|
+
private convertExtrude;
|
|
109
|
+
private buildPath;
|
|
110
|
+
private convertLathe;
|
|
111
|
+
private buildLathe;
|
|
112
|
+
private convertGroupBuilder;
|
|
113
|
+
private convertLoft;
|
|
114
|
+
private convertFill;
|
|
115
|
+
private convertHull;
|
|
116
|
+
private evaluateNumber;
|
|
117
|
+
private evaluateVector3;
|
|
118
|
+
private evaluateTranslateVector;
|
|
119
|
+
private evaluateColor;
|
|
120
|
+
private evaluateVector3OrColor;
|
|
121
|
+
private valuesEqual;
|
|
122
|
+
}
|
|
123
|
+
export declare function astToThreeJS(nodes: SceneNode[], options?: ConversionOptions): THREE.Group;
|
|
124
|
+
//# sourceMappingURL=toThreeJS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toThreeJS.d.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