@mulmoclaude/shapescript-plugin 2.3.0 → 2.5.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 +11 -7
- package/dist/core/definition.d.ts.map +1 -1
- package/dist/core/samples.d.ts.map +1 -1
- package/dist/{core-BBgBeYYe.cjs → core-DVrgcbHm.cjs} +1 -1
- package/dist/{core-yB1Eiacr.js → core-mg9vhqAp.js} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/export/usdz.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/render.cjs +2 -2
- package/dist/render.js +9 -9
- package/dist/{samples-D2_jOmoh.cjs → samples-DUiaU2gY.cjs} +49 -20
- package/dist/{samples-CT-c9o1S.js → samples-Dl_yo5Ql.js} +353 -298
- package/dist/shapescript/builders.d.ts +5 -0
- package/dist/shapescript/builders.d.ts.map +1 -1
- package/dist/shapescript/parser.d.ts +22 -0
- package/dist/shapescript/parser.d.ts.map +1 -1
- package/dist/shapescript/text.d.ts +29 -0
- package/dist/shapescript/text.d.ts.map +1 -0
- package/dist/shapescript/toThreeJS.d.ts +15 -1
- package/dist/shapescript/toThreeJS.d.ts.map +1 -1
- package/dist/shapescript/types.d.ts +16 -1
- package/dist/shapescript/types.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/{toThreeJS-CKjSbEnA.js → toThreeJS-BKTWUGi8.js} +1468 -1064
- package/dist/toThreeJS-CcjI8USA.cjs +24 -0
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue.cjs +24 -21
- package/dist/vue.js +1080 -1077
- package/package.json +1 -1
- package/dist/toThreeJS-Cs0UJm82.cjs +0 -10
package/README.md
CHANGED
|
@@ -79,9 +79,8 @@ USDZ units are metres, so `size 1` is one metre in AR.
|
|
|
79
79
|
A call is either C-like, with **no space** before its parenthesis (`sin(x)`; `sin (x)` is not a
|
|
80
80
|
call), or bare, as upstream: `max 0 (j - 1)`, `sqrt 9`, `sin pi / 2` — the function takes every
|
|
81
81
|
value after it, so parenthesise it inside a larger expression: `(sqrt 9) + (sqrt 16)`. Arguments are
|
|
82
|
-
a value list; commas (`max(0, j - 1)`) also work here but not in the upstream app.
|
|
83
|
-
|
|
84
|
-
portable scripts keep to that.
|
|
82
|
+
a value list; commas (`max(0, j - 1)`) also work here but not in the upstream app. One statement per
|
|
83
|
+
line, as upstream: `define a 1 define b 2` on one line is a parse error naming the rule.
|
|
85
84
|
|
|
86
85
|
## Storage
|
|
87
86
|
|
|
@@ -212,7 +211,7 @@ extrude path {
|
|
|
212
211
|
}
|
|
213
212
|
```
|
|
214
213
|
|
|
215
|
-
Also supported: `pi
|
|
214
|
+
Also supported: `pi` (no `tau`, as upstream; write `2 * pi`), `true`, `false`, scientific notation, unary `+`,
|
|
216
215
|
short-circuit `and`/`or`, string literals, `join`/`split`/`trim`, tuple arguments to `min`/`max`,
|
|
217
216
|
zero-based tuple/string subscripts (negative from the end, or by name: `v["y"]`), `.count`, ordinal
|
|
218
217
|
members `.first` … `.tenth`, `.last`, `.allButFirst`, `.allButLast`, vector `.x/.y/.z/.w`, size
|
|
@@ -273,8 +272,13 @@ corners, capped at the ends of an open path); an open path extrudes to a two-sid
|
|
|
273
272
|
upstream. `minkowski { a b }` is the hull of two convex solids' vertex sums, and for a
|
|
274
273
|
non-convex operand the merged per-face hulls (overlapping shells, not a boolean union — fine to
|
|
275
274
|
draw, not to feed to another boolean); `inset(mesh d)` slides every vertex to where its faces'
|
|
276
|
-
offset planes meet. `
|
|
277
|
-
|
|
275
|
+
offset planes meet. `text "Hello"` lays glyph outlines out as upstream does — left margin at
|
|
276
|
+
x = 0, first baseline at y = 0, one world unit per line, `size` scaling it, `wrapwidth` and
|
|
277
|
+
`linespacing` as options, values interpolated (`text "Bob has " apples " apples"`) — in a bundled
|
|
278
|
+
Helvetica-like face (Helvetiker; `font` is accepted and skipped with a warning, and a character
|
|
279
|
+
the face lacks draws as `?`). Bare `text` draws outlines; `fill` and `extrude` turn it into faces
|
|
280
|
+
and solids, holes included, and it is a value with `.bounds`. `import`, `svgpath`, `object` values
|
|
281
|
+
and paths as values are refused with a message naming the feature. Textures,
|
|
278
282
|
normal maps, `camera` and `light` blocks are accepted and skipped with a warning that the
|
|
279
283
|
tool result and the View both report. Unsupported commands and failed CSG operations return
|
|
280
284
|
errors instead of silently substituting different geometry. As with other polygonal CSG
|
|
@@ -293,7 +297,7 @@ places it (with `position` / `orientation` / `size` on the call), and its member
|
|
|
293
297
|
construction face for face, so scripts that index its faces (upstream's Dodecahedron) get the same
|
|
294
298
|
faces. `for v in … { expr }` and `if c { a } else { b }` are expressions, a function may build
|
|
295
299
|
shapes (`define face(data) { polygon { … } }`) and be called bare as a statement (`face data`), and
|
|
296
|
-
`mesh { … }` assembles the polygons its body produces — `polygon { color red
|
|
300
|
+
`mesh { … }` assembles the polygons its body produces — `polygon { color red … }` with one `point` per line
|
|
297
301
|
with 3D points, a tuple per point allowed — into one flat-shaded, vertex-coloured mesh. A value a
|
|
298
302
|
statement produces that is not a shape is an "unused value" error, as upstream. Paths as values and
|
|
299
303
|
`object` values remain unsupported.
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;CA+R3B,CAAC"}
|
|
@@ -1 +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,
|
|
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,EAgF/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./samples-
|
|
1
|
+
const e=require("./samples-DUiaU2gY.cjs"),t=require("./toThreeJS-CcjI8USA.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}});
|
|
@@ -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-Dl_yo5Ql.js";
|
|
2
|
+
import { t as r } from "./toThreeJS-BKTWUGi8.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",
|
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-DUiaU2gY.cjs"),t=require("./toThreeJS-CcjI8USA.cjs"),n=require("./core-DVrgcbHm.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.Vn,exports.locateShape=e.u,exports.parseShapeScript=t.s,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Hn,exports.readSaveShapeResult=t.Un,exports.samples=e.t,exports.sceneInfoOf=t.i,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 {
|
|
3
|
-
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-
|
|
4
|
-
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath,
|
|
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-Dl_yo5Ql.js";
|
|
2
|
+
import { Hn as v, Un as y, Vn as b, i as x, r as S, s as C } from "./toThreeJS-BKTWUGi8.js";
|
|
3
|
+
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-mg9vhqAp.js";
|
|
4
|
+
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, b as isShapeScriptDispatchArgs, h as locateShape, C as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, y as readSaveShapeResult, m as samples, x as sceneInfoOf, o as sceneToUsdz, c as shapeArtifactPath, t as shapeScriptToUsdz, a as toArtifactsRelative, e as usdzArtifactPath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usdz.d.ts","sourceRoot":"","sources":["../../src/export/usdz.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,gFAAgF;AAChF,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,4CAA4C;AAC5C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;uEAGuE;AACvE,wBAAsB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"usdz.d.ts","sourceRoot":"","sources":["../../src/export/usdz.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,gFAAgF;AAChF,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,4CAA4C;AAC5C,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;;uEAGuE;AACvE,wBAAsB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAS1F;AA8FD;;;gEAGgE;AAChE,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAO5I"}
|
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-DUiaU2gY.cjs"),t=require("./toThreeJS-CcjI8USA.cjs"),n=require("./core-DVrgcbHm.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.Vn,exports.locateShape=e.u,exports.parseShapeScript=t.s,exports.pluginCore=e.s,exports.presentShapeScript=e.c,exports.readLoadShapeResult=t.Hn,exports.readSaveShapeResult=t.Un,exports.samples=e.t,exports.sceneInfoOf=t.i,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 {
|
|
3
|
-
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-
|
|
4
|
-
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath,
|
|
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-Dl_yo5Ql.js";
|
|
2
|
+
import { Hn as v, Un as y, Vn as b, i as x, r as S, s as C } from "./toThreeJS-BKTWUGi8.js";
|
|
3
|
+
import { a as w, i as T, n as E, o as D, r as O, t as k } from "./core-mg9vhqAp.js";
|
|
4
|
+
export { k as EXPORT_USDZ_DESCRIPTION, E as EXPORT_USDZ_PROMPT, O as EXPORT_USDZ_SCHEMA, T as EXPORT_USDZ_TOOL_NAME, w 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, S as astToThreeJS, D as executeExportShapeScriptUsdz, u as executePresentShapeScript, s as executeShapeScriptDispatch, i as isPresentableShapePath, d as isShapeArtifactPath, b as isShapeScriptDispatchArgs, h as locateShape, C as parseShapeScript, p as pluginCore, n as presentShapeScript, v as readLoadShapeResult, y as readSaveShapeResult, m as samples, x as sceneInfoOf, 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-CcjI8USA.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, Color, 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};
|
|
@@ -83,4 +83,4 @@ window.__shapeSheet = sheet.toDataURL("image/png");`}function g(e){let{threeUrl:
|
|
|
83
83
|
<canvas id="sheet"></canvas>
|
|
84
84
|
<script type="module">
|
|
85
85
|
${`${m(t,JSON.stringify({views:r,width:i,height:a,zoom:o,projection:s,scene:n}),JSON.stringify(p(r.length)))}\n${h()}`}
|
|
86
|
-
<\/script>`}var _=1e3;function v(e){return e instanceof Error?e.message:String(e)}var y=60*_,b=30*_,x=9e4,S="renderShapeScript needs Puppeteer's headless Chromium, which this host does not have. Run `npx puppeteer browsers install chrome`, then retry. Everything else, including presentShapeScript, works without it.",C=class extends Error{};function w(e,t){try{e?.(t)}catch{}}function T(){let e={}.url;if(typeof e==`string`&&e.length>0)return e;if(typeof __filename==`string`)return(0,d.pathToFileURL)(__filename).href;throw Error(`shapescript render: cannot locate this module to resolve three from`)}var E=(0,u.createRequire)(T());function D(e){return c.
|
|
86
|
+
<\/script>`}var _=1e3;function v(e){return e instanceof Error?e.message:String(e)}var y=60*_,b=30*_,x=9e4,S="renderShapeScript needs Puppeteer's headless Chromium, which this host does not have. Run `npx puppeteer browsers install chrome`, then retry. Everything else, including presentShapeScript, works without it.",C=class extends Error{};function w(e,t){try{e?.(t)}catch{}}function T(){let e={}.url;if(typeof e==`string`&&e.length>0)return e;if(typeof __filename==`string`)return(0,d.pathToFileURL)(__filename).href;throw Error(`shapescript render: cannot locate this module to resolve three from`)}var E=(0,u.createRequire)(T());function D(e){return c.Bn(e)&&typeof e.launch==`function`}async function ee(){try{let e=await import(`puppeteer`);return D(e)?e:c.Bn(e)&&D(e.default)?e.default:null}catch{return null}}function te(){try{return(0,u.createRequire)(E.resolve(`@mulmoclaude/shapescript-plugin/package.json`))}catch{return E}}function O(){let e=te().resolve(`three`);return e.endsWith(`three.cjs`)?e.replace(/three\.cjs$/,`three.module.js`):e}var k=`https://shapescript.invalid`,A=`${k}/render.html`,j=`./three.module.js`;async function M(e,t,n){let r;try{r=new URL(e)}catch{return null}if(r.origin!==k)return null;let i=f.default.posix.basename(r.pathname);return i===`render.html`?{contentType:`text/html; charset=utf-8`,body:t}:/^three[\w.-]*\.js$/.test(i)?{contentType:`text/javascript; charset=utf-8`,body:await(0,l.readFile)(f.default.join(n,i),`utf-8`)}:null}async function N(e,t){let n=f.default.dirname(O());await e.setRequestInterception(!0),e.on(`request`,e=>{(async()=>{try{let r=await M(e.url(),t,n);await(r?e.respond({status:200,...r}):e.abort())}catch{}})()})}async function P(e){let t=await ee();if(!t)throw new C(S);let n=c.r(c.s(e.script)).toJSON(),r=g({...e,threeUrl:j,sceneJson:n}),i;try{i=await t.launch({headless:!0,timeout:b,args:[`--enable-unsafe-swiftshader`,`--use-gl=swiftshader`]})}catch(e){throw new C(`${S} (launch failed: ${v(e)})`)}try{let e=await i.newPage();await e.setViewport({width:800,height:600});let t=[];e.on(`pageerror`,e=>t.push(e.message)),await N(e,r),await e.goto(A,{waitUntil:`load`});try{await e.waitForFunction(`typeof window.__shapeSheet === 'string'`,{timeout:y})}catch(e){let n=t.length>0?`the render page failed: ${t.join(`; `)}`:v(e);throw Error(n,{cause:e})}let n=await e.evaluate(`window.__shapeSheet`);if(typeof n!=`string`||!n.startsWith(`data:image/png;base64,`))throw Error(`the render page produced no image`);return n.slice(22)}finally{await i.close().catch(t=>w(e.onWarning,`chromium close failed: ${v(t)}`))}}var F=30,I=25,L=1,R=480,z=900,B=160,V=85,H=x+3e4,U=`renderShapeScript`,W="Render a ShapeScript model to a PNG image and save it, so you can LOOK at the model you wrote and check it before showing it to the user. Returns the image path — read that file to see the result. By default it renders four camera angles onto one sheet, because a single view cannot settle what is in front of what. Takes the same source as presentShapeScript: inline `script`, or `path` to a saved .shape file.",G=`Use renderShapeScript to CHECK a 3D model you wrote before presenting it — it saves a PNG and returns the path, which you then read to see what the model actually looks like. Fix what you see and re-render. Rendering needs a local headless browser; if it reports one is missing, say so and continue with presentShapeScript rather than retrying.`,K={type:`object`,properties:{script:{type:`string`,description:"ShapeScript source to render. Provide either this or `path`, not both."},path:{type:`string`,description:`Path to an existing .shape file to render (e.g. one presentShapeScript saved under artifacts/shapes/).`},azimuth:{type:`number`,description:`Camera rotation around the model in degrees, 0 = looking from +Z. Default ${F}. In the default four-view sheet this is the FIRST view's angle; the others are offset from it.`},elevation:{type:`number`,description:`Camera height in degrees above the horizon, 90 = straight down. Default ${I}. Avoid 0 and 90 for the main view — an axis-aligned shot flattens depth.`},zoom:{type:`number`,description:`Multiplier on the automatic framing, which fits the whole model. 1 = fit (default), 2 = twice as close, 0.5 = further out. Prefer this over guessing a camera distance: it means the same thing at any model scale.`},views:{type:`string`,enum:[`quad`,`single`],description:"`quad` (default) renders four angles on one sheet — use it to judge shape and layout. `single` renders only `azimuth`/`elevation`, for a close look at one detail."},projection:{type:`string`,enum:[`perspective`,`orthographic`],description:"`perspective` (default) looks natural; `orthographic` keeps parallel edges parallel, which is better for comparing proportions."},width:{type:`number`,description:`Pixel width of ONE view. Default ${R}, clamped to ${B}–${z}.`},height:{type:`number`,description:`Pixel height of ONE view. Default ${R}, clamped to ${B}–${z}.`}},required:[]};function q(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(z,Math.max(B,Math.round(e)))}function J(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}var Y=e=>`${Math.round(e)}°`;function X(e,t,n){let r=(e,t,n)=>({azimuth:e,elevation:t,label:`${n} — az ${Y(e)}, el ${Y(t)}`});return n?[r(e,t,`view`)]:[r(e,t,`front-right`),r(e+90,t,`back-right`),r(e+180,t,`back-left`),r(e,V,`top`)]}async function Z(e,t){let n=typeof t.script==`string`&&t.script.trim()!==``?t.script:void 0,r=typeof t.path==`string`&&t.path.trim()!==``?t.path:void 0;if(n&&r)throw Error("Provide either `script` or `path`, not both");if(n)return n;if(r)return e.readShape(r);throw Error("Provide either `script` (inline source) or `path` (an existing .shape file)")}function Q(e,t,n,r){return{script:t,views:n,width:q(e.width,R),height:q(e.height,R),zoom:Math.max(J(e.zoom,L),.01),projection:e.projection===`orthographic`?`orthographic`:`perspective`,...r?{onWarning:r}:{}}}function $(e,t){let n=t.map(e=>e.label).join(`; `);return`Saved render to ${e} (${t.length===1?`1 view`:`${t.length} views`}: ${n}). Read that file to see the model.`}async function ne(e,t){let n=await Z(e,t),r=X(J(t.azimuth,F),J(t.elevation,I),t.views===`single`);try{let i=await P(Q(t,n,r,e.onWarning));return{message:$(await e.saveImage(i),r),rendered:!0}}catch(t){if(t instanceof C)return w(e.onWarning,`renderShapeScript: unavailable — ${t.message}`),{message:t.message,rendered:!1};throw t}}exports.CHROMIUM_HINT=S,exports.LAUNCH_TIMEOUT_MS=b,exports.RENDER_BUDGET_MS=x,exports.RENDER_SHAPE_SCRIPT_DESCRIPTION=W,exports.RENDER_SHAPE_SCRIPT_PROMPT=G,exports.RENDER_SHAPE_SCRIPT_SCHEMA=K,exports.RENDER_SHAPE_SCRIPT_TOOL_NAME=U,exports.RENDER_TIMEOUT_MS=y,exports.RENDER_TOOL_TIMEOUT_MS=H,exports.RenderUnavailableError=C,exports.buildRenderPage=g,exports.executeRenderShapeScript=ne,exports.gridFor=p,exports.renderOptionsFrom=Q,exports.renderShapeScriptSheet=P,exports.savedMessage=$,exports.viewAngles=X;
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as e, r as t, s as n } from "./toThreeJS-BKTWUGi8.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";
|
|
@@ -95,13 +95,13 @@ function y() {
|
|
|
95
95
|
throw Error("shapescript render: cannot locate this module to resolve three from");
|
|
96
96
|
}
|
|
97
97
|
var b = i(y());
|
|
98
|
-
function x(
|
|
99
|
-
return
|
|
98
|
+
function x(t) {
|
|
99
|
+
return e(t) && typeof t.launch == "function";
|
|
100
100
|
}
|
|
101
101
|
async function S() {
|
|
102
102
|
try {
|
|
103
|
-
let
|
|
104
|
-
return x(
|
|
103
|
+
let t = await import("puppeteer");
|
|
104
|
+
return x(t) ? t : e(t) && x(t.default) ? t.default : null;
|
|
105
105
|
} catch {
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
@@ -149,11 +149,11 @@ async function k(e, t) {
|
|
|
149
149
|
})();
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
-
async function A(
|
|
152
|
+
async function A(e) {
|
|
153
153
|
let r = await S();
|
|
154
154
|
if (!r) throw new _(g);
|
|
155
|
-
let i =
|
|
156
|
-
...
|
|
155
|
+
let i = t(n(e.script)).toJSON(), a = u({
|
|
156
|
+
...e,
|
|
157
157
|
threeUrl: D,
|
|
158
158
|
sceneJson: i
|
|
159
159
|
}), o;
|
|
@@ -184,7 +184,7 @@ async function A(n) {
|
|
|
184
184
|
if (typeof n != "string" || !n.startsWith("data:image/png;base64,")) throw Error("the render page produced no image");
|
|
185
185
|
return n.slice(22);
|
|
186
186
|
} finally {
|
|
187
|
-
await o.close().catch((
|
|
187
|
+
await o.close().catch((t) => v(e.onWarning, `chromium close failed: ${f(t)}`));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./toThreeJS-
|
|
1
|
+
const e=require("./toThreeJS-CcjI8USA.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
|
|
|
@@ -63,8 +63,8 @@ arguments with spaces; commas also work here (max(0, j - 1)) but NOT in the upst
|
|
|
63
63
|
Inside a larger expression parenthesise a bare call: (sqrt 9) + (sqrt 16).
|
|
64
64
|
Custom functions: define hyp(a b) { sqrt(a * a + b * b) } — parameters, optional defines, then the result
|
|
65
65
|
expression. A function may also build shapes: define face(data) { polygon { … } } returns what it built.
|
|
66
|
-
Write ONE statement per line
|
|
67
|
-
|
|
66
|
+
Write ONE statement per line: "define a 1 define b 2" on one line is a parse error here, as in the upstream
|
|
67
|
+
app, where "size 2 1 radius 0.5" reads radius as a fourth size component.
|
|
68
68
|
|
|
69
69
|
Examples:
|
|
70
70
|
for i in 1 to 8 {
|
|
@@ -111,7 +111,7 @@ A bare path draws as a LINE (stroke), as upstream; use fill / extrude / lathe /
|
|
|
111
111
|
- arc { angle A } inside a path: A half-turns clockwise from +Y, radius size/2 (default 0.5), with optional
|
|
112
112
|
position / orientation / size — e.g. two quarter arcs and two points make a rounded slab.
|
|
113
113
|
- 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.
|
|
114
|
-
- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation
|
|
114
|
+
- A path may carry position / orientation / size of its own (path { position 0 0 2 … } with orientation and points on their own lines); 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.
|
|
115
115
|
- rotate (half-turns) / translate / scale inside a path move the frame for later points:
|
|
116
116
|
path {
|
|
117
117
|
for 0 to 8 {
|
|
@@ -166,12 +166,20 @@ Loft sections must each have one perimeter and enclose an area; extrude/fill pri
|
|
|
166
166
|
An extrude path is a solid only when it is closed (its last point repeats its first); an open path extrudes
|
|
167
167
|
to a wall, as upstream. inset(mesh distance) moves a mesh value's faces inward (outward when negative).
|
|
168
168
|
A material command inside a builder block (extrude { color red … }) colours the result; size on a builder or
|
|
169
|
-
group scales it. Not supported: extrude twist, svgpath
|
|
170
|
-
-
|
|
171
|
-
|
|
169
|
+
group scales it. Not supported: extrude twist, svgpath.
|
|
170
|
+
- text "Hello" / text { size 0.5 … } with wrapwidth, linespacing and each "line" on its own line: glyph outlines in the built-in
|
|
171
|
+
Helvetica-like font, left margin at x 0 and first baseline at y 0, one unit per line (size scales it). Bare text draws
|
|
172
|
+
outlines; fill text "Hi" makes faces and extrude { size 1 1 0.3 text "Hi" } solids. Values interpolate:
|
|
173
|
+
text "Bob has " apples " apples", text i. Centre it with its bounds: define t text "Hi" then
|
|
174
|
+
translate -t.bounds.width/2 -t.bounds.height/2 before fill t. font is accepted and ignored (one face only).
|
|
175
|
+
- mesh { polygon { point x y z … } … }: a mesh from explicit faces; polygon { color red … point a … }
|
|
176
|
+
(one point per line) takes 3D points (a tuple works: point v) and a colour per face. Faces may come from a function: mesh { for f in faces { face f } }.
|
|
172
177
|
|
|
173
178
|
### Additional Expressions:
|
|
174
|
-
- Constants: pi, true, false (
|
|
179
|
+
- Constants: pi, true, false (there is no tau; write 2 * pi)
|
|
180
|
+
- ONE STATEMENT PER LINE, as in the upstream app: sphere { position 0 1 0 size 2 } is refused (upstream reads it as a
|
|
181
|
+
position with five arguments). Put each property, point and shape on its own line; a block may open on its
|
|
182
|
+
statement's line and close on its own.
|
|
175
183
|
- A lone position / translate value is X alone (position 1 = 1 0 0); a lone size is uniform; a lone orientation is a roll.
|
|
176
184
|
- Scientific notation and unary plus: 1e-3, +2
|
|
177
185
|
- Ranges as values: define loops 1 to 5 step 2, then for i in loops { … }, for i in loops step 1, and
|
|
@@ -196,8 +204,8 @@ post { height 3 }
|
|
|
196
204
|
### Compatibility:
|
|
197
205
|
This plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units, scoping,
|
|
198
206
|
materials and path semantics follow upstream, so a script written against the upstream docs renders the
|
|
199
|
-
same here. Not supported (each is refused by name): import,
|
|
200
|
-
object values and paths as values. Textures, cameras and lights are accepted but not drawn.
|
|
207
|
+
same here. Not supported (each is refused by name): import, svgpath, extrude twist,
|
|
208
|
+
object values and paths as values. Textures, fonts, cameras and lights are accepted but not drawn.
|
|
201
209
|
|
|
202
210
|
### Comments:
|
|
203
211
|
// Single-line comment
|
|
@@ -255,7 +263,7 @@ for x in -5 to 5 {
|
|
|
255
263
|
}
|
|
256
264
|
}`},path:{type:`string`,description:"Path to an EXISTING ShapeScript source to present in place, instead of `script` — a `.shape` file this tool saved earlier (`artifacts/shapes/…`) or any other on disk. Provide either `script` or `path`, never both. Edits the user makes in the view write back to that same file."}},required:[`title`]}},i=`shapes`,a=`shape`,o=[`.shape`];function s(e,n=a){return(0,t.slugifyArtifact)(e,n)}function c(){let e=globalThis.crypto;if(e?.getRandomValues){let t=e.getRandomValues(new Uint8Array(4));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(16).slice(2,10).padEnd(8,`0`)}function l(e,n=new Date,r=c()){let o=(0,t.buildArtifactRelPath)({dir:i,title:e,ext:`.shape`,fallback:a,now:n,partitioned:!1,suffix:r});return{relPath:o,filePath:(0,t.toWorkspaceArtifactPath)(o)}}function u(e,n=new Date,r=c()){let o=(0,t.buildArtifactRelPath)({dir:i,title:e,ext:`.usdz`,fallback:a,now:n,partitioned:!1,suffix:r});return{relPath:o,filePath:(0,t.toWorkspaceArtifactPath)(o)}}function d(e){return!e.startsWith(`${t.ARTIFACTS_ROOT}/${i}/`)||!e.endsWith(`.shape`)?!1:!(0,t.hasUnsafePathSegment)(e)}function f(e){return e.startsWith(`${t.ARTIFACTS_ROOT}/`)?e.slice(t.ARTIFACTS_ROOT.length+1):e}function p(e){return(0,t.classifyFilePath)(e,o)!==null}function m(e,t){if(d(t))return{files:e.files.artifacts,rel:f(t)};let n=e.files.byPath;return n&&p(t)?{files:n,rel:t}:null}async function h(e,t){if(typeof t?.path!=`string`)throw Error(`path must be an existing .shape file`);let n=m(e,t.path);if(!n)throw Error(`path must be an existing .shape file`);switch(t.kind){case`loadShape`:return{script:await n.files.read(n.rel)};case`saveShape`:if(typeof t.script!=`string`)throw Error("saveShape requires `script` as a string");if(!await n.files.exists(n.rel))throw Error(`No ShapeScript exists at ${t.path}`);return await n.files.write(n.rel,t.script),{path:t.path};default:throw Error(`shapescript plugin: unknown dispatch kind ${JSON.stringify(t)}`)}}var g=`Acknowledge that the 3D visualization has been created and is displayed to the user. They can rotate, zoom, and pan the camera.`,_=e=>typeof e==`string`&&e.trim()!==``;function v(t){let n=e.r(e.s(t)),r=e.i(n);return e.a(n),r}function y(e){let t=[];return e.warnings.length&&t.push(`Not rendered: ${e.warnings.join(`; `)}`),e.logs.length&&t.push(`Output:\n${e.logs.join(`
|
|
257
265
|
`)}`),t.length?`\n${t.join(`
|
|
258
|
-
`)}`:``}async function b(e,t){let n=e.files;if(!n)throw Error("This host cannot open a ShapeScript by path — pass the source as `script` instead");let r=m({files:n},t);if(!r)throw Error("`path` must be a .shape file, without `.` / `..` segments");if(!await r.files.exists(r.rel))throw Error(`No ShapeScript exists at ${t}`);return r.files.read(r.rel)}var x=5;async function S(e,t,n){let r=e.files?.artifacts;if(r){for(let e=0;e<x;e++){let{relPath:e,filePath:i}=l(n);if(!await r.exists(e))return await r.write(e,t),i}throw Error(`Could not allocate a free path under artifacts/shapes — try again with a different title`)}}async function C(e,t){if(_(t.path)&&_(t.script))throw Error("Provide either `script` or `path`, not both");if(_(t.path))return{script:await b(e,t.path),filePath:t.path};if(!_(t.script))throw Error(`ShapeScript code is required but was not provided`);return{script:t.script}}var w=async(t,n)=>{let r=`INVALID_ARGUMENT`;try{if(!e.zn(n))throw Error("presentShapeScript args must be an object with `script` or `path`");if(!_(n.title))throw Error(`A nonempty visualization title is required`);let i=await C(t??{},n);r=`EVALUATION_ERROR`;let a=v(i.script),o=i.filePath??await S(t??{},i.script,n.title);return{message:(o?`Saved ShapeScript to ${o}`:`Created 3D visualization: ${n.title}`)+y(a),title:n.title,data:o?{script:i.script,filePath:o}:{script:i.script},instructions:g}}catch(t){let n={code:t instanceof e.Rn?`PARSE_ERROR`:t instanceof e.n?`LIMIT_EXCEEDED`:r,message:t instanceof Error?t.message:String(t),...t instanceof e.Rn&&t.line!==void 0?{line:t.line}:{},...t instanceof e.Rn&&t.column!==void 0?{column:t.column}:{}};return{message:`ShapeScript error: ${n.message}`,error:n,jsonData:{error:n},instructions:`The visualization was not created. Correct the ShapeScript using the returned diagnostic and call presentShapeScript again.`}}},T={toolDefinition:r,execute:w,generatingMessage:`Creating 3D visualization...`,waitingMessage:`Tell the user that the 3D visualization was created and will be presented shortly.`,isEnabled:()=>!0},E=w,D=Uint8Array,O=Uint16Array,k=Int32Array,ee=new D([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),te=new D([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),A=new D([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),j=function(e,t){for(var n=new O(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new k(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},M=j(ee,2),N=M.b,P=M.r;N[28]=258,P[258]=28;var F=j(te,0);F.b;for(var I=F.r,L=new O(32768),R=0;R<32768;++R){var z=(R&43690)>>1|(R&21845)<<1;z=(z&52428)>>2|(z&13107)<<2,z=(z&61680)>>4|(z&3855)<<4,L[R]=((z&65280)>>8|(z&255)<<8)>>1}for(var B=(function(e,t,n){for(var r=e.length,i=0,a=new O(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new O(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new O(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[L[d]>>c]=l}else for(s=new O(r),i=0;i<r;++i)e[i]&&(s[i]=L[o[e[i]-1]++]>>15-e[i]);return s}),V=new D(288),R=0;R<144;++R)V[R]=8;for(var R=144;R<256;++R)V[R]=9;for(var R=256;R<280;++R)V[R]=7;for(var R=280;R<288;++R)V[R]=8;for(var H=new D(32),R=0;R<32;++R)H[R]=5;var ne=B(V,9,0),re=B(H,5,0),ie=function(e){return(e+7)/8|0},U=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new D(e.subarray(t,n))},W=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],G=function(e,t,n){var r=Error(t||W[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,G),!n)throw r;return r},K=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},q=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},J=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:le,l:0};if(i==1){var o=new D(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new O(f+1),m=Y(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new D(p),l:m}},Y=function(e,t,n){return e.s==-1?Math.max(Y(e.l,t,n+1),Y(e.r,t,n+1)):t[e.s]=n},ae=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new O(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},X=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},oe=function(e,t,n){var r=n.length,i=ie(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},se=function(e,t,n,r,i,a,o,s,c,l,u){K(t,u++,n),++i[256];for(var d=J(i,15),f=d.t,p=d.l,m=J(a,15),h=m.t,g=m.l,_=ae(f),v=_.c,y=_.n,b=ae(h),x=b.c,S=b.n,C=new O(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=J(C,7),E=T.t,D=T.l,k=19;k>4&&!E[A[k-1]];--k);var j=l+5<<3,M=X(i,V)+X(a,H)+o,N=X(i,f)+X(a,h)+o+14+3*k+X(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&j<=M&&j<=N)return oe(t,u,e.subarray(c,c+l));var P,F,I,L;if(K(t,u,1+(N<M)),u+=2,N<M){P=B(f,p,0),F=f,I=B(h,g,0),L=h;var R=B(E,D,0);K(t,u,y-257),K(t,u+5,S-1),K(t,u+10,k-4),u+=14;for(var w=0;w<k;++w)K(t,u+3*w,E[A[w]]);u+=3*k;for(var z=[v,x],ie=0;ie<2;++ie)for(var U=z[ie],w=0;w<U.length;++w){var W=U[w]&31;K(t,u,R[W]),u+=E[W],W>15&&(K(t,u,U[w]>>5&127),u+=U[w]>>12)}}else P=ne,F=V,I=re,L=H;for(var w=0;w<s;++w){var G=r[w];if(G>255){var W=G>>18&31;q(t,u,P[W+257]),u+=F[W+257],W>7&&(K(t,u,G>>23&31),u+=ee[W]);var Y=G&31;q(t,u,I[Y]),u+=L[Y],Y>3&&(q(t,u,G>>5&8191),u+=te[Y])}else q(t,u,P[G]),u+=F[G]}return q(t,u,P[256]),u+F[256]},ce=new k([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),le=new D(0),ue=function(e,t,n,r,i,a){var o=a.z||e.length,s=new D(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=ce[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new O(32768),g=a.h||new O(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new k(25e3),x=new O(288),S=new O(32),C=0,w=0,T=a.i||0,E=0,A=a.w||0,j=0;T+2<o;++T){var M=y(T),N=T&32767,F=g[M];if(h[N]=F,g[M]=N,A<=T){var L=o-T;if((C>7e3||E>24576)&&(L>423||!l)){u=se(e,c,0,b,x,S,w,E,j,T-j,u),E=C=w=0,j=T;for(var R=0;R<286;++R)x[R]=0;for(var R=0;R<30;++R)S[R]=0}var z=2,B=0,V=p,H=N-F&32767;if(L>2&&M==y(T-H))for(var ne=Math.min(f,L)-1,re=Math.min(32767,T),W=Math.min(258,L);H<=re&&--V&&N!=F;){if(e[T+z]==e[T+z-H]){for(var G=0;G<W&&e[T+G]==e[T+G-H];++G);if(G>z){if(z=G,B=H,G>ne)break;for(var K=Math.min(H,G-2),q=0,R=0;R<K;++R){var J=T-H+R&32767,Y=J-h[J]&32767;Y>q&&(q=Y,F=J)}}}N=F,F=h[N],H+=N-F&32767}if(B){b[E++]=268435456|P[z]<<18|I[B];var ae=P[z]&31,X=I[B]&31;w+=ee[ae]+te[X],++x[257+ae],++S[X],A=T+z,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,A);T<o;++T)b[E++]=e[T],++x[e[T]];u=se(e,c,l,b,x,S,w,E,j,T-j,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=A)}else{for(var T=a.w||0;T<o+l;T+=65535){var le=T+65535;le>=o&&(c[u/8|0]=l,le=o),u=oe(c,u+1,e.subarray(T,le))}a.i=o}return U(s,0,r+ie(u)+i)},de=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),fe=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=de[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},pe=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new D(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return ue(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},me=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},Z=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function he(e,t){return pe(e,t||{},0,0)}var ge=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=me(r,a[1]),a=a[0]),a instanceof D?n[o]=[a,s]:(n[o+=`/`]=[new D(0),s],ge(a,o,n,r))}},_e=typeof TextEncoder<`u`&&new TextEncoder,ve=typeof TextDecoder<`u`&&new TextDecoder;try{ve.decode(le,{stream:!0})}catch{}function ye(e,t){if(t){for(var n=new D(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(_e)return _e.encode(e);for(var i=e.length,a=new D(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new D(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return U(a,0,o)}var be=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&G(9),t+=r+4}return t},xe=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=be(l);Z(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&G(10),Z(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Z(e,t,n.crc),Z(e,t+4,a<0?-a-2:a),Z(e,t+8,n.size)),Z(e,t+12,c),Z(e,t+14,d),t+=16,o!=null&&(Z(e,t,u),Z(e,t+6,n.attrs),Z(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;Z(e,t,+m),Z(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Se=function(e,t,n,r,i){Z(e,t,101010256),Z(e,t+8,n),Z(e,t+10,n),Z(e,t+12,r),Z(e,t+16,i)};function Ce(e,t){t||={};var n={},r=[];ge(e,``,n,t);var i=0,a=0;for(var o in n){var s=n[o],c=s[0],l=s[1],u=l.level==0?0:8,d=ye(o),f=d.length,p=l.comment,m=p&&ye(p),h=m&&m.length,g=be(l.extra);f>65535&&G(11);var _=u?he(c,l):c,v=_.length,y=fe();y.p(c),r.push(me(l,{size:c.length,crc:y.d(),c:_,f:d,m,u:f!=o.length||m&&p.length!=h,o:i,compression:u})),i+=30+f+g+v,a+=76+2*(f+g)+(h||0)+v}for(var b=new D(a+22),x=i,S=a-i,C=0;C<r.length;++C){var d=r[C];xe(b,d.o,d,d.f,d.u,d.c.length);var w=30+d.f.length+be(d.extra);b.set(d.c,d.o+w),xe(b,i,d,d.f,d.u,d.c.length,d.o,d.m),i+=16+w+(d.m?d.m.length:0)}return Se(b,i,r.length,S,x),b}var Q=class{constructor(e,t=``,n=[],r=[]){this.name=e,this.type=t,this.metadata=n,this.properties=r,this.children=[]}addMetadata(e,t){this.metadata.push({key:e,value:t})}addProperty(e,t=[]){this.properties.push({property:e,metadata:t})}addChild(e){this.children.push(e)}toString(e=0){let t=` `.repeat(e),n=this.metadata.map(e=>{let n=e.key,r=e.value;if(Array.isArray(r)){let e=[];return e.push(`${n} = {`),r.forEach(n=>{e.push(`${t}\t\t${n}`)}),e.push(`${t}\t}`),e.join(`
|
|
266
|
+
`)}`:``}async function b(e,t){let n=e.files;if(!n)throw Error("This host cannot open a ShapeScript by path — pass the source as `script` instead");let r=m({files:n},t);if(!r)throw Error("`path` must be a .shape file, without `.` / `..` segments");if(!await r.files.exists(r.rel))throw Error(`No ShapeScript exists at ${t}`);return r.files.read(r.rel)}var x=5;async function S(e,t,n){let r=e.files?.artifacts;if(r){for(let e=0;e<x;e++){let{relPath:e,filePath:i}=l(n);if(!await r.exists(e))return await r.write(e,t),i}throw Error(`Could not allocate a free path under artifacts/shapes — try again with a different title`)}}async function C(e,t){if(_(t.path)&&_(t.script))throw Error("Provide either `script` or `path`, not both");if(_(t.path))return{script:await b(e,t.path),filePath:t.path};if(!_(t.script))throw Error(`ShapeScript code is required but was not provided`);return{script:t.script}}var w=async(t,n)=>{let r=`INVALID_ARGUMENT`;try{if(!e.Bn(n))throw Error("presentShapeScript args must be an object with `script` or `path`");if(!_(n.title))throw Error(`A nonempty visualization title is required`);let i=await C(t??{},n);r=`EVALUATION_ERROR`;let a=v(i.script),o=i.filePath??await S(t??{},i.script,n.title);return{message:(o?`Saved ShapeScript to ${o}`:`Created 3D visualization: ${n.title}`)+y(a),title:n.title,data:o?{script:i.script,filePath:o}:{script:i.script},instructions:g}}catch(t){let n={code:t instanceof e.zn?`PARSE_ERROR`:t instanceof e.n?`LIMIT_EXCEEDED`:r,message:t instanceof Error?t.message:String(t),...t instanceof e.zn&&t.line!==void 0?{line:t.line}:{},...t instanceof e.zn&&t.column!==void 0?{column:t.column}:{}};return{message:`ShapeScript error: ${n.message}`,error:n,jsonData:{error:n},instructions:`The visualization was not created. Correct the ShapeScript using the returned diagnostic and call presentShapeScript again.`}}},T={toolDefinition:r,execute:w,generatingMessage:`Creating 3D visualization...`,waitingMessage:`Tell the user that the 3D visualization was created and will be presented shortly.`,isEnabled:()=>!0},E=w,D=Uint8Array,O=Uint16Array,k=Int32Array,ee=new D([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),te=new D([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),A=new D([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),j=function(e,t){for(var n=new O(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new k(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},M=j(ee,2),N=M.b,P=M.r;N[28]=258,P[258]=28;var F=j(te,0);F.b;for(var ne=F.r,I=new O(32768),L=0;L<32768;++L){var R=(L&43690)>>1|(L&21845)<<1;R=(R&52428)>>2|(R&13107)<<2,R=(R&61680)>>4|(R&3855)<<4,I[L]=((R&65280)>>8|(R&255)<<8)>>1}for(var z=(function(e,t,n){for(var r=e.length,i=0,a=new O(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new O(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new O(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[I[d]>>c]=l}else for(s=new O(r),i=0;i<r;++i)e[i]&&(s[i]=I[o[e[i]-1]++]>>15-e[i]);return s}),B=new D(288),L=0;L<144;++L)B[L]=8;for(var L=144;L<256;++L)B[L]=9;for(var L=256;L<280;++L)B[L]=7;for(var L=280;L<288;++L)B[L]=8;for(var V=new D(32),L=0;L<32;++L)V[L]=5;var re=z(B,9,0),ie=z(V,5,0),ae=function(e){return(e+7)/8|0},H=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new D(e.subarray(t,n))},U=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],W=function(e,t,n){var r=Error(t||U[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,W),!n)throw r;return r},G=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},K=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},q=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:X,l:0};if(i==1){var o=new D(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new O(f+1),m=J(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new D(p),l:m}},J=function(e,t,n){return e.s==-1?Math.max(J(e.l,t,n+1),J(e.r,t,n+1)):t[e.s]=n},oe=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new O(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Y=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},se=function(e,t,n){var r=n.length,i=ae(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},ce=function(e,t,n,r,i,a,o,s,c,l,u){G(t,u++,n),++i[256];for(var d=q(i,15),f=d.t,p=d.l,m=q(a,15),h=m.t,g=m.l,_=oe(f),v=_.c,y=_.n,b=oe(h),x=b.c,S=b.n,C=new O(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=q(C,7),E=T.t,D=T.l,k=19;k>4&&!E[A[k-1]];--k);var j=l+5<<3,M=Y(i,B)+Y(a,V)+o,N=Y(i,f)+Y(a,h)+o+14+3*k+Y(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&j<=M&&j<=N)return se(t,u,e.subarray(c,c+l));var P,F,ne,I;if(G(t,u,1+(N<M)),u+=2,N<M){P=z(f,p,0),F=f,ne=z(h,g,0),I=h;var L=z(E,D,0);G(t,u,y-257),G(t,u+5,S-1),G(t,u+10,k-4),u+=14;for(var w=0;w<k;++w)G(t,u+3*w,E[A[w]]);u+=3*k;for(var R=[v,x],ae=0;ae<2;++ae)for(var H=R[ae],w=0;w<H.length;++w){var U=H[w]&31;G(t,u,L[U]),u+=E[U],U>15&&(G(t,u,H[w]>>5&127),u+=H[w]>>12)}}else P=re,F=B,ne=ie,I=V;for(var w=0;w<s;++w){var W=r[w];if(W>255){var U=W>>18&31;K(t,u,P[U+257]),u+=F[U+257],U>7&&(G(t,u,W>>23&31),u+=ee[U]);var J=W&31;K(t,u,ne[J]),u+=I[J],J>3&&(K(t,u,W>>5&8191),u+=te[J])}else K(t,u,P[W]),u+=F[W]}return K(t,u,P[256]),u+F[256]},le=new k([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),X=new D(0),ue=function(e,t,n,r,i,a){var o=a.z||e.length,s=new D(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=le[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new O(32768),g=a.h||new O(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new k(25e3),x=new O(288),S=new O(32),C=0,w=0,T=a.i||0,E=0,A=a.w||0,j=0;T+2<o;++T){var M=y(T),N=T&32767,F=g[M];if(h[N]=F,g[M]=N,A<=T){var I=o-T;if((C>7e3||E>24576)&&(I>423||!l)){u=ce(e,c,0,b,x,S,w,E,j,T-j,u),E=C=w=0,j=T;for(var L=0;L<286;++L)x[L]=0;for(var L=0;L<30;++L)S[L]=0}var R=2,z=0,B=p,V=N-F&32767;if(I>2&&M==y(T-V))for(var re=Math.min(f,I)-1,ie=Math.min(32767,T),U=Math.min(258,I);V<=ie&&--B&&N!=F;){if(e[T+R]==e[T+R-V]){for(var W=0;W<U&&e[T+W]==e[T+W-V];++W);if(W>R){if(R=W,z=V,W>re)break;for(var G=Math.min(V,W-2),K=0,L=0;L<G;++L){var q=T-V+L&32767,J=q-h[q]&32767;J>K&&(K=J,F=q)}}}N=F,F=h[N],V+=N-F&32767}if(z){b[E++]=268435456|P[R]<<18|ne[z];var oe=P[R]&31,Y=ne[z]&31;w+=ee[oe]+te[Y],++x[257+oe],++S[Y],A=T+R,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,A);T<o;++T)b[E++]=e[T],++x[e[T]];u=ce(e,c,l,b,x,S,w,E,j,T-j,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=A)}else{for(var T=a.w||0;T<o+l;T+=65535){var X=T+65535;X>=o&&(c[u/8|0]=l,X=o),u=se(c,u+1,e.subarray(T,X))}a.i=o}return H(s,0,r+ae(u)+i)},de=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),fe=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=de[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},pe=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new D(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return ue(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},me=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},Z=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function he(e,t){return pe(e,t||{},0,0)}var ge=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=me(r,a[1]),a=a[0]),a instanceof D?n[o]=[a,s]:(n[o+=`/`]=[new D(0),s],ge(a,o,n,r))}},_e=typeof TextEncoder<`u`&&new TextEncoder,ve=typeof TextDecoder<`u`&&new TextDecoder;try{ve.decode(X,{stream:!0})}catch{}function ye(e,t){if(t){for(var n=new D(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(_e)return _e.encode(e);for(var i=e.length,a=new D(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new D(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return H(a,0,o)}var be=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&W(9),t+=r+4}return t},xe=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=be(l);Z(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&W(10),Z(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Z(e,t,n.crc),Z(e,t+4,a<0?-a-2:a),Z(e,t+8,n.size)),Z(e,t+12,c),Z(e,t+14,d),t+=16,o!=null&&(Z(e,t,u),Z(e,t+6,n.attrs),Z(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;Z(e,t,+m),Z(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Se=function(e,t,n,r,i){Z(e,t,101010256),Z(e,t+8,n),Z(e,t+10,n),Z(e,t+12,r),Z(e,t+16,i)};function Ce(e,t){t||={};var n={},r=[];ge(e,``,n,t);var i=0,a=0;for(var o in n){var s=n[o],c=s[0],l=s[1],u=l.level==0?0:8,d=ye(o),f=d.length,p=l.comment,m=p&&ye(p),h=m&&m.length,g=be(l.extra);f>65535&&W(11);var _=u?he(c,l):c,v=_.length,y=fe();y.p(c),r.push(me(l,{size:c.length,crc:y.d(),c:_,f:d,m,u:f!=o.length||m&&p.length!=h,o:i,compression:u})),i+=30+f+g+v,a+=76+2*(f+g)+(h||0)+v}for(var b=new D(a+22),x=i,S=a-i,C=0;C<r.length;++C){var d=r[C];xe(b,d.o,d,d.f,d.u,d.c.length);var w=30+d.f.length+be(d.extra);b.set(d.c,d.o+w),xe(b,i,d,d.f,d.u,d.c.length,d.o,d.m),i+=16+w+(d.m?d.m.length:0)}return Se(b,i,r.length,S,x),b}var Q=class{constructor(e,t=``,n=[],r=[]){this.name=e,this.type=t,this.metadata=n,this.properties=r,this.children=[]}addMetadata(e,t){this.metadata.push({key:e,value:t})}addProperty(e,t=[]){this.properties.push({property:e,metadata:t})}addChild(e){this.children.push(e)}toString(e=0){let t=` `.repeat(e),n=this.metadata.map(e=>{let n=e.key,r=e.value;if(Array.isArray(r)){let e=[];return e.push(`${n} = {`),r.forEach(n=>{e.push(`${t}\t\t${n}`)}),e.push(`${t}\t}`),e.join(`
|
|
259
267
|
`)}return`${n} = ${r}`}),r=n.length?` (\n${n.map(e=>`${t}\t${e}`).join(`
|
|
260
268
|
`)}\n${t})`:``,i=this.properties.map(e=>{let n=e.property.replace(/\n/g,`
|
|
261
269
|
`+t+` `),r=e.metadata.length?` (\n${e.metadata.map(e=>`${t}\t\t${e}`).join(`
|
|
@@ -276,13 +284,25 @@ for x in -5 to 5 {
|
|
|
276
284
|
timeCodesPerSecond = ${e.fps}
|
|
277
285
|
framesPerSecond = ${e.fps}`:``}
|
|
278
286
|
)
|
|
279
|
-
`}function ke(t,n){let r=new Map;for(let i=0;i<n.length;i++){let a=n[i];for(let n=0;n<a.tracks.length;n++){let i=a.tracks[n],o=e.
|
|
287
|
+
`}function ke(t,n){let r=new Map;for(let i=0;i<n.length;i++){let a=n[i];for(let n=0;n<a.tracks.length;n++){let i=a.tracks[n],o=e.st.parseTrackName(i.name),s=e.st.findNode(t,o.nodeName);if(s==null)continue;let c=o.propertyName;if(c!==`position`&&c!==`quaternion`&&c!==`scale`)continue;let l=r.get(s);l===void 0&&(l={},r.set(s,l)),l[c]=i}}return r}function Ae(e){let t=0;for(let n=0;n<e.length;n++)e[n].duration>t&&(t=e[n].duration);return t}function je(e,t,n,r){let i=n.times,a=n.values,o=[];for(let e=0;e<i.length;e++){let t=e*3;o.push(`${(i[e]*r).toPrecision($)}: (${a[t].toPrecision($)}, ${a[t+1].toPrecision($)}, ${a[t+2].toPrecision($)})`)}return`${t} ${e}.timeSamples = {\n\t${o.join(`,
|
|
280
288
|
`)},\n}`}function Me(e,t){let n=e.times,r=e.values,i=[];for(let e=0;e<n.length;e++){let a=e*4;i.push(`${(n[e]*t).toPrecision($)}: (${r[a+3].toPrecision($)}, ${r[a].toPrecision($)}, ${r[a+1].toPrecision($)}, ${r[a+2].toPrecision($)})`)}return`quatf xformOp:orient.timeSamples = {\n\t${i.join(`,
|
|
281
289
|
`)},\n}`}function Ne(e,t,n,r,i,a){for(let o=0,s=e.children.length;o<s;o++)Pe(e.children[o],t,n,r,i,a)}function Pe(e,t,n,r,i,a){if(e.visible===!1&&a.onlyVisible===!0)return;let o;if(e.isMesh){let t=e.geometry,s=Array.isArray(e.material),c=s?e.material:[e.material];for(let e=0;e<c.length;e++){let t=c[e];t.isMeshStandardMaterial||console.warn(`THREE.USDZExporter: Use MeshStandardMaterial for best results.`),t.uuid in n||(n[t.uuid]=t)}let l=c.map(e=>n[e.uuid]);if(s===!1){let e=`geometries/Geometry_${t.id}.usda`;if(!(e in i)){let n=Be(t);i[e]=ye(Oe()+`
|
|
282
|
-
`+n.toString())}}o=Le(e,t,l,r,a)}else o=e.isCamera?Ze(e,r,a):Ie(e,r,a);t.addChild(o),Ne(e,o,n,r,i,a)}function Fe(e,t,n){let r=n.animationTracks.get(t),i=t.pivot!==null;if(!i&&r===void 0){let n=Re(t.matrix);e.addProperty(`matrix4d xformOp:transform = ${n}`),e.addProperty(`uniform token[] xformOpOrder = ["xformOp:transform"]`);return}let a=n.animationFrameRate,o=t.position,s=t.quaternion,c=t.scale;if(r!==void 0&&r.position!==void 0?e.addProperty(je(`xformOp:translate`,`float3`,r.position,a)):e.addProperty(`float3 xformOp:translate = (${o.x.toPrecision($)}, ${o.y.toPrecision($)}, ${o.z.toPrecision($)})`),i){let n=t.pivot;e.addProperty(`float3 xformOp:translate:pivot = (${n.x.toPrecision($)}, ${n.y.toPrecision($)}, ${n.z.toPrecision($)})`)}r!==void 0&&r.quaternion!==void 0?e.addProperty(Me(r.quaternion,a)):e.addProperty(`quatf xformOp:orient = (${s.w.toPrecision($)}, ${s.x.toPrecision($)}, ${s.y.toPrecision($)}, ${s.z.toPrecision($)})`),r!==void 0&&r.scale!==void 0?e.addProperty(je(`xformOp:scale`,`float3`,r.scale,a)):e.addProperty(`float3 xformOp:scale = (${c.x.toPrecision($)}, ${c.y.toPrecision($)}, ${c.z.toPrecision($)})`),i?e.addProperty(`uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]`):e.addProperty(`uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]`)}function Ie(e,t,n){let r=Te(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Xform`);return Fe(i,e,n),i}function Le(e,t,n,r,i){let a=Ie(e,r,i);return n.length===1?(a.addMetadata(`prepend references`,`@./geometries/Geometry_${t.id}.usda@</Geometry>`),a.addMetadata(`prepend apiSchemas`,`["MaterialBindingAPI"]`),a.addProperty(`rel material:binding = </Materials/Material_${n[0].id}>`)):a.addChild(Ve(t,n)),a}function Re(e){let t=e.elements;return`( ${ze(t,0)}, ${ze(t,4)}, ${ze(t,8)}, ${ze(t,12)} )`}function ze(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function Be(e){let t=new Q(`Geometry`),n=Ve(e);return t.addChild(n),t}function Ve(e,t=null){let n=e.attributes,r=n.position.count,i=new Q(`Geometry`,`Mesh`);i.addProperty(`int[] faceVertexCounts = [${He(e)}]`),i.addProperty(`int[] faceVertexIndices = [${Ue(e)}]`),i.addProperty(`normal3f[] normals = [${We(n.normal,r)}]`,[`interpolation = "vertex"`]),i.addProperty(`point3f[] points = [${We(n.position,r)}]`);for(let e=0;e<4;e++){let t=e>0?e:``,r=n[`uv`+t];r!==void 0&&i.addProperty(`texCoord2f[] primvars:st${t} = [${Ge(r)}]`,[`interpolation = "vertex"`])}let a=n.color;if(a!==void 0&&i.addProperty(`color3f[] primvars:displayColor = [${We(a,r)}]`,[`interpolation = "vertex"`]),i.addProperty(`uniform token subdivisionScheme = "none"`),t!==null){let r=e.groups,a=(e.index===null?n.position.count:e.index.count)/3;for(let e=0;e<r.length;e++){let n=r[e],o=t[n.materialIndex];if(o===void 0)continue;let s=Math.floor(n.start/3),c=Math.min(s+Math.floor(n.count/3),a),l=[];for(let e=s;e<c;e++)l.push(e);let u=new Q(`subset_${e}`,`GeomSubset`);u.addMetadata(`prepend apiSchemas`,`["MaterialBindingAPI"]`),u.addProperty(`uniform token elementType = "face"`),u.addProperty(`uniform token familyName = "materialBind"`),u.addProperty(`int[] indices = [${l.join(`, `)}]`),u.addProperty(`rel material:binding = </Materials/Material_${o.id}>`),i.addChild(u)}}return i}function He(e){let t=e.index===null?e.attributes.position.count:e.index.count;return Array(t/3).fill(3).join(`, `)}function Ue(e){let t=e.index,n=[];if(t!==null)for(let e=0;e<t.count;e++)n.push(t.getX(e));else{let t=e.attributes.position.count;for(let e=0;e<t;e++)n.push(e)}return n.join(`, `)}function We(e,t){if(e===void 0)return console.warn(`USDZExporter: Normals missing.`),Array(t).fill(`(0, 0, 0)`).join(`, `);let n=[];for(let t=0;t<e.count;t++){let r=e.getX(t),i=e.getY(t),a=e.getZ(t);n.push(`(${r.toPrecision($)}, ${i.toPrecision($)}, ${a.toPrecision($)})`)}return n.join(`, `)}function Ge(e){let t=[];for(let n=0;n<e.count;n++){let r=e.getX(n),i=e.getY(n);t.push(`(${r.toPrecision($)}, ${1-i.toPrecision($)})`)}return t.join(`, `)}function Ke(e,t,n=!1){let r=new Q(`Materials`);for(let i in e){let a=e[i];r.addChild(qe(a,t,n))}return r}function qe(t,n,r=!1){let i=new Q(`Material_${t.id}`,`Material`);function a(e,i,a){let o=e.source.id+`_`+e.flipY;n[o]=e;let s=e.channel>0?`st`+e.channel:`st`,c={1e3:`repeat`,1001:`clamp`,1002:`mirror`},l=e.repeat.clone(),u=e.offset.clone(),d=e.rotation,f=Math.sin(d),p=Math.cos(d);u.y=1-u.y-l.y,r?(u.x/=l.x,u.y/=l.y,u.x+=f/l.x,u.y+=p-1):(u.x+=f*l.x,u.y+=(1-p)*l.y);let m=new Q(`PrimvarReader_${i}`,`Shader`);m.addProperty(`uniform token info:id = "UsdPrimvarReader_float2"`),m.addProperty(`float2 inputs:fallback = (0.0, 0.0)`),m.addProperty(`string inputs:varname = "${s}"`),m.addProperty(`float2 outputs:result`);let h=new Q(`Transform2d_${i}`,`Shader`);h.addProperty(`uniform token info:id = "UsdTransform2d"`),h.addProperty(`float2 inputs:in.connect = </Materials/Material_${t.id}/PrimvarReader_${i}.outputs:result>`),h.addProperty(`float inputs:rotation = ${(180/Math.PI*d).toFixed($)}`),h.addProperty(`float2 inputs:scale = ${Xe(l)}`),h.addProperty(`float2 inputs:translation = ${Xe(u)}`),h.addProperty(`float2 outputs:result`);let g=new Q(`Texture_${e.id}_${i}`,`Shader`);if(g.addProperty(`uniform token info:id = "UsdUVTexture"`),g.addProperty(`asset inputs:file = @textures/Texture_${o}.${Ee(e)}@`),g.addProperty(`float2 inputs:st.connect = </Materials/Material_${t.id}/Transform2d_${i}.outputs:result>`),a!==void 0){let e=i===`diffuse`?t.opacity:1;g.addProperty(`float4 inputs:scale = ${Ye(a,e)}`)}if(i===`normal`){let e=t.normalScale.x;g.addProperty(`float4 inputs:scale = (${2*e}, ${2*e}, 2, 1)`),g.addProperty(`float4 inputs:bias = (${-e}, ${-e}, -1, 0)`)}return g.addProperty(`token inputs:sourceColorSpace = "${e.colorSpace===``?`raw`:`sRGB`}"`),g.addProperty(`token inputs:wrapS = "${c[e.wrapS]}"`),g.addProperty(`token inputs:wrapT = "${c[e.wrapT]}"`),g.addProperty(`float outputs:r`),g.addProperty(`float outputs:g`),g.addProperty(`float outputs:b`),g.addProperty(`float3 outputs:rgb`),(t.transparent||t.alphaTest>0)&&g.addProperty(`float outputs:a`),[m,h,g]}t.side===2&&console.warn(`THREE.USDZExporter: USDZ does not support double sided materials`,t);let o=new Q(`PreviewSurface`,`Shader`);if(o.addProperty(`uniform token info:id = "UsdPreviewSurface"`),t.map===null?o.addProperty(`color3f inputs:diffuseColor = ${Je(t.color)}`):(o.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:rgb>`),t.transparent?o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`):t.alphaTest>0&&(o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`),o.addProperty(`float inputs:opacityThreshold = ${t.alphaTest}`)),a(t.map,`diffuse`,t.color).forEach(e=>i.addChild(e))),t.emissive){let n=t.emissiveIntensity??1;if(t.emissiveMap){o.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${t.id}/Texture_${t.emissiveMap.id}_emissive.outputs:rgb>`);let r=new e.g(t.emissive.r*n,t.emissive.g*n,t.emissive.b*n);a(t.emissiveMap,`emissive`,r).forEach(e=>i.addChild(e))}else t.emissive.getHex()>0&&o.addProperty(`color3f inputs:emissiveColor = ${Je(t.emissive)}`)}if(t.normalMap&&(o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${t.id}/Texture_${t.normalMap.id}_normal.outputs:rgb>`),a(t.normalMap,`normal`).forEach(e=>i.addChild(e))),t.aoMap){o.addProperty(`float inputs:occlusion.connect = </Materials/Material_${t.id}/Texture_${t.aoMap.id}_occlusion.outputs:r>`);let n=t.aoMapIntensity??1,r=new e.g(n,n,n);a(t.aoMap,`occlusion`,r).forEach(e=>i.addChild(e))}if(t.roughnessMap){o.addProperty(`float inputs:roughness.connect = </Materials/Material_${t.id}/Texture_${t.roughnessMap.id}_roughness.outputs:g>`);let n=new e.g(t.roughness,t.roughness,t.roughness);a(t.roughnessMap,`roughness`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:roughness = ${t.roughness??1}`);if(t.metalnessMap){o.addProperty(`float inputs:metallic.connect = </Materials/Material_${t.id}/Texture_${t.metalnessMap.id}_metallic.outputs:b>`);let n=new e.g(t.metalness,t.metalness,t.metalness);a(t.metalnessMap,`metallic`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:metallic = ${t.metalness??0}`);if(t.alphaMap?(o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.alphaMap.id}_opacity.outputs:r>`),o.addProperty(`float inputs:opacityThreshold = 0.0001`),a(t.alphaMap,`opacity`).forEach(e=>i.addChild(e))):o.addProperty(`float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial){if(t.clearcoatMap!==null){o.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatMap.id}_clearcoat.outputs:r>`);let n=new e.g(t.clearcoat,t.clearcoat,t.clearcoat);a(t.clearcoatMap,`clearcoat`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:clearcoat = ${t.clearcoat}`);if(t.clearcoatRoughnessMap!==null){o.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);let n=new e.g(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness);a(t.clearcoatRoughnessMap,`clearcoatRoughness`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`);o.addProperty(`float inputs:ior = ${t.ior}`)}return o.addProperty(`int inputs:useSpecularWorkflow = 0`),o.addProperty(`token outputs:surface`),i.addChild(o),i.addProperty(`token outputs:surface.connect = </Materials/Material_${t.id}/PreviewSurface.outputs:surface>`),i}function Je(e){return`(${e.r}, ${e.g}, ${e.b})`}function Ye(e,t=1){return`(${e.r}, ${e.g}, ${e.b}, ${t})`}function Xe(e){return`(${e.x}, ${e.y})`}function Ze(e,t,n){let r=Te(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Camera`);Fe(i,e,n);let a=e.isOrthographicCamera?`orthographic`:`perspective`;i.addProperty(`token projection = "${a}"`);let o=`(${e.near.toPrecision($)}, ${e.far.toPrecision($)})`;i.addProperty(`float2 clippingRange = ${o}`);let s;s=e.isOrthographicCamera?((Math.abs(e.left)+Math.abs(e.right))*10).toPrecision($):e.getFilmWidth().toPrecision($),i.addProperty(`float horizontalAperture = ${s}`);let c;if(c=e.isOrthographicCamera?((Math.abs(e.top)+Math.abs(e.bottom))*10).toPrecision($):e.getFilmHeight().toPrecision($),i.addProperty(`float verticalAperture = ${c}`),e.isPerspectiveCamera){let t=e.getFocalLength().toPrecision($);i.addProperty(`float focalLength = ${t}`);let n=e.focus.toPrecision($);i.addProperty(`float focusDistance = ${n}`)}return i}var Qe=`model/vnd.usdz+zip`,$e=`.usdz`;async function et(e){let t=await new we().parseAsync(e,{quickLookCompatible:!0});return new Uint8Array(t)}async function tt(t,n={}){let r=e.r(e.s(t),{...n,wireframe:!1});try{return await et(r)}finally{e.a(r)}}var nt=[{name:`Basic Shapes`,args:{title:`Basic 3D Shapes`,script:`// Basic shapes demonstration
|
|
283
|
-
cube {
|
|
284
|
-
|
|
285
|
-
|
|
290
|
+
`+n.toString())}}o=Le(e,t,l,r,a)}else o=e.isCamera?Ze(e,r,a):Ie(e,r,a);t.addChild(o),Ne(e,o,n,r,i,a)}function Fe(e,t,n){let r=n.animationTracks.get(t),i=t.pivot!==null;if(!i&&r===void 0){let n=Re(t.matrix);e.addProperty(`matrix4d xformOp:transform = ${n}`),e.addProperty(`uniform token[] xformOpOrder = ["xformOp:transform"]`);return}let a=n.animationFrameRate,o=t.position,s=t.quaternion,c=t.scale;if(r!==void 0&&r.position!==void 0?e.addProperty(je(`xformOp:translate`,`float3`,r.position,a)):e.addProperty(`float3 xformOp:translate = (${o.x.toPrecision($)}, ${o.y.toPrecision($)}, ${o.z.toPrecision($)})`),i){let n=t.pivot;e.addProperty(`float3 xformOp:translate:pivot = (${n.x.toPrecision($)}, ${n.y.toPrecision($)}, ${n.z.toPrecision($)})`)}r!==void 0&&r.quaternion!==void 0?e.addProperty(Me(r.quaternion,a)):e.addProperty(`quatf xformOp:orient = (${s.w.toPrecision($)}, ${s.x.toPrecision($)}, ${s.y.toPrecision($)}, ${s.z.toPrecision($)})`),r!==void 0&&r.scale!==void 0?e.addProperty(je(`xformOp:scale`,`float3`,r.scale,a)):e.addProperty(`float3 xformOp:scale = (${c.x.toPrecision($)}, ${c.y.toPrecision($)}, ${c.z.toPrecision($)})`),i?e.addProperty(`uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]`):e.addProperty(`uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]`)}function Ie(e,t,n){let r=Te(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Xform`);return Fe(i,e,n),i}function Le(e,t,n,r,i){let a=Ie(e,r,i);return n.length===1?(a.addMetadata(`prepend references`,`@./geometries/Geometry_${t.id}.usda@</Geometry>`),a.addMetadata(`prepend apiSchemas`,`["MaterialBindingAPI"]`),a.addProperty(`rel material:binding = </Materials/Material_${n[0].id}>`)):a.addChild(Ve(t,n)),a}function Re(e){let t=e.elements;return`( ${ze(t,0)}, ${ze(t,4)}, ${ze(t,8)}, ${ze(t,12)} )`}function ze(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function Be(e){let t=new Q(`Geometry`),n=Ve(e);return t.addChild(n),t}function Ve(e,t=null){let n=e.attributes,r=n.position.count,i=new Q(`Geometry`,`Mesh`);i.addProperty(`int[] faceVertexCounts = [${He(e)}]`),i.addProperty(`int[] faceVertexIndices = [${Ue(e)}]`),i.addProperty(`normal3f[] normals = [${We(n.normal,r)}]`,[`interpolation = "vertex"`]),i.addProperty(`point3f[] points = [${We(n.position,r)}]`);for(let e=0;e<4;e++){let t=e>0?e:``,r=n[`uv`+t];r!==void 0&&i.addProperty(`texCoord2f[] primvars:st${t} = [${Ge(r)}]`,[`interpolation = "vertex"`])}let a=n.color;if(a!==void 0&&i.addProperty(`color3f[] primvars:displayColor = [${We(a,r)}]`,[`interpolation = "vertex"`]),i.addProperty(`uniform token subdivisionScheme = "none"`),t!==null){let r=e.groups,a=(e.index===null?n.position.count:e.index.count)/3;for(let e=0;e<r.length;e++){let n=r[e],o=t[n.materialIndex];if(o===void 0)continue;let s=Math.floor(n.start/3),c=Math.min(s+Math.floor(n.count/3),a),l=[];for(let e=s;e<c;e++)l.push(e);let u=new Q(`subset_${e}`,`GeomSubset`);u.addMetadata(`prepend apiSchemas`,`["MaterialBindingAPI"]`),u.addProperty(`uniform token elementType = "face"`),u.addProperty(`uniform token familyName = "materialBind"`),u.addProperty(`int[] indices = [${l.join(`, `)}]`),u.addProperty(`rel material:binding = </Materials/Material_${o.id}>`),i.addChild(u)}}return i}function He(e){let t=e.index===null?e.attributes.position.count:e.index.count;return Array(t/3).fill(3).join(`, `)}function Ue(e){let t=e.index,n=[];if(t!==null)for(let e=0;e<t.count;e++)n.push(t.getX(e));else{let t=e.attributes.position.count;for(let e=0;e<t;e++)n.push(e)}return n.join(`, `)}function We(e,t){if(e===void 0)return console.warn(`USDZExporter: Normals missing.`),Array(t).fill(`(0, 0, 0)`).join(`, `);let n=[];for(let t=0;t<e.count;t++){let r=e.getX(t),i=e.getY(t),a=e.getZ(t);n.push(`(${r.toPrecision($)}, ${i.toPrecision($)}, ${a.toPrecision($)})`)}return n.join(`, `)}function Ge(e){let t=[];for(let n=0;n<e.count;n++){let r=e.getX(n),i=e.getY(n);t.push(`(${r.toPrecision($)}, ${1-i.toPrecision($)})`)}return t.join(`, `)}function Ke(e,t,n=!1){let r=new Q(`Materials`);for(let i in e){let a=e[i];r.addChild(qe(a,t,n))}return r}function qe(t,n,r=!1){let i=new Q(`Material_${t.id}`,`Material`);function a(e,i,a){let o=e.source.id+`_`+e.flipY;n[o]=e;let s=e.channel>0?`st`+e.channel:`st`,c={1e3:`repeat`,1001:`clamp`,1002:`mirror`},l=e.repeat.clone(),u=e.offset.clone(),d=e.rotation,f=Math.sin(d),p=Math.cos(d);u.y=1-u.y-l.y,r?(u.x/=l.x,u.y/=l.y,u.x+=f/l.x,u.y+=p-1):(u.x+=f*l.x,u.y+=(1-p)*l.y);let m=new Q(`PrimvarReader_${i}`,`Shader`);m.addProperty(`uniform token info:id = "UsdPrimvarReader_float2"`),m.addProperty(`float2 inputs:fallback = (0.0, 0.0)`),m.addProperty(`string inputs:varname = "${s}"`),m.addProperty(`float2 outputs:result`);let h=new Q(`Transform2d_${i}`,`Shader`);h.addProperty(`uniform token info:id = "UsdTransform2d"`),h.addProperty(`float2 inputs:in.connect = </Materials/Material_${t.id}/PrimvarReader_${i}.outputs:result>`),h.addProperty(`float inputs:rotation = ${(180/Math.PI*d).toFixed($)}`),h.addProperty(`float2 inputs:scale = ${Xe(l)}`),h.addProperty(`float2 inputs:translation = ${Xe(u)}`),h.addProperty(`float2 outputs:result`);let g=new Q(`Texture_${e.id}_${i}`,`Shader`);if(g.addProperty(`uniform token info:id = "UsdUVTexture"`),g.addProperty(`asset inputs:file = @textures/Texture_${o}.${Ee(e)}@`),g.addProperty(`float2 inputs:st.connect = </Materials/Material_${t.id}/Transform2d_${i}.outputs:result>`),a!==void 0){let e=i===`diffuse`?t.opacity:1;g.addProperty(`float4 inputs:scale = ${Ye(a,e)}`)}if(i===`normal`){let e=t.normalScale.x;g.addProperty(`float4 inputs:scale = (${2*e}, ${2*e}, 2, 1)`),g.addProperty(`float4 inputs:bias = (${-e}, ${-e}, -1, 0)`)}return g.addProperty(`token inputs:sourceColorSpace = "${e.colorSpace===``?`raw`:`sRGB`}"`),g.addProperty(`token inputs:wrapS = "${c[e.wrapS]}"`),g.addProperty(`token inputs:wrapT = "${c[e.wrapT]}"`),g.addProperty(`float outputs:r`),g.addProperty(`float outputs:g`),g.addProperty(`float outputs:b`),g.addProperty(`float3 outputs:rgb`),(t.transparent||t.alphaTest>0)&&g.addProperty(`float outputs:a`),[m,h,g]}t.side===2&&console.warn(`THREE.USDZExporter: USDZ does not support double sided materials`,t);let o=new Q(`PreviewSurface`,`Shader`);if(o.addProperty(`uniform token info:id = "UsdPreviewSurface"`),t.map===null?o.addProperty(`color3f inputs:diffuseColor = ${Je(t.color)}`):(o.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:rgb>`),t.transparent?o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`):t.alphaTest>0&&(o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.map.id}_diffuse.outputs:a>`),o.addProperty(`float inputs:opacityThreshold = ${t.alphaTest}`)),a(t.map,`diffuse`,t.color).forEach(e=>i.addChild(e))),t.emissive){let n=t.emissiveIntensity??1;if(t.emissiveMap){o.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${t.id}/Texture_${t.emissiveMap.id}_emissive.outputs:rgb>`);let r=new e.g(t.emissive.r*n,t.emissive.g*n,t.emissive.b*n);a(t.emissiveMap,`emissive`,r).forEach(e=>i.addChild(e))}else t.emissive.getHex()>0&&o.addProperty(`color3f inputs:emissiveColor = ${Je(t.emissive)}`)}if(t.normalMap&&(o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${t.id}/Texture_${t.normalMap.id}_normal.outputs:rgb>`),a(t.normalMap,`normal`).forEach(e=>i.addChild(e))),t.aoMap){o.addProperty(`float inputs:occlusion.connect = </Materials/Material_${t.id}/Texture_${t.aoMap.id}_occlusion.outputs:r>`);let n=t.aoMapIntensity??1,r=new e.g(n,n,n);a(t.aoMap,`occlusion`,r).forEach(e=>i.addChild(e))}if(t.roughnessMap){o.addProperty(`float inputs:roughness.connect = </Materials/Material_${t.id}/Texture_${t.roughnessMap.id}_roughness.outputs:g>`);let n=new e.g(t.roughness,t.roughness,t.roughness);a(t.roughnessMap,`roughness`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:roughness = ${t.roughness??1}`);if(t.metalnessMap){o.addProperty(`float inputs:metallic.connect = </Materials/Material_${t.id}/Texture_${t.metalnessMap.id}_metallic.outputs:b>`);let n=new e.g(t.metalness,t.metalness,t.metalness);a(t.metalnessMap,`metallic`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:metallic = ${t.metalness??0}`);if(t.alphaMap?(o.addProperty(`float inputs:opacity.connect = </Materials/Material_${t.id}/Texture_${t.alphaMap.id}_opacity.outputs:r>`),o.addProperty(`float inputs:opacityThreshold = 0.0001`),a(t.alphaMap,`opacity`).forEach(e=>i.addChild(e))):o.addProperty(`float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial){if(t.clearcoatMap!==null){o.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatMap.id}_clearcoat.outputs:r>`);let n=new e.g(t.clearcoat,t.clearcoat,t.clearcoat);a(t.clearcoatMap,`clearcoat`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:clearcoat = ${t.clearcoat}`);if(t.clearcoatRoughnessMap!==null){o.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${t.id}/Texture_${t.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);let n=new e.g(t.clearcoatRoughness,t.clearcoatRoughness,t.clearcoatRoughness);a(t.clearcoatRoughnessMap,`clearcoatRoughness`,n).forEach(e=>i.addChild(e))}else o.addProperty(`float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`);o.addProperty(`float inputs:ior = ${t.ior}`)}return o.addProperty(`int inputs:useSpecularWorkflow = 0`),o.addProperty(`token outputs:surface`),i.addChild(o),i.addProperty(`token outputs:surface.connect = </Materials/Material_${t.id}/PreviewSurface.outputs:surface>`),i}function Je(e){return`(${e.r}, ${e.g}, ${e.b})`}function Ye(e,t=1){return`(${e.r}, ${e.g}, ${e.b}, ${t})`}function Xe(e){return`(${e.x}, ${e.y})`}function Ze(e,t,n){let r=Te(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Camera`);Fe(i,e,n);let a=e.isOrthographicCamera?`orthographic`:`perspective`;i.addProperty(`token projection = "${a}"`);let o=`(${e.near.toPrecision($)}, ${e.far.toPrecision($)})`;i.addProperty(`float2 clippingRange = ${o}`);let s;s=e.isOrthographicCamera?((Math.abs(e.left)+Math.abs(e.right))*10).toPrecision($):e.getFilmWidth().toPrecision($),i.addProperty(`float horizontalAperture = ${s}`);let c;if(c=e.isOrthographicCamera?((Math.abs(e.top)+Math.abs(e.bottom))*10).toPrecision($):e.getFilmHeight().toPrecision($),i.addProperty(`float verticalAperture = ${c}`),e.isPerspectiveCamera){let t=e.getFocalLength().toPrecision($);i.addProperty(`float focalLength = ${t}`);let n=e.focus.toPrecision($);i.addProperty(`float focusDistance = ${n}`)}return i}var Qe=`model/vnd.usdz+zip`,$e=`.usdz`;async function et(e){let{root:t,dispose:n}=nt(e);try{let e=await new we().parseAsync(t,{quickLookCompatible:!0});return new Uint8Array(e)}finally{n()}}var tt=1e3;function nt(t){let n=new e.I().add(t.clone()),r=[],i=[];n.traverse(e=>{let t=e;t.isMesh&&t.geometry.hasAttribute(`color`)&&t.material.vertexColors&&i.push(t)});for(let t of i){let n=new e.I;n.name=t.name,n.visible=t.visible,n.position.copy(t.position),n.quaternion.copy(t.quaternion),n.scale.copy(t.scale),n.updateMatrix();for(let e of rt(t))r.push(e.geometry,e.material),n.add(e);for(let e of[...t.children])n.add(e);t.parent?.add(n),t.parent?.remove(t)}return{root:n,dispose:()=>r.forEach(e=>e.dispose())}}function rt(t){let n=t.geometry.index?t.geometry.toNonIndexed():t.geometry,r=n.getAttribute(`color`),i=new Map;for(let e=0;e*3<r.count;e++){let t=it(r,e),n=t.toArray().map(e=>Math.round(e*tt)).join(`,`);(i.get(n)??i.set(n,{colour:t,faces:[]}).get(n)).faces.push(e)}let a=t.material,o=[...i.values()].map(({colour:t,faces:r})=>{let i=at(n,r),o=a.clone();return o.vertexColors=!1,o.color.copy(a.color).multiply(t),new e.Y(i,o)});return n!==t.geometry&&n.dispose(),o}function it(t,n){let r=new e.g(0,0,0);for(let i=0;i<3;i++)r.add(new e.g(t.getX(n*3+i),t.getY(n*3+i),t.getZ(n*3+i)));return r.multiplyScalar(1/3)}function at(t,n){let r=new e.p;for(let[i,a]of Object.entries(t.attributes)){if(i===`color`)continue;let t=a.itemSize,o=new Float32Array(n.length*3*t);n.forEach((e,n)=>{for(let r=0;r<3;r++)for(let i=0;i<t;i++)o[(n*3+r)*t+i]=a.getComponent(e*3+r,i)}),r.setAttribute(i,new e.j(o,t))}return r}async function ot(t,n={}){let r=e.r(e.s(t),{...n,wireframe:!1});try{return await et(r)}finally{e.a(r)}}var st=[{name:`Basic Shapes`,args:{title:`Basic 3D Shapes`,script:`// Basic shapes demonstration
|
|
291
|
+
cube {
|
|
292
|
+
position -2 0 0
|
|
293
|
+
size 1
|
|
294
|
+
color (1 0.3 0.3)
|
|
295
|
+
}
|
|
296
|
+
sphere {
|
|
297
|
+
position 0 0 0
|
|
298
|
+
size 1
|
|
299
|
+
color (0.3 1 0.3)
|
|
300
|
+
}
|
|
301
|
+
cylinder {
|
|
302
|
+
position 2 0 0
|
|
303
|
+
size 0.5 1
|
|
304
|
+
color (0.3 0.3 1)
|
|
305
|
+
}`}},{name:`Circular Pattern`,args:{title:`Circular Pattern`,script:`// 12個の立方体を円形に配置
|
|
286
306
|
|
|
287
307
|
define count 12
|
|
288
308
|
define radius 3
|
|
@@ -313,7 +333,16 @@ sphere {
|
|
|
313
333
|
opacity 0.5
|
|
314
334
|
}`}},{name:`CSG Difference`,args:{title:`Hollow Sphere`,script:`// Create a hollow sphere using CSG difference
|
|
315
335
|
difference {
|
|
316
|
-
sphere {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
336
|
+
sphere {
|
|
337
|
+
size 2
|
|
338
|
+
color (1 0.5 0)
|
|
339
|
+
}
|
|
340
|
+
sphere {
|
|
341
|
+
size 1.7
|
|
342
|
+
color (1 1 1)
|
|
343
|
+
}
|
|
344
|
+
cube {
|
|
345
|
+
position 0 0 2
|
|
346
|
+
size 2
|
|
347
|
+
}
|
|
348
|
+
}`}}];Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return n}});
|