@mulmoclaude/shapescript-plugin 2.0.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +112 -26
  2. package/dist/core/definition.d.ts.map +1 -1
  3. package/dist/core/index.d.ts +2 -1
  4. package/dist/core/index.d.ts.map +1 -1
  5. package/dist/core/plugin.d.ts.map +1 -1
  6. package/dist/{core-DZvhTmuk.cjs → core-BBgBeYYe.cjs} +1 -1
  7. package/dist/{core-BvTjfhU2.js → core-yB1Eiacr.js} +2 -2
  8. package/dist/core.cjs +1 -1
  9. package/dist/core.js +4 -4
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/lang/de.d.ts.map +1 -1
  13. package/dist/lang/en.d.ts.map +1 -1
  14. package/dist/lang/es.d.ts.map +1 -1
  15. package/dist/lang/fr.d.ts.map +1 -1
  16. package/dist/lang/ja.d.ts.map +1 -1
  17. package/dist/lang/ko.d.ts.map +1 -1
  18. package/dist/lang/messages.d.ts +4 -0
  19. package/dist/lang/messages.d.ts.map +1 -1
  20. package/dist/lang/ptBR.d.ts.map +1 -1
  21. package/dist/lang/zh.d.ts.map +1 -1
  22. package/dist/render/page.d.ts.map +1 -1
  23. package/dist/render.cjs +8 -4
  24. package/dist/render.js +14 -10
  25. package/dist/{samples-CXhuDdDd.js → samples-CT-c9o1S.js} +281 -276
  26. package/dist/samples-D2_jOmoh.cjs +319 -0
  27. package/dist/shapescript/builders.d.ts +12 -2
  28. package/dist/shapescript/builders.d.ts.map +1 -1
  29. package/dist/shapescript/evaluator.d.ts +76 -2
  30. package/dist/shapescript/evaluator.d.ts.map +1 -1
  31. package/dist/shapescript/meshValues.d.ts +54 -0
  32. package/dist/shapescript/meshValues.d.ts.map +1 -0
  33. package/dist/shapescript/minkowski.d.ts +37 -0
  34. package/dist/shapescript/minkowski.d.ts.map +1 -0
  35. package/dist/shapescript/parser.d.ts +66 -2
  36. package/dist/shapescript/parser.d.ts.map +1 -1
  37. package/dist/shapescript/toThreeJS.d.ts +144 -8
  38. package/dist/shapescript/toThreeJS.d.ts.map +1 -1
  39. package/dist/shapescript/types.d.ts +145 -17
  40. package/dist/shapescript/types.d.ts.map +1 -1
  41. package/dist/style.css +1 -1
  42. package/dist/{toThreeJS-FsP-Na75.js → toThreeJS-CKjSbEnA.js} +6670 -4712
  43. package/dist/toThreeJS-Cs0UJm82.cjs +10 -0
  44. package/dist/vue/Preview.vue.d.ts.map +1 -1
  45. package/dist/vue/View.vue.d.ts.map +1 -1
  46. package/dist/vue/index.d.ts +1 -1
  47. package/dist/vue/index.d.ts.map +1 -1
  48. package/dist/vue.cjs +35 -25
  49. package/dist/vue.js +1532 -1493
  50. package/package.json +1 -1
  51. package/dist/samples-DGD0Kjwg.cjs +0 -276
  52. package/dist/toThreeJS-MvllBF9e.cjs +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmoclaude/shapescript-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.3.0",
4
4
  "description": "presentShapeScript \u2014 interactive 3D visualizations authored in the ShapeScript language (parser + Three.js renderer). Core (tool definition + execute) on `.`, Vue View/Preview on `./vue`.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,276 +0,0 @@
1
- const e=require("./toThreeJS-MvllBF9e.cjs");let t=require("@mulmoclaude/core/artifacts");var n=`presentShapeScript`,r={type:`function`,name:n,description:"Display interactive 3D visualizations using ShapeScript with expressions, variables, control flow, and functions. A new `script` is saved to `artifacts/shapes/` and the returned `filePath` names it; pass `path` instead to present a source that already exists.",parameters:{type:`object`,properties:{title:{type:`string`,description:`Title for the 3D visualization`},script:{type:`string`,description:`ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.
2
-
3
- ## SYNTAX OVERVIEW:
4
-
5
- ### Expressions & Operators:
6
- - Arithmetic: +, -, *, /, % with proper precedence
7
- - Comparison: =, <>, <, <=, >, >=
8
- - Boolean: and, or, not
9
- - Parentheses for grouping: (2 + 3) * 4
10
-
11
- ### Variables:
12
- define radius 2
13
- define red (1 0 0)
14
- sphere {
15
- size radius
16
- color red
17
- }
18
-
19
- ### Control Flow:
20
-
21
- For loops with variables:
22
- for i in 1 to 5 {
23
- cube {
24
- position (i * 2) 0 0
25
- size 1
26
- }
27
- }
28
-
29
- For loops with step:
30
- for i in 0 to 10 step 2 {
31
- sphere { position 0 i 0 }
32
- }
33
-
34
- If/else conditionals:
35
- define showSphere 1
36
- if showSphere {
37
- sphere { size 2 }
38
- } else {
39
- cube { size 2 }
40
- }
41
-
42
- Switch statements:
43
- define shape 2
44
- switch shape {
45
- case 1
46
- cube
47
- case 2
48
- sphere
49
- else
50
- cone
51
- }
52
-
53
- ### Built-in Functions:
54
-
55
- Math: round, floor, ceil, abs, sign, sqrt, pow, min, max
56
- Trig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)
57
- Vector: dot, cross, length, normalize, sum
58
-
59
- IMPORTANT: Function calls require NO space between name and parenthesis:
60
- - sin(x) ✓ function call
61
- - sin (x) ✗ NOT a function call (identifier + parenthesized expression)
62
- Separate arguments with spaces, as upstream does: max(0 (j - 1)), pow(2.718 (0 - x)). Commas also work
63
- here (max(0, j - 1)) but NOT in the upstream ShapeScript app, so prefer spaces. Bare max 0 1 without
64
- parentheses is not supported.
65
- Write ONE statement per line. This parser accepts "define a 1 define b 2" on one line; the upstream app
66
- rejects it, and a script that keeps to one statement per line opens in both.
67
-
68
- Examples:
69
- for i in 1 to 8 {
70
- define angle (i * 0.785) // 45 degrees in radians
71
- cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }
72
- }
73
-
74
- ### Primitives & Properties:
75
-
76
- Shapes: cube, sphere, cylinder, cone, torus, circle, square, polygon (sides 3–256)
77
- Properties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z
78
- Materials: color R G B (0-1), opacity (0-1)
79
-
80
- UNITS (same as upstream ShapeScript — https://shapescript.info/mac/):
81
- - size is the DIAMETER of sphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length.
82
- - orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.
83
- - rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.
84
- - Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.
85
-
86
- ### CSG Operations:
87
- union, difference, intersection, xor, stencil
88
-
89
- Example:
90
- difference {
91
- sphere {
92
- size 2
93
- color (1 0.5 0)
94
- }
95
- cube { size 1.5 }
96
- }
97
-
98
- ### Paths:
99
- path { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.
100
- - curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.
101
- - A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.
102
- - rotate (half-turns) / translate / scale inside a path move the frame for later points:
103
- path {
104
- for 0 to 8 {
105
- curve 0 1
106
- rotate 1 / 8
107
- }
108
- } // semicircle
109
-
110
- ### Builders:
111
- - extrude: extrude { polygon { sides 3 } } or an inline path (size Z = depth, default 1):
112
- extrude path {
113
- point 0 0
114
- point 1 0
115
- point 0 1
116
- point 0 0
117
- }
118
- - fill: fill { square } or fill path { ... }
119
- - lathe (revolves the XY profile about Y):
120
- lathe path {
121
- point 0 0
122
- point 1 0
123
- curve 1.5 1
124
- point 1 2
125
- point 0 2
126
- }
127
- - loft (closed planar sections joined with caps):
128
- loft {
129
- square
130
- translate 0 0 2
131
- circle
132
- }
133
- - hull (convex envelope):
134
- hull {
135
- cube { position -1 0 0 }
136
- cube { position 1 0 0 }
137
- }
138
- - stencil preserves the first shape and paints its surface with later shapes' materials.
139
- Loft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.
140
-
141
- ### Additional Expressions:
142
- - Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)
143
- - Scientific notation and unary plus: 1e-3, +2
144
- - Tuple/vector members: vector.x, vector.y, vector.z; color.red/green/blue/alpha
145
- - Tuple/string length: value.count; zero-based indexing: values[0]; ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast
146
- - String literals, join(...), trim(...); min/max also accept tuples
147
- - Custom shapes with options:
148
- define post {
149
- option height 2
150
- cylinder { size 0.2 height }
151
- }
152
- post { height 3 }
153
- - Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)
154
-
155
- ### Compatibility:
156
- This plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units and
157
- path semantics follow upstream, so a script written against the upstream docs renders the same here.
158
- Function calls use name(...). Imports, textures, text/fonts, lights/cameras, arbitrary objects,
159
- hex/named colours, and general user-defined functions are not supported.
160
-
161
- ### Comments:
162
- // Single-line comment
163
- /* Multi-line
164
- comment */
165
-
166
- ## COMPLETE EXAMPLES:
167
-
168
- Linear arrangement with expressions:
169
- define spacing 1.5
170
- for i in 1 to 4 {
171
- cylinder {
172
- position ((i - 2.5) * spacing) 0 0
173
- size 0.4 1
174
- }
175
- }
176
-
177
- Circular pattern:
178
- define count 12
179
- for i in 1 to count {
180
- define angle ((i / count) * 6.283) // 2 * PI
181
- cube {
182
- position (cos(angle) * 3) 0 (sin(angle) * 3)
183
- color (i / count) 0.5 (1 - i / count)
184
- size 0.5
185
- }
186
- }
187
-
188
- Conditional geometry:
189
- define makeHollow 1
190
- if makeHollow {
191
- difference {
192
- sphere {
193
- size 2
194
- color (1 0 0)
195
- }
196
- sphere { size 1.7 }
197
- }
198
- } else {
199
- sphere {
200
- size 2
201
- color (1 0 0)
202
- }
203
- }
204
-
205
- Mathematical visualization:
206
- for x in -5 to 5 {
207
- for z in -5 to 5 {
208
- define height (sin(x * 0.5) * cos(z * 0.5) * 2)
209
- cube {
210
- position (x * 0.3) height (z * 0.3)
211
- size 0.25 (abs(height) + 0.1) 0.25
212
- color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)
213
- }
214
- }
215
- }`},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){e.i(e.r(e.In(t)))}async function y(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 b=5;async function x(e,t,n){let r=e.files?.artifacts;if(r){for(let e=0;e<b;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 S(e,t){if(_(t.path)&&_(t.script))throw Error("Provide either `script` or `path`, not both");if(_(t.path))return{script:await y(e,t.path),filePath:t.path};if(!_(t.script))throw Error(`ShapeScript code is required but was not provided`);return{script:t.script}}var C=async(t,n)=>{let r=`INVALID_ARGUMENT`;try{if(!e.Rn(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 S(t??{},n);r=`EVALUATION_ERROR`,v(i.script);let a=i.filePath??await x(t??{},i.script,n.title);return{message:a?`Saved ShapeScript to ${a}`:`Created 3D visualization: ${n.title}`,title:n.title,data:a?{script:i.script,filePath:a}:{script:i.script},instructions:g}}catch(t){let n={code:t instanceof e.Ln?`PARSE_ERROR`:t instanceof e.n?`LIMIT_EXCEEDED`:r,message:t instanceof Error?t.message:String(t),...t instanceof e.Ln&&t.line!==void 0?{line:t.line}:{},...t instanceof e.Ln&&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.`}}},w={toolDefinition:r,execute:C,generatingMessage:`Creating 3D visualization...`,waitingMessage:`Tell the user that the 3D visualization was created and will be presented shortly.`,isEnabled:()=>!0},T=C,E=Uint8Array,D=Uint16Array,ee=Int32Array,te=new E([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]),ne=new E([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]),O=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),k=function(e,t){for(var n=new D(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new ee(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}},A=k(te,2),j=A.b,M=A.r;j[28]=258,M[258]=28;var N=k(ne,0);N.b;for(var P=N.r,F=new D(32768),I=0;I<32768;++I){var L=(I&43690)>>1|(I&21845)<<1;L=(L&52428)>>2|(L&13107)<<2,L=(L&61680)>>4|(L&3855)<<4,F[I]=((L&65280)>>8|(L&255)<<8)>>1}for(var R=(function(e,t,n){for(var r=e.length,i=0,a=new D(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new D(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new D(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[F[d]>>c]=l}else for(s=new D(r),i=0;i<r;++i)e[i]&&(s[i]=F[o[e[i]-1]++]>>15-e[i]);return s}),z=new E(288),I=0;I<144;++I)z[I]=8;for(var I=144;I<256;++I)z[I]=9;for(var I=256;I<280;++I)z[I]=7;for(var I=280;I<288;++I)z[I]=8;for(var B=new E(32),I=0;I<32;++I)B[I]=5;var V=R(z,9,0),re=R(B,5,0),ie=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 E(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:ce,l:0};if(i==1){var o=new E(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 D(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 E(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},ae=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new D(++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},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},X=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,_=ae(f),v=_.c,y=_.n,b=ae(h),x=b.c,S=b.n,C=new D(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,ee=T.l,k=19;k>4&&!E[O[k-1]];--k);var A=l+5<<3,j=Y(i,z)+Y(a,B)+o,M=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&&A<=j&&A<=M)return oe(t,u,e.subarray(c,c+l));var N,P,F,I;if(G(t,u,1+(M<j)),u+=2,M<j){N=R(f,p,0),P=f,F=R(h,g,0),I=h;var L=R(E,ee,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[O[w]]);u+=3*k;for(var ie=[v,x],H=0;H<2;++H)for(var U=ie[H],w=0;w<U.length;++w){var W=U[w]&31;G(t,u,L[W]),u+=E[W],W>15&&(G(t,u,U[w]>>5&127),u+=U[w]>>12)}}else N=V,P=z,F=re,I=B;for(var w=0;w<s;++w){var J=r[w];if(J>255){var W=J>>18&31;K(t,u,N[W+257]),u+=P[W+257],W>7&&(G(t,u,J>>23&31),u+=te[W]);var X=J&31;K(t,u,F[X]),u+=I[X],X>3&&(K(t,u,J>>5&8191),u+=ne[X])}else K(t,u,N[J]),u+=P[J]}return K(t,u,N[256]),u+P[256]},se=new ee([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ce=new E(0),le=function(e,t,n,r,i,a){var o=a.z||e.length,s=new E(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=se[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new D(32768),g=a.h||new D(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new ee(25e3),x=new D(288),S=new D(32),C=0,w=0,T=a.i||0,O=0,k=a.w||0,A=0;T+2<o;++T){var j=y(T),N=T&32767,F=g[j];if(h[N]=F,g[j]=N,k<=T){var I=o-T;if((C>7e3||O>24576)&&(I>423||!l)){u=X(e,c,0,b,x,S,w,O,A,T-A,u),O=C=w=0,A=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&&j==y(T-V))for(var re=Math.min(f,I)-1,U=Math.min(32767,T),W=Math.min(258,I);V<=U&&--B&&N!=F;){if(e[T+R]==e[T+R-V]){for(var G=0;G<W&&e[T+G]==e[T+G-V];++G);if(G>R){if(R=G,z=V,G>re)break;for(var K=Math.min(V,G-2),q=0,L=0;L<K;++L){var J=T-V+L&32767,ae=J-h[J]&32767;ae>q&&(q=ae,F=J)}}}N=F,F=h[N],V+=N-F&32767}if(z){b[O++]=268435456|M[R]<<18|P[z];var Y=M[R]&31,ce=P[z]&31;w+=te[Y]+ne[ce],++x[257+Y],++S[ce],k=T+R,++C}else b[O++]=e[T],++x[e[T]]}}for(T=Math.max(T,k);T<o;++T)b[O++]=e[T],++x[e[T]];u=X(e,c,l,b,x,S,w,O,A,T-A,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=k)}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 H(s,0,r+ie(u)+i)},ue=(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})(),de=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=ue[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},fe=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new E(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return le(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)},pe=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 me(e,t){return fe(e,t||{},0,0)}var he=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=pe(r,a[1]),a=a[0]),a instanceof E?n[o]=[a,s]:(n[o+=`/`]=[new E(0),s],he(a,o,n,r))}},ge=typeof TextEncoder<`u`&&new TextEncoder,_e=typeof TextDecoder<`u`&&new TextDecoder;try{_e.decode(ce,{stream:!0})}catch{}function ve(e,t){if(t){for(var n=new E(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(ge)return ge.encode(e);for(var i=e.length,a=new E(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 E(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 ye=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},be=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=ye(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},xe=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 Se(e,t){t||={};var n={},r=[];he(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=ve(o),f=d.length,p=l.comment,m=p&&ve(p),h=m&&m.length,g=ye(l.extra);f>65535&&W(11);var _=u?me(c,l):c,v=_.length,y=de();y.p(c),r.push(pe(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 E(a+22),x=i,S=a-i,C=0;C<r.length;++C){var d=r[C];be(b,d.o,d,d.f,d.u,d.c.length);var w=30+d.f.length+ye(d.extra);b.set(d.c,d.o+w),be(b,i,d,d.f,d.u,d.c.length,d.o,d.m),i+=16+w+(d.m?d.m.length:0)}return xe(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(`
216
- `)}return`${n} = ${r}`}),r=n.length?` (\n${n.map(e=>`${t}\t${e}`).join(`
217
- `)}\n${t})`:``,i=this.properties.map(e=>{let n=e.property.replace(/\n/g,`
218
- `+t+` `),r=e.metadata.length?` (\n${e.metadata.map(e=>`${t}\t\t${e}`).join(`
219
- `)}\n${t}\t)`:``;return`${t}\t${n}${r}`}),a=this.children.map(t=>t.toString(e+1)),o=[];if(i.length>0&&o.push(...i),a.length>0){i.length>0&&o.push(``);for(let e=0;e<a.length;e++)o.push(a[e]),e<a.length-1&&o.push(``)}let s=o.join(`
220
- `);return`${t}def ${this.type?this.type+` `:``}"${this.name}"${r}\n${t}{\n${s}\n${t}}`}},Ce=class{constructor(){this.textureUtils=null}setTextureUtils(e){this.textureUtils=e}parse(e,t,n,r){this.parseAsync(e,r).then(t).catch(n)}async parseAsync(e,t={}){t=Object.assign({ar:{anchoring:{type:`plane`},planeAnchoring:{alignment:`horizontal`}},includeAnchoringProperties:!0,onlyVisible:!0,quickLookCompatible:!1,maxTextureSize:1024,animations:[],animationFrameRate:60},t);let n=new Set,r={},i=`model.usda`;r[i]=null;let a=Oe(e,t.animations);t.animationTracks=a;let o=new Q(`Root`,`Xform`),s=new Q(`Scenes`,`Scope`);s.addMetadata(`kind`,`"sceneLibrary"`),o.addChild(s);let c=`Scene`,l=new Q(c,`Xform`);l.addMetadata(`customData`,[`bool preliminary_collidesWithEnvironment = 0`,`string sceneName = "${c}"`]),l.addMetadata(`sceneName`,`"${c}"`),t.includeAnchoringProperties&&(l.addProperty(`token preliminary:anchoring:type = "${t.ar.anchoring.type}"`),l.addProperty(`token preliminary:planeAnchoring:alignment = "${t.ar.planeAnchoring.alignment}"`)),s.addChild(l);let u,d={},f={};e.isScene?Me(e,l,d,n,r,t):Ne(e,l,d,n,r,t);let p=Ge(d,f,t.quickLookCompatible);u=De(a.size>0?{fps:t.animationFrameRate,endTimeCode:ke(t.animations)*t.animationFrameRate}:null)+`
221
- `+o.toString()+`
222
-
223
- `+p.toString(),r[i]=ve(u),u=null;for(let e in f){let n=f[e];if(n.isCompressedTexture===!0){if(this.textureUtils===null)throw Error(`THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.`);n=await this.textureUtils.decompress(n)}let i=Ee(n.image,n.flipY,t.maxTextureSize),a=n.userData.mimeType===`image/jpeg`?`image/jpeg`:`image/png`,o=await new Promise(e=>i.toBlob(e,a));r[`textures/Texture_${e}.${Te(n)}`]=new Uint8Array(await o.arrayBuffer())}let m=0;for(let e in r){let t=r[e],n=34+e.length;m+=n;let i=m&63;if(i!==4){let n=64-i;r[e]=[t,{extra:{12345:new Uint8Array(n)}}]}m=t.length}return Se(r,{level:0})}};function we(e,t){let n=e.name;return n=n.replace(/[^A-Za-z0-9_]/g,``),/^[0-9]/.test(n)&&(n=`_`+n),n===``&&(n=e.isCamera?`Camera`:`Object`),t.has(n)&&(n=n+`_`+e.id),t.add(n),n}function Te(e){return e.userData.mimeType===`image/jpeg`?`jpg`:`png`}function Ee(e,t,n){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let r=n/Math.max(e.width,e.height),i=document.createElement(`canvas`);i.width=e.width*Math.min(1,r),i.height=e.height*Math.min(1,r);let a=i.getContext(`2d`);return t===!0&&(a.translate(0,i.height),a.scale(1,-1)),a.drawImage(e,0,0,i.width,i.height),i}throw Error(`THREE.USDZExporter: No valid image data found. Unable to process texture.`)}var $=7;function De(e=null){return`#usda 1.0
224
- (
225
- customLayerData = {
226
- string creator = "Three.js USDZExporter"
227
- }
228
- defaultPrim = "Root"
229
- metersPerUnit = 1
230
- upAxis = "Y"${e?`
231
- startTimeCode = 0
232
- endTimeCode = ${e.endTimeCode}
233
- timeCodesPerSecond = ${e.fps}
234
- framesPerSecond = ${e.fps}`:``}
235
- )
236
- `}function Oe(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.it.parseTrackName(i.name),s=e.it.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 ke(e){let t=0;for(let n=0;n<e.length;n++)e[n].duration>t&&(t=e[n].duration);return t}function Ae(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(`,
237
- `)},\n}`}function je(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(`,
238
- `)},\n}`}function Me(e,t,n,r,i,a){for(let o=0,s=e.children.length;o<s;o++)Ne(e.children[o],t,n,r,i,a)}function Ne(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=ze(t);i[e]=ve(De()+`
239
- `+n.toString())}}o=Ie(e,t,l,r,a)}else o=e.isCamera?Xe(e,r,a):Fe(e,r,a);t.addChild(o),Me(e,o,n,r,i,a)}function Pe(e,t,n){let r=n.animationTracks.get(t),i=t.pivot!==null;if(!i&&r===void 0){let n=Le(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(Ae(`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(je(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(Ae(`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 Fe(e,t,n){let r=we(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Xform`);return Pe(i,e,n),i}function Ie(e,t,n,r,i){let a=Fe(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(Be(t,n)),a}function Le(e){let t=e.elements;return`( ${Re(t,0)}, ${Re(t,4)}, ${Re(t,8)}, ${Re(t,12)} )`}function Re(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function ze(e){let t=new Q(`Geometry`),n=Be(e);return t.addChild(n),t}function Be(e,t=null){let n=e.attributes,r=n.position.count,i=new Q(`Geometry`,`Mesh`);i.addProperty(`int[] faceVertexCounts = [${Ve(e)}]`),i.addProperty(`int[] faceVertexIndices = [${He(e)}]`),i.addProperty(`normal3f[] normals = [${Ue(n.normal,r)}]`,[`interpolation = "vertex"`]),i.addProperty(`point3f[] points = [${Ue(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} = [${We(r)}]`,[`interpolation = "vertex"`])}let a=n.color;if(a!==void 0&&i.addProperty(`color3f[] primvars:displayColor = [${Ue(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 Ve(e){let t=e.index===null?e.attributes.position.count:e.index.count;return Array(t/3).fill(3).join(`, `)}function He(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 Ue(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 We(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 Ge(e,t,n=!1){let r=new Q(`Materials`);for(let i in e){let a=e[i];r.addChild(Ke(a,t,n))}return r}function Ke(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 = ${Ye(l)}`),h.addProperty(`float2 inputs:translation = ${Ye(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}.${Te(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 = ${Je(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 = ${qe(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.m(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 = ${qe(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.m(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.m(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.m(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.m(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.m(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 qe(e){return`(${e.r}, ${e.g}, ${e.b})`}function Je(e,t=1){return`(${e.r}, ${e.g}, ${e.b}, ${t})`}function Ye(e){return`(${e.x}, ${e.y})`}function Xe(e,t,n){let r=we(e,t);e.matrix.determinant()<0&&console.warn(`THREE.USDZExporter: USDZ does not support negative scales`,e);let i=new Q(r,`Camera`);Pe(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 Ze=`model/vnd.usdz+zip`,Qe=`.usdz`;async function $e(e){let t=await new Ce().parseAsync(e,{quickLookCompatible:!0});return new Uint8Array(t)}async function et(t,n={}){let r=e.r(e.In(t),{...n,wireframe:!1});try{return await $e(r)}finally{e.i(r)}}var tt=[{name:`Basic Shapes`,args:{title:`Basic 3D Shapes`,script:`// Basic shapes demonstration
240
- cube { position -2 0 0 size 1 color (1 0.3 0.3) }
241
- sphere { position 0 0 0 size 1 color (0.3 1 0.3) }
242
- cylinder { position 2 0 0 size 0.5 1 color (0.3 0.3 1) }`}},{name:`Circular Pattern`,args:{title:`Circular Pattern`,script:`// 12個の立方体を円形に配置
243
-
244
- define count 12
245
- define radius 3
246
-
247
- for i in 1 to count {
248
- // 各立方体の角度を計算(2 * PI = 6.283ラジアン)
249
- define angle ((i / count) * 6.283)
250
-
251
- // 円形配置のためのX座標とZ座標を計算
252
- define x (cos(angle) * radius)
253
- define z (sin(angle) * radius)
254
-
255
- // グラデーションカラーを作成
256
- define colorValue (i / count)
257
-
258
- cube {
259
- position x 0 z
260
- size 0.5
261
- color colorValue 0.5 (1 - colorValue)
262
- }
263
- }
264
-
265
- // 中心に参考用の球体を配置
266
- sphere {
267
- position 0 0 0
268
- size 0.3
269
- color 1 1 0
270
- opacity 0.5
271
- }`}},{name:`CSG Difference`,args:{title:`Hollow Sphere`,script:`// Create a hollow sphere using CSG difference
272
- difference {
273
- sphere { size 2 color (1 0.5 0) }
274
- sphere { size 1.7 color (1 1 1) }
275
- cube { position 0 0 2 size 2 }
276
- }`}}];Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return C}}),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 $e}}),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 Qe}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return tt}}),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}});