@mulmoclaude/shapescript-plugin 2.4.0 → 2.5.1
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 +4 -5
- package/dist/core/definition.d.ts.map +1 -1
- package/dist/core/samples.d.ts.map +1 -1
- package/dist/{core-DmD6zaRF.cjs → core-1E7QiANi.cjs} +1 -1
- package/dist/{core-CvNYv5VF.js → core-CiJHiO3H.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-y59fsGq8.js → samples-BwyNyHha.js} +353 -298
- package/dist/{samples-BrJ4z8v-.cjs → samples-b6J0NoFm.cjs} +42 -18
- package/dist/shapescript/meshValues.d.ts +4 -0
- package/dist/shapescript/meshValues.d.ts.map +1 -1
- package/dist/shapescript/parser.d.ts +7 -0
- package/dist/shapescript/parser.d.ts.map +1 -1
- package/dist/shapescript/toThreeJS.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/{toThreeJS-CaZGJjfO.cjs → toThreeJS-BETrskvw.cjs} +4 -4
- package/dist/{toThreeJS-OGEAi4zV.js → toThreeJS-DyLC4g1t.js} +132 -94
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue.cjs +22 -21
- package/dist/vue.js +1078 -1077
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ARTIFACTS_ROOT as
|
|
1
|
+
import { Bn as e, I as t, Y as n, a as r, g as i, i as a, j as o, n as s, p as c, r as l, s as u, st as d, zn as f } from "./toThreeJS-DyLC4g1t.js";
|
|
2
|
+
import { ARTIFACTS_ROOT as p, buildArtifactRelPath as m, classifyFilePath as h, hasUnsafePathSegment as g, slugifyArtifact as _, toWorkspaceArtifactPath as v } from "@mulmoclaude/core/artifacts";
|
|
3
3
|
//#region src/core/definition.ts
|
|
4
|
-
var
|
|
4
|
+
var y = "presentShapeScript", b = {
|
|
5
5
|
type: "function",
|
|
6
|
-
name:
|
|
6
|
+
name: y,
|
|
7
7
|
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.",
|
|
8
8
|
parameters: {
|
|
9
9
|
type: "object",
|
|
@@ -14,7 +14,7 @@ var h = "presentShapeScript", g = {
|
|
|
14
14
|
},
|
|
15
15
|
script: {
|
|
16
16
|
type: "string",
|
|
17
|
-
description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {\n size radius\n color red\n}\n\n### Control Flow:\n\nFor loops with variables:\nfor i in 1 to 5 {\n cube {\n position (i * 2) 0 0\n size 1\n }\n}\n\nFor loops with step:\nfor i in 0 to 10 step 2 {\n sphere { position 0 i 0 }\n}\n\nIf/else conditionals:\ndefine showSphere 1\nif showSphere {\n sphere { size 2 }\n} else {\n cube { size 2 }\n}\n\nSwitch statements:\ndefine shape 2\nswitch shape {\ncase 1\n cube\ncase 2\n sphere\nelse\n cone\n}\n\n### Built-in Functions:\n\nMath: round, floor, ceil, abs, sign, sqrt, pow, min, max\nTrig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)\nVector: dot, cross, length, normalize, sum\nColour: rgb(r g b [a]), hsb(h s b [a]); strings: join, split, trim\n\nTwo call spellings, both as upstream: C-like max(0 (j - 1)) with NO space before the parenthesis, or the\nbare form max 0 (j - 1) / sqrt 9 / sin pi / 2, where the function takes every value after it. Separate\narguments with spaces; commas also work here (max(0, j - 1)) but NOT in the upstream ShapeScript app.\nInside a larger expression parenthesise a bare call: (sqrt 9) + (sqrt 16).\nCustom functions: define hyp(a b) { sqrt(a * a + b * b) } — parameters, optional defines, then the result\nexpression. A function may also build shapes: define face(data) { polygon { … } } returns what it built.\nWrite ONE statement per line. This parser accepts \"define a 1 define b 2\" on one line; the upstream app\nrejects it, and \"size 2 1 radius 0.5\" on one line reads radius as a fourth size component in both.\n\nExamples:\nfor i in 1 to 8 {\n define angle (i * 0.785) // 45 degrees in radians\n cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }\n}\n\n### Primitives & Properties:\n\nShapes: cube, sphere, icosphere, cylinder, cone, torus, circle, square, roundrect (radius 0–0.5 of the smaller side), polygon (sides 3–256)\nProperties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z, detail N, smoothing N, name \"label\"\nMaterials (as properties or as scoped commands): color, opacity, metallicity, roughness, glow, material NAME\n- color takes 1–4 values: luminance, luminance+alpha, RGB, RGBA. Also hex #F00 / #FF0000 / #FF000080, the names\n black blue green cyan red magenta purple yellow white orange gray/grey, hsb(...), and \"color red 0.5\" to set alpha.\n- opacity multiplies through nested scopes (opacity 0.5 twice = 0.25); glow is an emissive colour; smoothing 0 = flat shading.\n- define shiny material { color blue metallicity 1 roughness 0.1 } bundles properties; apply with material shiny.\n- texture \"file.png\" and background \"file.png\" are accepted with a warning (not drawn); background R G B sets the scene colour.\n- camera { … } and light { … } blocks are accepted and skipped with a warning.\n\nUNITS (same as upstream ShapeScript — https://shapescript.info/mac/):\n- size is the DIAMETER of sphere/icosphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length. size 1 2 means 1 2 1 (the third value repeats the first).\n- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.\n- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.\n- SCOPE: a shape block, group, builder or custom block resets transforms and materials at its closing brace.\n for / if / switch bodies do NOT: a translate inside a loop carries on after it (upstream's rule). Symbols\n (define) are scoped by every block.\n- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.\n\n### CSG Operations:\nunion, difference, intersection, xor, stencil\n\nExample:\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n cube { size 1.5 }\n}\n\n### Paths:\npath { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.\nA bare path draws as a LINE (stroke), as upstream; use fill / extrude / lathe / loft to make a surface or solid.\n- arc { angle A } inside a path: A half-turns clockwise from +Y, radius size/2 (default 0.5), with optional\n position / orientation / size — e.g. two quarter arcs and two points make a rounded slab.\n- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.\n- A path may carry position / orientation / size of its own (path { position 0 0 2 orientation 0 0.5 0 point … }); that is how a loft section is placed in 3D. Give loft and extrude PATH children, not fill{} meshes — the upstream app rejects a mesh there.\n- rotate (half-turns) / translate / scale inside a path move the frame for later points:\n path {\n for 0 to 8 {\n curve 0 1\n rotate 1 / 8\n }\n } // semicircle\n\n### Builders:\n- extrude: extrude polygon { sides 3 } / extrude { … } or an inline path (size X Y scale the profile, size Z = depth, default 1):\n extrude path {\n point 0 0\n point 1 0\n point 0 1\n point 0 0\n }\n- fill: fill { square } or fill path { ... }\n- lathe (revolves the XY profile about Y):\n lathe path {\n point 0 0\n point 1 0\n curve 1.5 1\n point 1 2\n point 0 2\n }\n- loft (closed planar sections joined with caps):\n loft {\n square\n translate 0 0 2\n circle\n }\n- hull (convex envelope):\n hull {\n cube { position -1 0 0 }\n cube { position 1 0 0 }\n }\n- stencil preserves the first shape and paints its surface with later shapes' materials.\n- minkowski (the Minkowski sum; with inset it rounds edges, as upstream's Fillet example does):\n define fillet(source radius) {\n minkowski {\n inset(source radius)\n sphere { size radius * 2 }\n }\n }\n fillet(cone { color red } 0.1)\n- extrude … along (a section swept along a path, capped at the ends of an open path):\n extrude {\n circle { size 0.1 }\n along path { for i in 0 to 20 { curve 0 1 - i / 20 rotate 0.2 } }\n }\nLoft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.\nAn extrude path is a solid only when it is closed (its last point repeats its first); an open path extrudes\nto a wall, as upstream. inset(mesh distance) moves a mesh value's faces inward (outward when negative).\nA material command inside a builder block (extrude { color red … }) colours the result; size on a builder or\ngroup scales it. Not supported: extrude twist, svgpath.\n- text \"Hello\" / text { size 0.5 wrapwidth 3 linespacing 0.2 \"Line one\" \"Line two\" }: glyph outlines in the built-in\n Helvetica-like font, left margin at x 0 and first baseline at y 0, one unit per line (size scales it). Bare text draws\n outlines; fill text \"Hi\" makes faces and extrude { size 1 1 0.3 text \"Hi\" } solids. Values interpolate:\n text \"Bob has \" apples \" apples\", text i. Centre it with its bounds: define t text \"Hi\" then\n translate -t.bounds.width/2 -t.bounds.height/2 before fill t. font is accepted and ignored (one face only).\n- mesh { polygon { point x y z … } … }: a mesh from explicit faces; polygon { color red point a point b point c }\n 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 } }.\n\n### Additional Expressions:\n- Constants: pi, true, false (tau exists here but NOT in the upstream app; write 2 * pi)\n- A lone position / translate value is X alone (position 1 = 1 0 0); a lone size is uniform; a lone orientation is a roll.\n- Scientific notation and unary plus: 1e-3, +2\n- Ranges as values: define loops 1 to 5 step 2, then for i in loops { … }, for i in loops step 1, and\n \"if 3 in loops\"; the in operator also tests tuples (2 in (1 2 3)) and strings.\n- Tuple/vector members: .x .y .z, .width .height .depth, .roll .yaw .pitch, .red .green .blue .alpha, .hue .saturation .brightness\n- Tuple/string length: value.count; zero-based indexing values[0], negative from the end values[-1], by name values[\"y\"];\n ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast\n- String literals, join(...), split(...), trim(...); min/max also accept tuples\n- print a b … records output that is returned with the tool result; assert condition stops the script when false\n- Custom shapes with options:\ndefine post {\n option height 2\n cylinder { size 0.2 height }\n}\npost { height 3 }\n- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)\n- Shapes as values: define ico icosphere { detail 0 } then ico (places it), ico.polygons (faces, each with\n .center .points .bounds), ico.triangles, ico.bounds (.min .max .center .size .width .height .depth), ico.volume.\n- for / if as expressions: define scales for i in 1 to 3 { i / 3 }; define c if big { red } else { white }\n- Functions may build shapes: define face(data) { polygon { … } } and are called bare as statements: face data\n\n### Compatibility:\nThis plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units, scoping,\nmaterials and path semantics follow upstream, so a script written against the upstream docs renders the\nsame here. Not supported (each is refused by name): import, svgpath, extrude twist,\nobject values and paths as values. Textures, fonts, cameras and lights are accepted but not drawn.\n\n### Comments:\n// Single-line comment\n/* Multi-line\n comment */\n\n## COMPLETE EXAMPLES:\n\nLinear arrangement with expressions:\ndefine spacing 1.5\nfor i in 1 to 4 {\n cylinder {\n position ((i - 2.5) * spacing) 0 0\n size 0.4 1\n }\n}\n\nCircular pattern:\ndefine count 12\nfor i in 1 to count {\n define angle ((i / count) * 6.283) // 2 * PI\n cube {\n position (cos(angle) * 3) 0 (sin(angle) * 3)\n color (i / count) 0.5 (1 - i / count)\n size 0.5\n }\n}\n\nConditional geometry:\ndefine makeHollow 1\nif makeHollow {\n difference {\n sphere {\n size 2\n color (1 0 0)\n }\n sphere { size 1.7 }\n }\n} else {\n sphere {\n size 2\n color (1 0 0)\n }\n}\n\nMathematical visualization:\nfor x in -5 to 5 {\n for z in -5 to 5 {\n define height (sin(x * 0.5) * cos(z * 0.5) * 2)\n cube {\n position (x * 0.3) height (z * 0.3)\n size 0.25 (abs(height) + 0.1) 0.25\n color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)\n }\n }\n}"
|
|
17
|
+
description: "ShapeScript code defining the 3D scene. Supported features and syntax are listed below. Syntax, evaluation, geometry and resource-limit errors are returned as diagnostics; correct the script and retry.\n\n## SYNTAX OVERVIEW:\n\n### Expressions & Operators:\n- Arithmetic: +, -, *, /, % with proper precedence\n- Comparison: =, <>, <, <=, >, >=\n- Boolean: and, or, not\n- Parentheses for grouping: (2 + 3) * 4\n\n### Variables:\ndefine radius 2\ndefine red (1 0 0)\nsphere {\n size radius\n color red\n}\n\n### Control Flow:\n\nFor loops with variables:\nfor i in 1 to 5 {\n cube {\n position (i * 2) 0 0\n size 1\n }\n}\n\nFor loops with step:\nfor i in 0 to 10 step 2 {\n sphere { position 0 i 0 }\n}\n\nIf/else conditionals:\ndefine showSphere 1\nif showSphere {\n sphere { size 2 }\n} else {\n cube { size 2 }\n}\n\nSwitch statements:\ndefine shape 2\nswitch shape {\ncase 1\n cube\ncase 2\n sphere\nelse\n cone\n}\n\n### Built-in Functions:\n\nMath: round, floor, ceil, abs, sign, sqrt, pow, min, max\nTrig: sin, cos, tan, asin, acos, atan, atan2 (uses radians)\nVector: dot, cross, length, normalize, sum\nColour: rgb(r g b [a]), hsb(h s b [a]); strings: join, split, trim\n\nTwo call spellings, both as upstream: C-like max(0 (j - 1)) with NO space before the parenthesis, or the\nbare form max 0 (j - 1) / sqrt 9 / sin pi / 2, where the function takes every value after it. Separate\narguments with spaces; commas also work here (max(0, j - 1)) but NOT in the upstream ShapeScript app.\nInside a larger expression parenthesise a bare call: (sqrt 9) + (sqrt 16).\nCustom functions: define hyp(a b) { sqrt(a * a + b * b) } — parameters, optional defines, then the result\nexpression. A function may also build shapes: define face(data) { polygon { … } } returns what it built.\nWrite ONE statement per line: \"define a 1 define b 2\" on one line is a parse error here, as in the upstream\napp, where \"size 2 1 radius 0.5\" reads radius as a fourth size component.\n\nExamples:\nfor i in 1 to 8 {\n define angle (i * 0.785) // 45 degrees in radians\n cube { position (cos(angle) * 3) 0 (sin(angle) * 3) }\n}\n\n### Primitives & Properties:\n\nShapes: cube, sphere, icosphere, cylinder, cone, torus, circle, square, roundrect (radius 0–0.5 of the smaller side), polygon (sides 3–256)\nProperties: position X Y Z, orientation ROLL YAW PITCH (alias: rotation), size X Y Z, detail N, smoothing N, name \"label\"\nMaterials (as properties or as scoped commands): color, opacity, metallicity, roughness, glow, material NAME\n- color takes 1–4 values: luminance, luminance+alpha, RGB, RGBA. Also hex #F00 / #FF0000 / #FF000080, the names\n black blue green cyan red magenta purple yellow white orange gray/grey, hsb(...), and \"color red 0.5\" to set alpha.\n- opacity multiplies through nested scopes (opacity 0.5 twice = 0.25); glow is an emissive colour; smoothing 0 = flat shading.\n- define shiny material { color blue metallicity 1 roughness 0.1 } bundles properties; apply with material shiny.\n- texture \"file.png\" and background \"file.png\" are accepted with a warning (not drawn); background R G B sets the scene colour.\n- camera { … } and light { … } blocks are accepted and skipped with a warning.\n\nUNITS (same as upstream ShapeScript — https://shapescript.info/mac/):\n- size is the DIAMETER of sphere/icosphere/cylinder/cone/circle/polygon/torus (a bare sphere fits the unit cube); for cube/square it is the edge length. size 1 2 means 1 2 1 (the third value repeats the first).\n- orientation / rotate use HALF-TURNS in roll (Z), yaw (Y), pitch (X) order: 0.5 = 90°, 1 = 180°. Positive is clockwise. A lone value is a roll: orientation 0.25 = 45° about Z. Angle-axis also works: orientation 0.5 0 1 0.\n- rotate / translate / scale as commands are relative and accumulate; orientation as a command is absolute.\n- SCOPE: a shape block, group, builder or custom block resets transforms and materials at its closing brace.\n for / if / switch bodies do NOT: a translate inside a loop carries on after it (upstream's rule). Symbols\n (define) are scoped by every block.\n- Trig FUNCTIONS (sin, cos, …) still take radians. Convert with pi: a half-turn value h is h * pi radians.\n\n### CSG Operations:\nunion, difference, intersection, xor, stencil\n\nExample:\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n cube { size 1.5 }\n}\n\n### Paths:\npath { point X Y … } — coordinates are ABSOLUTE in the path's frame. Close a path by repeating the first point.\nA bare path draws as a LINE (stroke), as upstream; use fill / extrude / lathe / loft to make a surface or solid.\n- arc { angle A } inside a path: A half-turns clockwise from +Y, radius size/2 (default 0.5), with optional\n position / orientation / size — e.g. two quarter arcs and two points make a rounded slab.\n- curve X Y is a quadratic Bézier CONTROL point: the outline passes through the point commands on either side, not through it. Two curves in a row get an implicit on-curve midpoint, so eight curves in an octagon draw a circle.\n- A path may carry position / orientation / size of its own (path { position 0 0 2 … } 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.\n- rotate (half-turns) / translate / scale inside a path move the frame for later points:\n path {\n for 0 to 8 {\n curve 0 1\n rotate 1 / 8\n }\n } // semicircle\n\n### Builders:\n- extrude: extrude polygon { sides 3 } / extrude { … } or an inline path (size X Y scale the profile, size Z = depth, default 1):\n extrude path {\n point 0 0\n point 1 0\n point 0 1\n point 0 0\n }\n- fill: fill { square } or fill path { ... }\n- lathe (revolves the XY profile about Y):\n lathe path {\n point 0 0\n point 1 0\n curve 1.5 1\n point 1 2\n point 0 2\n }\n- loft (closed planar sections joined with caps):\n loft {\n square\n translate 0 0 2\n circle\n }\n- hull (convex envelope):\n hull {\n cube { position -1 0 0 }\n cube { position 1 0 0 }\n }\n- stencil preserves the first shape and paints its surface with later shapes' materials.\n- minkowski (the Minkowski sum; with inset it rounds edges, as upstream's Fillet example does):\n define fillet(source radius) {\n minkowski {\n inset(source radius)\n sphere { size radius * 2 }\n }\n }\n fillet(cone { color red } 0.1)\n- extrude … along (a section swept along a path, capped at the ends of an open path):\n extrude {\n circle { size 0.1 }\n along path { for i in 0 to 20 { curve 0 1 - i / 20 rotate 0.2 } }\n }\nLoft sections must each have one perimeter and enclose an area; extrude/fill primitive profiles must lie in XY.\nAn extrude path is a solid only when it is closed (its last point repeats its first); an open path extrudes\nto a wall, as upstream. inset(mesh distance) moves a mesh value's faces inward (outward when negative).\nA material command inside a builder block (extrude { color red … }) colours the result; size on a builder or\ngroup scales it. Not supported: extrude twist, svgpath.\n- text \"Hello\" / text { size 0.5 … } with wrapwidth, linespacing and each \"line\" on its own line: glyph outlines in the built-in\n Helvetica-like font, left margin at x 0 and first baseline at y 0, one unit per line (size scales it). Bare text draws\n outlines; fill text \"Hi\" makes faces and extrude { size 1 1 0.3 text \"Hi\" } solids. Values interpolate:\n text \"Bob has \" apples \" apples\", text i. Centre it with its bounds: define t text \"Hi\" then\n translate -t.bounds.width/2 -t.bounds.height/2 before fill t. font is accepted and ignored (one face only).\n- mesh { polygon { point x y z … } … }: a mesh from explicit faces; polygon { color red … point a … }\n (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 } }.\n\n### Additional Expressions:\n- Constants: pi, true, false (there is no tau; write 2 * pi)\n- ONE STATEMENT PER LINE, as in the upstream app: sphere { position 0 1 0 size 2 } is refused (upstream reads it as a\n position with five arguments). Put each property, point and shape on its own line; a block may open on its\n statement's line and close on its own.\n- A lone position / translate value is X alone (position 1 = 1 0 0); a lone size is uniform; a lone orientation is a roll.\n- Scientific notation and unary plus: 1e-3, +2\n- Ranges as values: define loops 1 to 5 step 2, then for i in loops { … }, for i in loops step 1, and\n \"if 3 in loops\"; the in operator also tests tuples (2 in (1 2 3)) and strings.\n- Tuple/vector members: .x .y .z, .width .height .depth, .roll .yaw .pitch, .red .green .blue .alpha, .hue .saturation .brightness\n- Tuple/string length: value.count; zero-based indexing values[0], negative from the end values[-1], by name values[\"y\"];\n ordinals: v.first v.second … v.last, v.allButFirst, v.allButLast\n- String literals, join(...), split(...), trim(...); min/max also accept tuples\n- print a b … records output that is returned with the tool result; assert condition stops the script when false\n- Custom shapes with options:\ndefine post {\n option height 2\n cylinder { size 0.2 height }\n}\npost { height 3 }\n- Random numbers: rnd (0–1) and seed N (scoped to the enclosing block, same generator as upstream)\n- Shapes as values: define ico icosphere { detail 0 } then ico (places it), ico.polygons (faces, each with\n .center .points .bounds), ico.triangles, ico.bounds (.min .max .center .size .width .height .depth), ico.volume.\n- for / if as expressions: define scales for i in 1 to 3 { i / 3 }; define c if big { red } else { white }\n- Functions may build shapes: define face(data) { polygon { … } } and are called bare as statements: face data\n\n### Compatibility:\nThis plugin implements the documented modeling subset, not all upstream ShapeScript syntax; units, scoping,\nmaterials and path semantics follow upstream, so a script written against the upstream docs renders the\nsame here. Not supported (each is refused by name): import, svgpath, extrude twist,\nobject values and paths as values. Textures, fonts, cameras and lights are accepted but not drawn.\n\n### Comments:\n// Single-line comment\n/* Multi-line\n comment */\n\n## COMPLETE EXAMPLES:\n\nLinear arrangement with expressions:\ndefine spacing 1.5\nfor i in 1 to 4 {\n cylinder {\n position ((i - 2.5) * spacing) 0 0\n size 0.4 1\n }\n}\n\nCircular pattern:\ndefine count 12\nfor i in 1 to count {\n define angle ((i / count) * 6.283) // 2 * PI\n cube {\n position (cos(angle) * 3) 0 (sin(angle) * 3)\n color (i / count) 0.5 (1 - i / count)\n size 0.5\n }\n}\n\nConditional geometry:\ndefine makeHollow 1\nif makeHollow {\n difference {\n sphere {\n size 2\n color (1 0 0)\n }\n sphere { size 1.7 }\n }\n} else {\n sphere {\n size 2\n color (1 0 0)\n }\n}\n\nMathematical visualization:\nfor x in -5 to 5 {\n for z in -5 to 5 {\n define height (sin(x * 0.5) * cos(z * 0.5) * 2)\n cube {\n position (x * 0.3) height (z * 0.3)\n size 0.25 (abs(height) + 0.1) 0.25\n color (0.5 + height * 0.25) 0.3 (0.5 - height * 0.25)\n }\n }\n}"
|
|
18
18
|
},
|
|
19
19
|
path: {
|
|
20
20
|
type: "string",
|
|
@@ -23,11 +23,11 @@ var h = "presentShapeScript", g = {
|
|
|
23
23
|
},
|
|
24
24
|
required: ["title"]
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
function
|
|
28
|
-
return
|
|
26
|
+
}, x = "shapes", S = "shape", C = [".shape"];
|
|
27
|
+
function w(e, t = S) {
|
|
28
|
+
return _(e, t);
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function T() {
|
|
31
31
|
let e = globalThis.crypto;
|
|
32
32
|
if (e?.getRandomValues) {
|
|
33
33
|
let t = e.getRandomValues(/* @__PURE__ */ new Uint8Array(4));
|
|
@@ -35,61 +35,61 @@ function x() {
|
|
|
35
35
|
}
|
|
36
36
|
return Math.random().toString(16).slice(2, 10).padEnd(8, "0");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
let r =
|
|
40
|
-
dir:
|
|
38
|
+
function E(e, t = /* @__PURE__ */ new Date(), n = T()) {
|
|
39
|
+
let r = m({
|
|
40
|
+
dir: x,
|
|
41
41
|
title: e,
|
|
42
42
|
ext: ".shape",
|
|
43
|
-
fallback:
|
|
43
|
+
fallback: S,
|
|
44
44
|
now: t,
|
|
45
45
|
partitioned: !1,
|
|
46
46
|
suffix: n
|
|
47
47
|
});
|
|
48
48
|
return {
|
|
49
49
|
relPath: r,
|
|
50
|
-
filePath:
|
|
50
|
+
filePath: v(r)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
let r =
|
|
55
|
-
dir:
|
|
53
|
+
function D(e, t = /* @__PURE__ */ new Date(), n = T()) {
|
|
54
|
+
let r = m({
|
|
55
|
+
dir: x,
|
|
56
56
|
title: e,
|
|
57
57
|
ext: ".usdz",
|
|
58
|
-
fallback:
|
|
58
|
+
fallback: S,
|
|
59
59
|
now: t,
|
|
60
60
|
partitioned: !1,
|
|
61
61
|
suffix: n
|
|
62
62
|
});
|
|
63
63
|
return {
|
|
64
64
|
relPath: r,
|
|
65
|
-
filePath:
|
|
65
|
+
filePath: v(r)
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return !e.startsWith(`${
|
|
68
|
+
function O(e) {
|
|
69
|
+
return !e.startsWith(`${p}/${x}/`) || !e.endsWith(".shape") ? !1 : !g(e);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return e.startsWith(`${
|
|
71
|
+
function k(e) {
|
|
72
|
+
return e.startsWith(`${p}/`) ? e.slice(p.length + 1) : e;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return
|
|
74
|
+
function A(e) {
|
|
75
|
+
return h(e, C) !== null;
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/core/dispatch.ts
|
|
79
|
-
function
|
|
80
|
-
if (
|
|
79
|
+
function j(e, t) {
|
|
80
|
+
if (O(t)) return {
|
|
81
81
|
files: e.files.artifacts,
|
|
82
|
-
rel:
|
|
82
|
+
rel: k(t)
|
|
83
83
|
};
|
|
84
84
|
let n = e.files.byPath;
|
|
85
|
-
return n &&
|
|
85
|
+
return n && A(t) ? {
|
|
86
86
|
files: n,
|
|
87
87
|
rel: t
|
|
88
88
|
} : null;
|
|
89
89
|
}
|
|
90
|
-
async function
|
|
90
|
+
async function M(e, t) {
|
|
91
91
|
if (typeof t?.path != "string") throw Error("path must be an existing .shape file");
|
|
92
|
-
let n =
|
|
92
|
+
let n = j(e, t.path);
|
|
93
93
|
if (!n) throw Error("path must be an existing .shape file");
|
|
94
94
|
switch (t.kind) {
|
|
95
95
|
case "loadShape": return { script: await n.files.read(n.rel) };
|
|
@@ -102,81 +102,81 @@ async function O(e, t) {
|
|
|
102
102
|
}
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/core/plugin.ts
|
|
105
|
-
var
|
|
106
|
-
function
|
|
107
|
-
let
|
|
108
|
-
return t
|
|
105
|
+
var N = "Acknowledge that the 3D visualization has been created and is displayed to the user. They can rotate, zoom, and pan the camera.", P = (e) => typeof e == "string" && e.trim() !== "";
|
|
106
|
+
function F(e) {
|
|
107
|
+
let t = l(u(e)), n = a(t);
|
|
108
|
+
return r(t), n;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function ee(e) {
|
|
111
111
|
let t = [];
|
|
112
112
|
return e.warnings.length && t.push(`Not rendered: ${e.warnings.join("; ")}`), e.logs.length && t.push(`Output:\n${e.logs.join("\n")}`), t.length ? `\n${t.join("\n")}` : "";
|
|
113
113
|
}
|
|
114
|
-
async function
|
|
114
|
+
async function I(e, t) {
|
|
115
115
|
let n = e.files;
|
|
116
116
|
if (!n) throw Error("This host cannot open a ShapeScript by path — pass the source as `script` instead");
|
|
117
|
-
let r =
|
|
117
|
+
let r = j({ files: n }, t);
|
|
118
118
|
if (!r) throw Error("`path` must be a .shape file, without `.` / `..` segments");
|
|
119
119
|
if (!await r.files.exists(r.rel)) throw Error(`No ShapeScript exists at ${t}`);
|
|
120
120
|
return r.files.read(r.rel);
|
|
121
121
|
}
|
|
122
|
-
var
|
|
123
|
-
async function
|
|
122
|
+
var L = 5;
|
|
123
|
+
async function R(e, t, n) {
|
|
124
124
|
let r = e.files?.artifacts;
|
|
125
125
|
if (r) {
|
|
126
|
-
for (let e = 0; e <
|
|
127
|
-
let { relPath: e, filePath: i } =
|
|
126
|
+
for (let e = 0; e < L; e++) {
|
|
127
|
+
let { relPath: e, filePath: i } = E(n);
|
|
128
128
|
if (!await r.exists(e)) return await r.write(e, t), i;
|
|
129
129
|
}
|
|
130
130
|
throw Error("Could not allocate a free path under artifacts/shapes — try again with a different title");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
async function
|
|
134
|
-
if (
|
|
135
|
-
if (
|
|
136
|
-
script: await
|
|
133
|
+
async function z(e, t) {
|
|
134
|
+
if (P(t.path) && P(t.script)) throw Error("Provide either `script` or `path`, not both");
|
|
135
|
+
if (P(t.path)) return {
|
|
136
|
+
script: await I(e, t.path),
|
|
137
137
|
filePath: t.path
|
|
138
138
|
};
|
|
139
|
-
if (!
|
|
139
|
+
if (!P(t.script)) throw Error("ShapeScript code is required but was not provided");
|
|
140
140
|
return { script: t.script };
|
|
141
141
|
}
|
|
142
|
-
var
|
|
142
|
+
var B = async (t, n) => {
|
|
143
143
|
let r = "INVALID_ARGUMENT";
|
|
144
144
|
try {
|
|
145
|
-
if (!
|
|
146
|
-
if (!
|
|
147
|
-
let
|
|
145
|
+
if (!e(n)) throw Error("presentShapeScript args must be an object with `script` or `path`");
|
|
146
|
+
if (!P(n.title)) throw Error("A nonempty visualization title is required");
|
|
147
|
+
let i = await z(t ?? {}, n);
|
|
148
148
|
r = "EVALUATION_ERROR";
|
|
149
|
-
let
|
|
149
|
+
let a = F(i.script), o = i.filePath ?? await R(t ?? {}, i.script, n.title);
|
|
150
150
|
return {
|
|
151
|
-
message: (
|
|
151
|
+
message: (o ? `Saved ShapeScript to ${o}` : `Created 3D visualization: ${n.title}`) + ee(a),
|
|
152
152
|
title: n.title,
|
|
153
|
-
data:
|
|
154
|
-
script:
|
|
155
|
-
filePath:
|
|
156
|
-
} : { script:
|
|
157
|
-
instructions:
|
|
153
|
+
data: o ? {
|
|
154
|
+
script: i.script,
|
|
155
|
+
filePath: o
|
|
156
|
+
} : { script: i.script },
|
|
157
|
+
instructions: N
|
|
158
158
|
};
|
|
159
|
-
} catch (
|
|
160
|
-
let
|
|
161
|
-
code:
|
|
162
|
-
message:
|
|
163
|
-
...
|
|
164
|
-
...
|
|
159
|
+
} catch (e) {
|
|
160
|
+
let t = {
|
|
161
|
+
code: e instanceof f ? "PARSE_ERROR" : e instanceof s ? "LIMIT_EXCEEDED" : r,
|
|
162
|
+
message: e instanceof Error ? e.message : String(e),
|
|
163
|
+
...e instanceof f && e.line !== void 0 ? { line: e.line } : {},
|
|
164
|
+
...e instanceof f && e.column !== void 0 ? { column: e.column } : {}
|
|
165
165
|
};
|
|
166
166
|
return {
|
|
167
|
-
message: `ShapeScript error: ${
|
|
168
|
-
error:
|
|
169
|
-
jsonData: { error:
|
|
167
|
+
message: `ShapeScript error: ${t.message}`,
|
|
168
|
+
error: t,
|
|
169
|
+
jsonData: { error: t },
|
|
170
170
|
instructions: "The visualization was not created. Correct the ShapeScript using the returned diagnostic and call presentShapeScript again."
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
},
|
|
174
|
-
toolDefinition:
|
|
175
|
-
execute:
|
|
173
|
+
}, V = {
|
|
174
|
+
toolDefinition: b,
|
|
175
|
+
execute: B,
|
|
176
176
|
generatingMessage: "Creating 3D visualization...",
|
|
177
177
|
waitingMessage: "Tell the user that the 3D visualization was created and will be presented shortly.",
|
|
178
178
|
isEnabled: () => !0
|
|
179
|
-
},
|
|
179
|
+
}, te = B, H = Uint8Array, U = Uint16Array, ne = Int32Array, re = new H([
|
|
180
180
|
0,
|
|
181
181
|
0,
|
|
182
182
|
0,
|
|
@@ -209,7 +209,7 @@ var I = async (t, n) => {
|
|
|
209
209
|
0,
|
|
210
210
|
0,
|
|
211
211
|
0
|
|
212
|
-
]),
|
|
212
|
+
]), ie = new H([
|
|
213
213
|
0,
|
|
214
214
|
0,
|
|
215
215
|
0,
|
|
@@ -242,7 +242,7 @@ var I = async (t, n) => {
|
|
|
242
242
|
13,
|
|
243
243
|
0,
|
|
244
244
|
0
|
|
245
|
-
]),
|
|
245
|
+
]), W = new H([
|
|
246
246
|
16,
|
|
247
247
|
17,
|
|
248
248
|
18,
|
|
@@ -262,42 +262,42 @@ var I = async (t, n) => {
|
|
|
262
262
|
14,
|
|
263
263
|
1,
|
|
264
264
|
15
|
|
265
|
-
]),
|
|
266
|
-
for (var n = new
|
|
267
|
-
for (var i = new
|
|
265
|
+
]), ae = function(e, t) {
|
|
266
|
+
for (var n = new U(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
|
|
267
|
+
for (var i = new ne(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
|
|
268
268
|
return {
|
|
269
269
|
b: n,
|
|
270
270
|
r: i
|
|
271
271
|
};
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
for (var
|
|
277
|
-
var
|
|
278
|
-
|
|
272
|
+
}, oe = ae(re, 2), se = oe.b, ce = oe.r;
|
|
273
|
+
se[28] = 258, ce[258] = 28;
|
|
274
|
+
var G = ae(ie, 0);
|
|
275
|
+
G.b;
|
|
276
|
+
for (var le = G.r, ue = new U(32768), K = 0; K < 32768; ++K) {
|
|
277
|
+
var q = (K & 43690) >> 1 | (K & 21845) << 1;
|
|
278
|
+
q = (q & 52428) >> 2 | (q & 13107) << 2, q = (q & 61680) >> 4 | (q & 3855) << 4, ue[K] = ((q & 65280) >> 8 | (q & 255) << 8) >> 1;
|
|
279
279
|
}
|
|
280
|
-
for (var
|
|
281
|
-
for (var r = e.length, i = 0, a = new
|
|
282
|
-
var o = new
|
|
280
|
+
for (var J = (function(e, t, n) {
|
|
281
|
+
for (var r = e.length, i = 0, a = new U(t); i < r; ++i) e[i] && ++a[e[i] - 1];
|
|
282
|
+
var o = new U(t);
|
|
283
283
|
for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
|
|
284
284
|
var s;
|
|
285
285
|
if (n) {
|
|
286
|
-
s = new
|
|
286
|
+
s = new U(1 << t);
|
|
287
287
|
var c = 15 - t;
|
|
288
|
-
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[
|
|
289
|
-
} else for (s = new
|
|
288
|
+
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[ue[d] >> c] = l;
|
|
289
|
+
} else for (s = new U(r), i = 0; i < r; ++i) e[i] && (s[i] = ue[o[e[i] - 1]++] >> 15 - e[i]);
|
|
290
290
|
return s;
|
|
291
|
-
}),
|
|
292
|
-
for (var
|
|
293
|
-
for (var
|
|
294
|
-
for (var
|
|
295
|
-
for (var
|
|
296
|
-
var
|
|
291
|
+
}), Y = new H(288), K = 0; K < 144; ++K) Y[K] = 8;
|
|
292
|
+
for (var K = 144; K < 256; ++K) Y[K] = 9;
|
|
293
|
+
for (var K = 256; K < 280; ++K) Y[K] = 7;
|
|
294
|
+
for (var K = 280; K < 288; ++K) Y[K] = 8;
|
|
295
|
+
for (var de = new H(32), K = 0; K < 32; ++K) de[K] = 5;
|
|
296
|
+
var fe = /*#__PURE__*/ J(Y, 9, 0), pe = /*#__PURE__*/ J(de, 5, 0), me = function(e) {
|
|
297
297
|
return (e + 7) / 8 | 0;
|
|
298
|
-
},
|
|
299
|
-
return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new
|
|
300
|
-
},
|
|
298
|
+
}, he = function(e, t, n) {
|
|
299
|
+
return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new H(e.subarray(t, n));
|
|
300
|
+
}, ge = [
|
|
301
301
|
"unexpected EOF",
|
|
302
302
|
"invalid block type",
|
|
303
303
|
"invalid length/literal",
|
|
@@ -312,30 +312,30 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
312
312
|
"filename too long",
|
|
313
313
|
"stream finishing",
|
|
314
314
|
"invalid zip data"
|
|
315
|
-
],
|
|
316
|
-
var r = Error(t ||
|
|
317
|
-
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r,
|
|
315
|
+
], _e = function(e, t, n) {
|
|
316
|
+
var r = Error(t || ge[e]);
|
|
317
|
+
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, _e), !n) throw r;
|
|
318
318
|
return r;
|
|
319
|
-
},
|
|
319
|
+
}, X = function(e, t, n) {
|
|
320
320
|
n <<= t & 7;
|
|
321
321
|
var r = t / 8 | 0;
|
|
322
322
|
e[r] |= n, e[r + 1] |= n >> 8;
|
|
323
|
-
},
|
|
323
|
+
}, ve = function(e, t, n) {
|
|
324
324
|
n <<= t & 7;
|
|
325
325
|
var r = t / 8 | 0;
|
|
326
326
|
e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
|
|
327
|
-
},
|
|
327
|
+
}, ye = function(e, t) {
|
|
328
328
|
for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
|
|
329
329
|
s: r,
|
|
330
330
|
f: e[r]
|
|
331
331
|
});
|
|
332
332
|
var i = n.length, a = n.slice();
|
|
333
333
|
if (!i) return {
|
|
334
|
-
t:
|
|
334
|
+
t: Ee,
|
|
335
335
|
l: 0
|
|
336
336
|
};
|
|
337
337
|
if (i == 1) {
|
|
338
|
-
var o = new
|
|
338
|
+
var o = new H(n[0].s + 1);
|
|
339
339
|
return o[n[0].s] = 1, {
|
|
340
340
|
t: o,
|
|
341
341
|
l: 1
|
|
@@ -360,7 +360,7 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
360
360
|
r: c
|
|
361
361
|
};
|
|
362
362
|
for (var f = a[0].s, r = 1; r < i; ++r) a[r].s > f && (f = a[r].s);
|
|
363
|
-
var p = new
|
|
363
|
+
var p = new U(f + 1), m = be(n[u - 1], p, 0);
|
|
364
364
|
if (m > t) {
|
|
365
365
|
var r = 0, h = 0, g = m - t, _ = 1 << g;
|
|
366
366
|
for (a.sort(function(e, t) {
|
|
@@ -381,14 +381,14 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
381
381
|
m = t;
|
|
382
382
|
}
|
|
383
383
|
return {
|
|
384
|
-
t: new
|
|
384
|
+
t: new H(p),
|
|
385
385
|
l: m
|
|
386
386
|
};
|
|
387
|
-
},
|
|
388
|
-
return e.s == -1 ? Math.max(
|
|
389
|
-
},
|
|
387
|
+
}, be = function(e, t, n) {
|
|
388
|
+
return e.s == -1 ? Math.max(be(e.l, t, n + 1), be(e.r, t, n + 1)) : t[e.s] = n;
|
|
389
|
+
}, xe = function(e) {
|
|
390
390
|
for (var t = e.length; t && !e[--t];);
|
|
391
|
-
for (var n = new
|
|
391
|
+
for (var n = new U(++t), r = 0, i = e[0], a = 1, o = function(e) {
|
|
392
392
|
n[r++] = e;
|
|
393
393
|
}, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
|
|
394
394
|
else {
|
|
@@ -406,44 +406,44 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
406
406
|
c: n.subarray(0, r),
|
|
407
407
|
n: t
|
|
408
408
|
};
|
|
409
|
-
},
|
|
409
|
+
}, Se = function(e, t) {
|
|
410
410
|
for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
|
|
411
411
|
return n;
|
|
412
|
-
},
|
|
413
|
-
var r = n.length, i =
|
|
412
|
+
}, Ce = function(e, t, n) {
|
|
413
|
+
var r = n.length, i = me(t + 2);
|
|
414
414
|
e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
|
|
415
415
|
for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
|
|
416
416
|
return (i + 4 + r) * 8;
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
for (var d =
|
|
417
|
+
}, we = function(e, t, n, r, i, a, o, s, c, l, u) {
|
|
418
|
+
X(t, u++, n), ++i[256];
|
|
419
|
+
for (var d = ye(i, 15), f = d.t, p = d.l, m = ye(a, 15), h = m.t, g = m.l, _ = xe(f), v = _.c, y = _.n, b = xe(h), x = b.c, S = b.n, C = new U(19), w = 0; w < v.length; ++w) ++C[v[w] & 31];
|
|
420
420
|
for (var w = 0; w < x.length; ++w) ++C[x[w] & 31];
|
|
421
|
-
for (var T =
|
|
422
|
-
var k = l + 5 << 3, A =
|
|
423
|
-
if (c >= 0 && k <= A && k <= j) return
|
|
421
|
+
for (var T = ye(C, 7), E = T.t, D = T.l, O = 19; O > 4 && !E[W[O - 1]]; --O);
|
|
422
|
+
var k = l + 5 << 3, A = Se(i, Y) + Se(a, de) + o, j = Se(i, f) + Se(a, h) + o + 14 + 3 * O + Se(C, E) + 2 * C[16] + 3 * C[17] + 7 * C[18];
|
|
423
|
+
if (c >= 0 && k <= A && k <= j) return Ce(t, u, e.subarray(c, c + l));
|
|
424
424
|
var M, N, P, F;
|
|
425
|
-
if (
|
|
426
|
-
M =
|
|
427
|
-
var ee =
|
|
428
|
-
|
|
429
|
-
for (var w = 0; w < O; ++w)
|
|
425
|
+
if (X(t, u, 1 + (j < A)), u += 2, j < A) {
|
|
426
|
+
M = J(f, p, 0), N = f, P = J(h, g, 0), F = h;
|
|
427
|
+
var ee = J(E, D, 0);
|
|
428
|
+
X(t, u, y - 257), X(t, u + 5, S - 1), X(t, u + 10, O - 4), u += 14;
|
|
429
|
+
for (var w = 0; w < O; ++w) X(t, u + 3 * w, E[W[w]]);
|
|
430
430
|
u += 3 * O;
|
|
431
431
|
for (var I = [v, x], L = 0; L < 2; ++L) for (var R = I[L], w = 0; w < R.length; ++w) {
|
|
432
432
|
var z = R[w] & 31;
|
|
433
|
-
|
|
433
|
+
X(t, u, ee[z]), u += E[z], z > 15 && (X(t, u, R[w] >> 5 & 127), u += R[w] >> 12);
|
|
434
434
|
}
|
|
435
|
-
} else M =
|
|
435
|
+
} else M = fe, N = Y, P = pe, F = de;
|
|
436
436
|
for (var w = 0; w < s; ++w) {
|
|
437
|
-
var
|
|
438
|
-
if (
|
|
439
|
-
var z =
|
|
440
|
-
|
|
441
|
-
var
|
|
442
|
-
|
|
443
|
-
} else
|
|
437
|
+
var B = r[w];
|
|
438
|
+
if (B > 255) {
|
|
439
|
+
var z = B >> 18 & 31;
|
|
440
|
+
ve(t, u, M[z + 257]), u += N[z + 257], z > 7 && (X(t, u, B >> 23 & 31), u += re[z]);
|
|
441
|
+
var V = B & 31;
|
|
442
|
+
ve(t, u, P[V]), u += F[V], V > 3 && (ve(t, u, B >> 5 & 8191), u += ie[V]);
|
|
443
|
+
} else ve(t, u, M[B]), u += N[B];
|
|
444
444
|
}
|
|
445
|
-
return
|
|
446
|
-
},
|
|
445
|
+
return ve(t, u, M[256]), u + N[256];
|
|
446
|
+
}, Te = /*#__PURE__*/ new ne([
|
|
447
447
|
65540,
|
|
448
448
|
131080,
|
|
449
449
|
131088,
|
|
@@ -453,76 +453,76 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
453
453
|
1048832,
|
|
454
454
|
2114560,
|
|
455
455
|
2117632
|
|
456
|
-
]),
|
|
457
|
-
var o = a.z || e.length, s = new
|
|
456
|
+
]), Ee = /*#__PURE__*/ new H(0), De = function(e, t, n, r, i, a) {
|
|
457
|
+
var o = a.z || e.length, s = new H(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
|
|
458
458
|
if (t) {
|
|
459
459
|
u && (c[0] = a.r >> 3);
|
|
460
|
-
for (var d =
|
|
460
|
+
for (var d = Te[t - 1], f = d >> 13, p = d & 8191, m = (1 << n) - 1, h = a.p || new U(32768), g = a.h || new U(m + 1), _ = Math.ceil(n / 3), v = 2 * _, y = function(t) {
|
|
461
461
|
return (e[t] ^ e[t + 1] << _ ^ e[t + 2] << v) & m;
|
|
462
|
-
}, b = new
|
|
462
|
+
}, b = new ne(25e3), x = new U(288), S = new U(32), C = 0, w = 0, T = a.i || 0, E = 0, D = a.w || 0, O = 0; T + 2 < o; ++T) {
|
|
463
463
|
var k = y(T), A = T & 32767, j = g[k];
|
|
464
464
|
if (h[A] = j, g[k] = A, D <= T) {
|
|
465
465
|
var M = o - T;
|
|
466
466
|
if ((C > 7e3 || E > 24576) && (M > 423 || !l)) {
|
|
467
|
-
u =
|
|
467
|
+
u = we(e, c, 0, b, x, S, w, E, O, T - O, u), E = C = w = 0, O = T;
|
|
468
468
|
for (var N = 0; N < 286; ++N) x[N] = 0;
|
|
469
469
|
for (var N = 0; N < 30; ++N) S[N] = 0;
|
|
470
470
|
}
|
|
471
471
|
var P = 2, F = 0, ee = p, I = A - j & 32767;
|
|
472
|
-
if (M > 2 && k == y(T - I)) for (var L = Math.min(f, M) - 1, R = Math.min(32767, T),
|
|
472
|
+
if (M > 2 && k == y(T - I)) for (var L = Math.min(f, M) - 1, R = Math.min(32767, T), z = Math.min(258, M); I <= R && --ee && A != j;) {
|
|
473
473
|
if (e[T + P] == e[T + P - I]) {
|
|
474
|
-
for (var
|
|
475
|
-
if (
|
|
476
|
-
if (P =
|
|
477
|
-
for (var
|
|
478
|
-
var
|
|
479
|
-
|
|
474
|
+
for (var B = 0; B < z && e[T + B] == e[T + B - I]; ++B);
|
|
475
|
+
if (B > P) {
|
|
476
|
+
if (P = B, F = I, B > L) break;
|
|
477
|
+
for (var V = Math.min(I, B - 2), te = 0, N = 0; N < V; ++N) {
|
|
478
|
+
var W = T - I + N & 32767, ae = W - h[W] & 32767;
|
|
479
|
+
ae > te && (te = ae, j = W);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
A = j, j = h[A], I += A - j & 32767;
|
|
484
484
|
}
|
|
485
485
|
if (F) {
|
|
486
|
-
b[E++] = 268435456 |
|
|
487
|
-
var
|
|
488
|
-
w +=
|
|
486
|
+
b[E++] = 268435456 | ce[P] << 18 | le[F];
|
|
487
|
+
var oe = ce[P] & 31, se = le[F] & 31;
|
|
488
|
+
w += re[oe] + ie[se], ++x[257 + oe], ++S[se], D = T + P, ++C;
|
|
489
489
|
} else b[E++] = e[T], ++x[e[T]];
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
for (T = Math.max(T, D); T < o; ++T) b[E++] = e[T], ++x[e[T]];
|
|
493
|
-
u =
|
|
493
|
+
u = we(e, c, l, b, x, S, w, E, O, T - O, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = g, a.p = h, a.i = T, a.w = D);
|
|
494
494
|
} else {
|
|
495
495
|
for (var T = a.w || 0; T < o + l; T += 65535) {
|
|
496
|
-
var
|
|
497
|
-
|
|
496
|
+
var G = T + 65535;
|
|
497
|
+
G >= o && (c[u / 8 | 0] = l, G = o), u = Ce(c, u + 1, e.subarray(T, G));
|
|
498
498
|
}
|
|
499
499
|
a.i = o;
|
|
500
500
|
}
|
|
501
|
-
return
|
|
502
|
-
},
|
|
501
|
+
return he(s, 0, r + me(u) + i);
|
|
502
|
+
}, Oe = /*#__PURE__*/ (function() {
|
|
503
503
|
for (var e = /* @__PURE__ */ new Int32Array(256), t = 0; t < 256; ++t) {
|
|
504
504
|
for (var n = t, r = 9; --r;) n = (n & 1 && -306674912) ^ n >>> 1;
|
|
505
505
|
e[t] = n;
|
|
506
506
|
}
|
|
507
507
|
return e;
|
|
508
|
-
})(),
|
|
508
|
+
})(), ke = function() {
|
|
509
509
|
var e = -1;
|
|
510
510
|
return {
|
|
511
511
|
p: function(t) {
|
|
512
|
-
for (var n = e, r = 0; r < t.length; ++r) n =
|
|
512
|
+
for (var n = e, r = 0; r < t.length; ++r) n = Oe[n & 255 ^ t[r]] ^ n >>> 8;
|
|
513
513
|
e = n;
|
|
514
514
|
},
|
|
515
515
|
d: function() {
|
|
516
516
|
return ~e;
|
|
517
517
|
}
|
|
518
518
|
};
|
|
519
|
-
},
|
|
519
|
+
}, Ae = function(e, t, n, r, i) {
|
|
520
520
|
if (!i && (i = { l: 1 }, t.dictionary)) {
|
|
521
|
-
var a = t.dictionary.subarray(-32768), o = new
|
|
521
|
+
var a = t.dictionary.subarray(-32768), o = new H(a.length + e.length);
|
|
522
522
|
o.set(a), o.set(e, a.length), e = o, i.w = a.length;
|
|
523
523
|
}
|
|
524
|
-
return
|
|
525
|
-
},
|
|
524
|
+
return De(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);
|
|
525
|
+
}, je = function(e, t) {
|
|
526
526
|
var n = {};
|
|
527
527
|
for (var r in e) n[r] = e[r];
|
|
528
528
|
for (var r in t) n[r] = t[r];
|
|
@@ -530,65 +530,65 @@ var ue = /*#__PURE__*/ K(q, 9, 0), de = /*#__PURE__*/ K(le, 5, 0), fe = function
|
|
|
530
530
|
}, Z = function(e, t, n) {
|
|
531
531
|
for (; n; ++t) e[t] = n, n >>>= 8;
|
|
532
532
|
};
|
|
533
|
-
function
|
|
534
|
-
return
|
|
533
|
+
function Me(e, t) {
|
|
534
|
+
return Ae(e, t || {}, 0, 0);
|
|
535
535
|
}
|
|
536
|
-
var
|
|
536
|
+
var Ne = function(e, t, n, r) {
|
|
537
537
|
for (var i in e) {
|
|
538
538
|
var a = e[i], o = t + i, s = r;
|
|
539
|
-
Array.isArray(a) && (s =
|
|
539
|
+
Array.isArray(a) && (s = je(r, a[1]), a = a[0]), a instanceof H ? n[o] = [a, s] : (n[o += "/"] = [new H(0), s], Ne(a, o, n, r));
|
|
540
540
|
}
|
|
541
|
-
},
|
|
541
|
+
}, Pe = typeof TextEncoder < "u" && /*#__PURE__*/ new TextEncoder(), Fe = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
|
|
542
542
|
try {
|
|
543
|
-
|
|
543
|
+
Fe.decode(Ee, { stream: !0 });
|
|
544
544
|
} catch {}
|
|
545
|
-
function
|
|
545
|
+
function Ie(e, t) {
|
|
546
546
|
if (t) {
|
|
547
|
-
for (var n = new
|
|
547
|
+
for (var n = new H(e.length), r = 0; r < e.length; ++r) n[r] = e.charCodeAt(r);
|
|
548
548
|
return n;
|
|
549
549
|
}
|
|
550
|
-
if (
|
|
551
|
-
for (var i = e.length, a = new
|
|
550
|
+
if (Pe) return Pe.encode(e);
|
|
551
|
+
for (var i = e.length, a = new H(e.length + (e.length >> 1)), o = 0, s = function(e) {
|
|
552
552
|
a[o++] = e;
|
|
553
553
|
}, r = 0; r < i; ++r) {
|
|
554
554
|
if (o + 5 > a.length) {
|
|
555
|
-
var c = new
|
|
555
|
+
var c = new H(o + 8 + (i - r << 1));
|
|
556
556
|
c.set(a), a = c;
|
|
557
557
|
}
|
|
558
558
|
var l = e.charCodeAt(r);
|
|
559
559
|
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));
|
|
560
560
|
}
|
|
561
|
-
return
|
|
561
|
+
return he(a, 0, o);
|
|
562
562
|
}
|
|
563
|
-
var
|
|
563
|
+
var Le = function(e) {
|
|
564
564
|
var t = 0;
|
|
565
565
|
if (e) for (var n in e) {
|
|
566
566
|
var r = e[n].length;
|
|
567
|
-
r > 65535 &&
|
|
567
|
+
r > 65535 && _e(9), t += r + 4;
|
|
568
568
|
}
|
|
569
569
|
return t;
|
|
570
|
-
},
|
|
571
|
-
var c = r.length, l = n.extra, u = s && s.length, d =
|
|
570
|
+
}, Re = function(e, t, n, r, i, a, o, s) {
|
|
571
|
+
var c = r.length, l = n.extra, u = s && s.length, d = Le(l);
|
|
572
572
|
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;
|
|
573
573
|
var f = new Date(n.mtime == null ? Date.now() : n.mtime), p = f.getFullYear() - 1980;
|
|
574
|
-
if ((p < 0 || p > 119) &&
|
|
574
|
+
if ((p < 0 || p > 119) && _e(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) {
|
|
575
575
|
var h = l[m], g = h.length;
|
|
576
576
|
Z(e, t, +m), Z(e, t + 2, g), e.set(h, t + 4), t += 4 + g;
|
|
577
577
|
}
|
|
578
578
|
return u && (e.set(s, t), t += u), t;
|
|
579
|
-
},
|
|
579
|
+
}, ze = function(e, t, n, r, i) {
|
|
580
580
|
Z(e, t, 101010256), Z(e, t + 8, n), Z(e, t + 10, n), Z(e, t + 12, r), Z(e, t + 16, i);
|
|
581
581
|
};
|
|
582
|
-
function
|
|
582
|
+
function Be(e, t) {
|
|
583
583
|
t ||= {};
|
|
584
584
|
var n = {}, r = [];
|
|
585
|
-
|
|
585
|
+
Ne(e, "", n, t);
|
|
586
586
|
var i = 0, a = 0;
|
|
587
587
|
for (var o in n) {
|
|
588
|
-
var s = n[o], c = s[0], l = s[1], u = l.level == 0 ? 0 : 8, d =
|
|
589
|
-
f > 65535 &&
|
|
590
|
-
var _ = u ?
|
|
591
|
-
y.p(c), r.push(
|
|
588
|
+
var s = n[o], c = s[0], l = s[1], u = l.level == 0 ? 0 : 8, d = Ie(o), f = d.length, p = l.comment, m = p && Ie(p), h = m && m.length, g = Le(l.extra);
|
|
589
|
+
f > 65535 && _e(11);
|
|
590
|
+
var _ = u ? Me(c, l) : c, v = _.length, y = ke();
|
|
591
|
+
y.p(c), r.push(je(l, {
|
|
592
592
|
size: c.length,
|
|
593
593
|
crc: y.d(),
|
|
594
594
|
c: _,
|
|
@@ -599,13 +599,13 @@ function Ie(e, t) {
|
|
|
599
599
|
compression: u
|
|
600
600
|
})), i += 30 + f + g + v, a += 76 + 2 * (f + g) + (h || 0) + v;
|
|
601
601
|
}
|
|
602
|
-
for (var b = new
|
|
602
|
+
for (var b = new H(a + 22), x = i, S = a - i, C = 0; C < r.length; ++C) {
|
|
603
603
|
var d = r[C];
|
|
604
|
-
|
|
605
|
-
var w = 30 + d.f.length +
|
|
606
|
-
b.set(d.c, d.o + w),
|
|
604
|
+
Re(b, d.o, d, d.f, d.u, d.c.length);
|
|
605
|
+
var w = 30 + d.f.length + Le(d.extra);
|
|
606
|
+
b.set(d.c, d.o + w), Re(b, i, d, d.f, d.u, d.c.length, d.o, d.m), i += 16 + w + (d.m ? d.m.length : 0);
|
|
607
607
|
}
|
|
608
|
-
return
|
|
608
|
+
return ze(b, i, r.length, S, x), b;
|
|
609
609
|
}
|
|
610
610
|
//#endregion
|
|
611
611
|
//#region ../../../node_modules/three/examples/jsm/exporters/USDZExporter.js
|
|
@@ -649,7 +649,7 @@ var Q = class {
|
|
|
649
649
|
let s = o.join("\n");
|
|
650
650
|
return `${t}def ${this.type ? this.type + " " : ""}"${this.name}"${r}\n${t}{\n${s}\n${t}}`;
|
|
651
651
|
}
|
|
652
|
-
},
|
|
652
|
+
}, Ve = class {
|
|
653
653
|
constructor() {
|
|
654
654
|
this.textureUtils = null;
|
|
655
655
|
}
|
|
@@ -674,27 +674,27 @@ var Q = class {
|
|
|
674
674
|
}, t);
|
|
675
675
|
let n = /* @__PURE__ */ new Set(), r = {}, i = "model.usda";
|
|
676
676
|
r[i] = null;
|
|
677
|
-
let a =
|
|
677
|
+
let a = Ke(e, t.animations);
|
|
678
678
|
t.animationTracks = a;
|
|
679
679
|
let o = new Q("Root", "Xform"), s = new Q("Scenes", "Scope");
|
|
680
680
|
s.addMetadata("kind", "\"sceneLibrary\""), o.addChild(s);
|
|
681
681
|
let c = "Scene", l = new Q(c, "Xform");
|
|
682
682
|
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);
|
|
683
683
|
let u, d = {}, f = {};
|
|
684
|
-
e.isScene ?
|
|
685
|
-
let p =
|
|
686
|
-
u =
|
|
684
|
+
e.isScene ? Xe(e, l, d, n, r, t) : Ze(e, l, d, n, r, t);
|
|
685
|
+
let p = lt(d, f, t.quickLookCompatible);
|
|
686
|
+
u = Ge(a.size > 0 ? {
|
|
687
687
|
fps: t.animationFrameRate,
|
|
688
|
-
endTimeCode:
|
|
689
|
-
} : null) + "\n" + o.toString() + "\n\n" + p.toString(), r[i] =
|
|
688
|
+
endTimeCode: qe(t.animations) * t.animationFrameRate
|
|
689
|
+
} : null) + "\n" + o.toString() + "\n\n" + p.toString(), r[i] = Ie(u), u = null;
|
|
690
690
|
for (let e in f) {
|
|
691
691
|
let n = f[e];
|
|
692
692
|
if (n.isCompressedTexture === !0) {
|
|
693
693
|
if (this.textureUtils === null) throw Error("THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.");
|
|
694
694
|
n = await this.textureUtils.decompress(n);
|
|
695
695
|
}
|
|
696
|
-
let i =
|
|
697
|
-
r[`textures/Texture_${e}.${
|
|
696
|
+
let i = We(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));
|
|
697
|
+
r[`textures/Texture_${e}.${Ue(n)}`] = new Uint8Array(await o.arrayBuffer());
|
|
698
698
|
}
|
|
699
699
|
let m = 0;
|
|
700
700
|
for (let e in r) {
|
|
@@ -707,17 +707,17 @@ var Q = class {
|
|
|
707
707
|
}
|
|
708
708
|
m = t.length;
|
|
709
709
|
}
|
|
710
|
-
return
|
|
710
|
+
return Be(r, { level: 0 });
|
|
711
711
|
}
|
|
712
712
|
};
|
|
713
|
-
function
|
|
713
|
+
function He(e, t) {
|
|
714
714
|
let n = e.name;
|
|
715
715
|
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;
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function Ue(e) {
|
|
718
718
|
return e.userData.mimeType === "image/jpeg" ? "jpg" : "png";
|
|
719
719
|
}
|
|
720
|
-
function
|
|
720
|
+
function We(e, t, n) {
|
|
721
721
|
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) {
|
|
722
722
|
let r = n / Math.max(e.width, e.height), i = document.createElement("canvas");
|
|
723
723
|
i.width = e.width * Math.min(1, r), i.height = e.height * Math.min(1, r);
|
|
@@ -727,7 +727,7 @@ function Be(e, t, n) {
|
|
|
727
727
|
throw Error("THREE.USDZExporter: No valid image data found. Unable to process texture.");
|
|
728
728
|
}
|
|
729
729
|
var $ = 7;
|
|
730
|
-
function
|
|
730
|
+
function Ge(e = null) {
|
|
731
731
|
return `#usda 1.0
|
|
732
732
|
(
|
|
733
733
|
customLayerData = {
|
|
@@ -743,27 +743,27 @@ function Ve(e = null) {
|
|
|
743
743
|
)
|
|
744
744
|
`;
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function Ke(e, t) {
|
|
747
747
|
let n = /* @__PURE__ */ new Map();
|
|
748
748
|
for (let r = 0; r < t.length; r++) {
|
|
749
749
|
let i = t[r];
|
|
750
750
|
for (let t = 0; t < i.tracks.length; t++) {
|
|
751
|
-
let r = i.tracks[t],
|
|
752
|
-
if (
|
|
753
|
-
let
|
|
754
|
-
if (
|
|
755
|
-
let
|
|
756
|
-
|
|
751
|
+
let r = i.tracks[t], a = d.parseTrackName(r.name), o = d.findNode(e, a.nodeName);
|
|
752
|
+
if (o == null) continue;
|
|
753
|
+
let s = a.propertyName;
|
|
754
|
+
if (s !== "position" && s !== "quaternion" && s !== "scale") continue;
|
|
755
|
+
let c = n.get(o);
|
|
756
|
+
c === void 0 && (c = {}, n.set(o, c)), c[s] = r;
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
return n;
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function qe(e) {
|
|
762
762
|
let t = 0;
|
|
763
763
|
for (let n = 0; n < e.length; n++) e[n].duration > t && (t = e[n].duration);
|
|
764
764
|
return t;
|
|
765
765
|
}
|
|
766
|
-
function
|
|
766
|
+
function Je(e, t, n, r) {
|
|
767
767
|
let i = n.times, a = n.values, o = [];
|
|
768
768
|
for (let e = 0; e < i.length; e++) {
|
|
769
769
|
let t = e * 3;
|
|
@@ -771,7 +771,7 @@ function We(e, t, n, r) {
|
|
|
771
771
|
}
|
|
772
772
|
return `${t} ${e}.timeSamples = {\n\t${o.join(",\n ")},\n}`;
|
|
773
773
|
}
|
|
774
|
-
function
|
|
774
|
+
function Ye(e, t) {
|
|
775
775
|
let n = e.times, r = e.values, i = [];
|
|
776
776
|
for (let e = 0; e < n.length; e++) {
|
|
777
777
|
let a = e * 4;
|
|
@@ -779,10 +779,10 @@ function Ge(e, t) {
|
|
|
779
779
|
}
|
|
780
780
|
return `quatf xformOp:orient.timeSamples = {\n\t${i.join(",\n ")},\n}`;
|
|
781
781
|
}
|
|
782
|
-
function
|
|
783
|
-
for (let o = 0, s = e.children.length; o < s; o++)
|
|
782
|
+
function Xe(e, t, n, r, i, a) {
|
|
783
|
+
for (let o = 0, s = e.children.length; o < s; o++) Ze(e.children[o], t, n, r, i, a);
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function Ze(e, t, n, r, i, a) {
|
|
786
786
|
if (e.visible === !1 && a.onlyVisible === !0) return;
|
|
787
787
|
let o;
|
|
788
788
|
if (e.isMesh) {
|
|
@@ -795,58 +795,58 @@ function qe(e, t, n, r, i, a) {
|
|
|
795
795
|
if (s === !1) {
|
|
796
796
|
let e = `geometries/Geometry_${t.id}.usda`;
|
|
797
797
|
if (!(e in i)) {
|
|
798
|
-
let n =
|
|
799
|
-
i[e] =
|
|
798
|
+
let n = rt(t);
|
|
799
|
+
i[e] = Ie(Ge() + "\n" + n.toString());
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
o =
|
|
803
|
-
} else o = e.isCamera ?
|
|
804
|
-
t.addChild(o),
|
|
802
|
+
o = et(e, t, l, r, a);
|
|
803
|
+
} else o = e.isCamera ? mt(e, r, a) : $e(e, r, a);
|
|
804
|
+
t.addChild(o), Xe(e, o, n, r, i, a);
|
|
805
805
|
}
|
|
806
|
-
function
|
|
806
|
+
function Qe(e, t, n) {
|
|
807
807
|
let r = n.animationTracks.get(t), i = t.pivot !== null;
|
|
808
808
|
if (!i && r === void 0) {
|
|
809
|
-
let n =
|
|
809
|
+
let n = tt(t.matrix);
|
|
810
810
|
e.addProperty(`matrix4d xformOp:transform = ${n}`), e.addProperty("uniform token[] xformOpOrder = [\"xformOp:transform\"]");
|
|
811
811
|
return;
|
|
812
812
|
}
|
|
813
813
|
let a = n.animationFrameRate, o = t.position, s = t.quaternion, c = t.scale;
|
|
814
|
-
if (r !== void 0 && r.position !== void 0 ? e.addProperty(
|
|
814
|
+
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) {
|
|
815
815
|
let n = t.pivot;
|
|
816
816
|
e.addProperty(`float3 xformOp:translate:pivot = (${n.x.toPrecision($)}, ${n.y.toPrecision($)}, ${n.z.toPrecision($)})`);
|
|
817
817
|
}
|
|
818
|
-
r !== void 0 && r.quaternion !== void 0 ? e.addProperty(
|
|
818
|
+
r !== void 0 && r.quaternion !== void 0 ? e.addProperty(Ye(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\"]");
|
|
819
819
|
}
|
|
820
|
-
function
|
|
821
|
-
let r =
|
|
820
|
+
function $e(e, t, n) {
|
|
821
|
+
let r = He(e, t);
|
|
822
822
|
e.matrix.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e);
|
|
823
823
|
let i = new Q(r, "Xform");
|
|
824
|
-
return
|
|
824
|
+
return Qe(i, e, n), i;
|
|
825
825
|
}
|
|
826
|
-
function
|
|
827
|
-
let a =
|
|
828
|
-
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(
|
|
826
|
+
function et(e, t, n, r, i) {
|
|
827
|
+
let a = $e(e, r, i);
|
|
828
|
+
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(it(t, n)), a;
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function tt(e) {
|
|
831
831
|
let t = e.elements;
|
|
832
|
-
return `( ${
|
|
832
|
+
return `( ${nt(t, 0)}, ${nt(t, 4)}, ${nt(t, 8)}, ${nt(t, 12)} )`;
|
|
833
833
|
}
|
|
834
|
-
function
|
|
834
|
+
function nt(e, t) {
|
|
835
835
|
return `(${e[t + 0]}, ${e[t + 1]}, ${e[t + 2]}, ${e[t + 3]})`;
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
let t = new Q("Geometry"), n =
|
|
837
|
+
function rt(e) {
|
|
838
|
+
let t = new Q("Geometry"), n = it(e);
|
|
839
839
|
return t.addChild(n), t;
|
|
840
840
|
}
|
|
841
|
-
function
|
|
841
|
+
function it(e, t = null) {
|
|
842
842
|
let n = e.attributes, r = n.position.count, i = new Q("Geometry", "Mesh");
|
|
843
|
-
i.addProperty(`int[] faceVertexCounts = [${
|
|
843
|
+
i.addProperty(`int[] faceVertexCounts = [${at(e)}]`), i.addProperty(`int[] faceVertexIndices = [${ot(e)}]`), i.addProperty(`normal3f[] normals = [${st(n.normal, r)}]`, ["interpolation = \"vertex\""]), i.addProperty(`point3f[] points = [${st(n.position, r)}]`);
|
|
844
844
|
for (let e = 0; e < 4; e++) {
|
|
845
845
|
let t = e > 0 ? e : "", r = n["uv" + t];
|
|
846
|
-
r !== void 0 && i.addProperty(`texCoord2f[] primvars:st${t} = [${
|
|
846
|
+
r !== void 0 && i.addProperty(`texCoord2f[] primvars:st${t} = [${ct(r)}]`, ["interpolation = \"vertex\""]);
|
|
847
847
|
}
|
|
848
848
|
let a = n.color;
|
|
849
|
-
if (a !== void 0 && i.addProperty(`color3f[] primvars:displayColor = [${
|
|
849
|
+
if (a !== void 0 && i.addProperty(`color3f[] primvars:displayColor = [${st(a, r)}]`, ["interpolation = \"vertex\""]), i.addProperty("uniform token subdivisionScheme = \"none\""), t !== null) {
|
|
850
850
|
let r = e.groups, a = (e.index === null ? n.position.count : e.index.count) / 3;
|
|
851
851
|
for (let e = 0; e < r.length; e++) {
|
|
852
852
|
let n = r[e], o = t[n.materialIndex];
|
|
@@ -859,11 +859,11 @@ function et(e, t = null) {
|
|
|
859
859
|
}
|
|
860
860
|
return i;
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function at(e) {
|
|
863
863
|
let t = e.index === null ? e.attributes.position.count : e.index.count;
|
|
864
864
|
return Array(t / 3).fill(3).join(", ");
|
|
865
865
|
}
|
|
866
|
-
function
|
|
866
|
+
function ot(e) {
|
|
867
867
|
let t = e.index, n = [];
|
|
868
868
|
if (t !== null) for (let e = 0; e < t.count; e++) n.push(t.getX(e));
|
|
869
869
|
else {
|
|
@@ -872,7 +872,7 @@ function nt(e) {
|
|
|
872
872
|
}
|
|
873
873
|
return n.join(", ");
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function st(e, t) {
|
|
876
876
|
if (e === void 0) return console.warn("USDZExporter: Normals missing."), Array(t).fill("(0, 0, 0)").join(", ");
|
|
877
877
|
let n = [];
|
|
878
878
|
for (let t = 0; t < e.count; t++) {
|
|
@@ -881,7 +881,7 @@ function rt(e, t) {
|
|
|
881
881
|
}
|
|
882
882
|
return n.join(", ");
|
|
883
883
|
}
|
|
884
|
-
function
|
|
884
|
+
function ct(e) {
|
|
885
885
|
let t = [];
|
|
886
886
|
for (let n = 0; n < e.count; n++) {
|
|
887
887
|
let r = e.getX(n), i = e.getY(n);
|
|
@@ -889,39 +889,39 @@ function it(e) {
|
|
|
889
889
|
}
|
|
890
890
|
return t.join(", ");
|
|
891
891
|
}
|
|
892
|
-
function
|
|
892
|
+
function lt(e, t, n = !1) {
|
|
893
893
|
let r = new Q("Materials");
|
|
894
894
|
for (let i in e) {
|
|
895
895
|
let a = e[i];
|
|
896
|
-
r.addChild(
|
|
896
|
+
r.addChild(ut(a, t, n));
|
|
897
897
|
}
|
|
898
898
|
return r;
|
|
899
899
|
}
|
|
900
|
-
function
|
|
901
|
-
let
|
|
902
|
-
function a(
|
|
903
|
-
let o =
|
|
904
|
-
t[o] =
|
|
905
|
-
let s =
|
|
900
|
+
function ut(e, t, n = !1) {
|
|
901
|
+
let r = new Q(`Material_${e.id}`, "Material");
|
|
902
|
+
function a(r, i, a) {
|
|
903
|
+
let o = r.source.id + "_" + r.flipY;
|
|
904
|
+
t[o] = r;
|
|
905
|
+
let s = r.channel > 0 ? "st" + r.channel : "st", c = {
|
|
906
906
|
1e3: "repeat",
|
|
907
907
|
1001: "clamp",
|
|
908
908
|
1002: "mirror"
|
|
909
|
-
}, l =
|
|
910
|
-
u.y = 1 - u.y - l.y,
|
|
909
|
+
}, l = r.repeat.clone(), u = r.offset.clone(), d = r.rotation, f = Math.sin(d), p = Math.cos(d);
|
|
910
|
+
u.y = 1 - u.y - l.y, n ? (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);
|
|
911
911
|
let m = new Q(`PrimvarReader_${i}`, "Shader");
|
|
912
912
|
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");
|
|
913
913
|
let h = new Q(`Transform2d_${i}`, "Shader");
|
|
914
|
-
h.addProperty("uniform token info:id = \"UsdTransform2d\""), h.addProperty(`float2 inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${i}.outputs:result>`), h.addProperty(`float inputs:rotation = ${(180 / Math.PI * d).toFixed($)}`), h.addProperty(`float2 inputs:scale = ${
|
|
915
|
-
let g = new Q(`Texture_${
|
|
916
|
-
if (g.addProperty("uniform token info:id = \"UsdUVTexture\""), g.addProperty(`asset inputs:file = @textures/Texture_${o}.${
|
|
914
|
+
h.addProperty("uniform token info:id = \"UsdTransform2d\""), h.addProperty(`float2 inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${i}.outputs:result>`), h.addProperty(`float inputs:rotation = ${(180 / Math.PI * d).toFixed($)}`), h.addProperty(`float2 inputs:scale = ${pt(l)}`), h.addProperty(`float2 inputs:translation = ${pt(u)}`), h.addProperty("float2 outputs:result");
|
|
915
|
+
let g = new Q(`Texture_${r.id}_${i}`, "Shader");
|
|
916
|
+
if (g.addProperty("uniform token info:id = \"UsdUVTexture\""), g.addProperty(`asset inputs:file = @textures/Texture_${o}.${Ue(r)}@`), g.addProperty(`float2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${i}.outputs:result>`), a !== void 0) {
|
|
917
917
|
let t = i === "diffuse" ? e.opacity : 1;
|
|
918
|
-
g.addProperty(`float4 inputs:scale = ${
|
|
918
|
+
g.addProperty(`float4 inputs:scale = ${ft(a, t)}`);
|
|
919
919
|
}
|
|
920
920
|
if (i === "normal") {
|
|
921
921
|
let t = e.normalScale.x;
|
|
922
922
|
g.addProperty(`float4 inputs:scale = (${2 * t}, ${2 * t}, 2, 1)`), g.addProperty(`float4 inputs:bias = (${-t}, ${-t}, -1, 0)`);
|
|
923
923
|
}
|
|
924
|
-
return g.addProperty(`token inputs:sourceColorSpace = "${
|
|
924
|
+
return g.addProperty(`token inputs:sourceColorSpace = "${r.colorSpace === "" ? "raw" : "sRGB"}"`), g.addProperty(`token inputs:wrapS = "${c[r.wrapS]}"`), g.addProperty(`token inputs:wrapT = "${c[r.wrapT]}"`), g.addProperty("float outputs:r"), g.addProperty("float outputs:g"), g.addProperty("float outputs:b"), g.addProperty("float3 outputs:rgb"), (e.transparent || e.alphaTest > 0) && g.addProperty("float outputs:a"), [
|
|
925
925
|
m,
|
|
926
926
|
h,
|
|
927
927
|
g
|
|
@@ -929,58 +929,58 @@ function ot(e, t, r = !1) {
|
|
|
929
929
|
}
|
|
930
930
|
e.side === 2 && console.warn("THREE.USDZExporter: USDZ does not support double sided materials", e);
|
|
931
931
|
let o = new Q("PreviewSurface", "Shader");
|
|
932
|
-
if (o.addProperty("uniform token info:id = \"UsdPreviewSurface\""), e.map === null ? o.addProperty(`color3f inputs:diffuseColor = ${
|
|
932
|
+
if (o.addProperty("uniform token info:id = \"UsdPreviewSurface\""), e.map === null ? o.addProperty(`color3f inputs:diffuseColor = ${dt(e.color)}`) : (o.addProperty(`color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`), e.transparent ? o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`) : e.alphaTest > 0 && (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`), o.addProperty(`float inputs:opacityThreshold = ${e.alphaTest}`)), a(e.map, "diffuse", e.color).forEach((e) => r.addChild(e))), e.emissive) {
|
|
933
933
|
let t = e.emissiveIntensity ?? 1;
|
|
934
934
|
if (e.emissiveMap) {
|
|
935
935
|
o.addProperty(`color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`);
|
|
936
|
-
let
|
|
937
|
-
a(e.emissiveMap, "emissive",
|
|
938
|
-
} else e.emissive.getHex() > 0 && o.addProperty(`color3f inputs:emissiveColor = ${
|
|
936
|
+
let n = new i(e.emissive.r * t, e.emissive.g * t, e.emissive.b * t);
|
|
937
|
+
a(e.emissiveMap, "emissive", n).forEach((e) => r.addChild(e));
|
|
938
|
+
} else e.emissive.getHex() > 0 && o.addProperty(`color3f inputs:emissiveColor = ${dt(e.emissive)}`);
|
|
939
939
|
}
|
|
940
|
-
if (e.normalMap && (o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`), a(e.normalMap, "normal").forEach((e) =>
|
|
940
|
+
if (e.normalMap && (o.addProperty(`normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`), a(e.normalMap, "normal").forEach((e) => r.addChild(e))), e.aoMap) {
|
|
941
941
|
o.addProperty(`float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`);
|
|
942
|
-
let t = e.aoMapIntensity ?? 1,
|
|
943
|
-
a(e.aoMap, "occlusion",
|
|
942
|
+
let t = e.aoMapIntensity ?? 1, n = new i(t, t, t);
|
|
943
|
+
a(e.aoMap, "occlusion", n).forEach((e) => r.addChild(e));
|
|
944
944
|
}
|
|
945
945
|
if (e.roughnessMap) {
|
|
946
946
|
o.addProperty(`float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`);
|
|
947
|
-
let t = new
|
|
948
|
-
a(e.roughnessMap, "roughness", t).forEach((e) =>
|
|
947
|
+
let t = new i(e.roughness, e.roughness, e.roughness);
|
|
948
|
+
a(e.roughnessMap, "roughness", t).forEach((e) => r.addChild(e));
|
|
949
949
|
} else o.addProperty(`float inputs:roughness = ${e.roughness ?? 1}`);
|
|
950
950
|
if (e.metalnessMap) {
|
|
951
951
|
o.addProperty(`float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`);
|
|
952
|
-
let t = new
|
|
953
|
-
a(e.metalnessMap, "metallic", t).forEach((e) =>
|
|
952
|
+
let t = new i(e.metalness, e.metalness, e.metalness);
|
|
953
|
+
a(e.metalnessMap, "metallic", t).forEach((e) => r.addChild(e));
|
|
954
954
|
} else o.addProperty(`float inputs:metallic = ${e.metalness ?? 0}`);
|
|
955
|
-
if (e.alphaMap ? (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`), o.addProperty("float inputs:opacityThreshold = 0.0001"), a(e.alphaMap, "opacity").forEach((e) =>
|
|
955
|
+
if (e.alphaMap ? (o.addProperty(`float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`), o.addProperty("float inputs:opacityThreshold = 0.0001"), a(e.alphaMap, "opacity").forEach((e) => r.addChild(e))) : o.addProperty(`float inputs:opacity = ${e.opacity}`), e.isMeshPhysicalMaterial) {
|
|
956
956
|
if (e.clearcoatMap !== null) {
|
|
957
957
|
o.addProperty(`float inputs:clearcoat.connect = </Materials/Material_${e.id}/Texture_${e.clearcoatMap.id}_clearcoat.outputs:r>`);
|
|
958
|
-
let t = new
|
|
959
|
-
a(e.clearcoatMap, "clearcoat", t).forEach((e) =>
|
|
958
|
+
let t = new i(e.clearcoat, e.clearcoat, e.clearcoat);
|
|
959
|
+
a(e.clearcoatMap, "clearcoat", t).forEach((e) => r.addChild(e));
|
|
960
960
|
} else o.addProperty(`float inputs:clearcoat = ${e.clearcoat}`);
|
|
961
961
|
if (e.clearcoatRoughnessMap !== null) {
|
|
962
962
|
o.addProperty(`float inputs:clearcoatRoughness.connect = </Materials/Material_${e.id}/Texture_${e.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`);
|
|
963
|
-
let t = new
|
|
964
|
-
a(e.clearcoatRoughnessMap, "clearcoatRoughness", t).forEach((e) =>
|
|
963
|
+
let t = new i(e.clearcoatRoughness, e.clearcoatRoughness, e.clearcoatRoughness);
|
|
964
|
+
a(e.clearcoatRoughnessMap, "clearcoatRoughness", t).forEach((e) => r.addChild(e));
|
|
965
965
|
} else o.addProperty(`float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`);
|
|
966
966
|
o.addProperty(`float inputs:ior = ${e.ior}`);
|
|
967
967
|
}
|
|
968
|
-
return o.addProperty("int inputs:useSpecularWorkflow = 0"), o.addProperty("token outputs:surface"),
|
|
968
|
+
return o.addProperty("int inputs:useSpecularWorkflow = 0"), o.addProperty("token outputs:surface"), r.addChild(o), r.addProperty(`token outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>`), r;
|
|
969
969
|
}
|
|
970
|
-
function
|
|
970
|
+
function dt(e) {
|
|
971
971
|
return `(${e.r}, ${e.g}, ${e.b})`;
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function ft(e, t = 1) {
|
|
974
974
|
return `(${e.r}, ${e.g}, ${e.b}, ${t})`;
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function pt(e) {
|
|
977
977
|
return `(${e.x}, ${e.y})`;
|
|
978
978
|
}
|
|
979
|
-
function
|
|
980
|
-
let r =
|
|
979
|
+
function mt(e, t, n) {
|
|
980
|
+
let r = He(e, t);
|
|
981
981
|
e.matrix.determinant() < 0 && console.warn("THREE.USDZExporter: USDZ does not support negative scales", e);
|
|
982
982
|
let i = new Q(r, "Camera");
|
|
983
|
-
|
|
983
|
+
Qe(i, e, n);
|
|
984
984
|
let a = e.isOrthographicCamera ? "orthographic" : "perspective";
|
|
985
985
|
i.addProperty(`token projection = "${a}"`);
|
|
986
986
|
let o = `(${e.near.toPrecision($)}, ${e.far.toPrecision($)})`;
|
|
@@ -998,30 +998,85 @@ function ut(e, t, n) {
|
|
|
998
998
|
}
|
|
999
999
|
//#endregion
|
|
1000
1000
|
//#region src/export/usdz.ts
|
|
1001
|
-
var
|
|
1002
|
-
async function
|
|
1003
|
-
let
|
|
1004
|
-
|
|
1001
|
+
var ht = "model/vnd.usdz+zip", gt = ".usdz";
|
|
1002
|
+
async function _t(e) {
|
|
1003
|
+
let { root: t, dispose: n } = yt(e);
|
|
1004
|
+
try {
|
|
1005
|
+
let e = await new Ve().parseAsync(t, { quickLookCompatible: !0 });
|
|
1006
|
+
return new Uint8Array(e);
|
|
1007
|
+
} finally {
|
|
1008
|
+
n();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
var vt = 1e3;
|
|
1012
|
+
function yt(e) {
|
|
1013
|
+
let n = new t().add(e.clone()), r = [], i = [];
|
|
1014
|
+
n.traverse((e) => {
|
|
1015
|
+
let t = e;
|
|
1016
|
+
t.isMesh && t.geometry.hasAttribute("color") && t.material.vertexColors && i.push(t);
|
|
1017
|
+
});
|
|
1018
|
+
for (let e of i) {
|
|
1019
|
+
let n = new t();
|
|
1020
|
+
n.name = e.name, n.visible = e.visible, n.position.copy(e.position), n.quaternion.copy(e.quaternion), n.scale.copy(e.scale), n.updateMatrix();
|
|
1021
|
+
for (let t of bt(e)) r.push(t.geometry, t.material), n.add(t);
|
|
1022
|
+
for (let t of [...e.children]) n.add(t);
|
|
1023
|
+
e.parent?.add(n), e.parent?.remove(e);
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
root: n,
|
|
1027
|
+
dispose: () => r.forEach((e) => e.dispose())
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
function bt(e) {
|
|
1031
|
+
let t = e.geometry.index ? e.geometry.toNonIndexed() : e.geometry, r = t.getAttribute("color"), i = /* @__PURE__ */ new Map();
|
|
1032
|
+
for (let e = 0; e * 3 < r.count; e++) {
|
|
1033
|
+
let t = xt(r, e), n = t.toArray().map((e) => Math.round(e * vt)).join(",");
|
|
1034
|
+
(i.get(n) ?? i.set(n, {
|
|
1035
|
+
colour: t,
|
|
1036
|
+
faces: []
|
|
1037
|
+
}).get(n)).faces.push(e);
|
|
1038
|
+
}
|
|
1039
|
+
let a = e.material, o = [...i.values()].map(({ colour: e, faces: r }) => {
|
|
1040
|
+
let i = St(t, r), o = a.clone();
|
|
1041
|
+
return o.vertexColors = !1, o.color.copy(a.color).multiply(e), new n(i, o);
|
|
1042
|
+
});
|
|
1043
|
+
return t !== e.geometry && t.dispose(), o;
|
|
1044
|
+
}
|
|
1045
|
+
function xt(e, t) {
|
|
1046
|
+
let n = new i(0, 0, 0);
|
|
1047
|
+
for (let r = 0; r < 3; r++) n.add(new i(e.getX(t * 3 + r), e.getY(t * 3 + r), e.getZ(t * 3 + r)));
|
|
1048
|
+
return n.multiplyScalar(1 / 3);
|
|
1049
|
+
}
|
|
1050
|
+
function St(e, t) {
|
|
1051
|
+
let n = new c();
|
|
1052
|
+
for (let [r, i] of Object.entries(e.attributes)) {
|
|
1053
|
+
if (r === "color") continue;
|
|
1054
|
+
let e = i.itemSize, a = new Float32Array(t.length * 3 * e);
|
|
1055
|
+
t.forEach((t, n) => {
|
|
1056
|
+
for (let r = 0; r < 3; r++) for (let o = 0; o < e; o++) a[(n * 3 + r) * e + o] = i.getComponent(t * 3 + r, o);
|
|
1057
|
+
}), n.setAttribute(r, new o(a, e));
|
|
1058
|
+
}
|
|
1059
|
+
return n;
|
|
1005
1060
|
}
|
|
1006
|
-
async function
|
|
1007
|
-
let
|
|
1008
|
-
...
|
|
1061
|
+
async function Ct(e, t = {}) {
|
|
1062
|
+
let n = l(u(e), {
|
|
1063
|
+
...t,
|
|
1009
1064
|
wireframe: !1
|
|
1010
1065
|
});
|
|
1011
1066
|
try {
|
|
1012
|
-
return await
|
|
1067
|
+
return await _t(n);
|
|
1013
1068
|
} finally {
|
|
1014
|
-
|
|
1069
|
+
r(n);
|
|
1015
1070
|
}
|
|
1016
1071
|
}
|
|
1017
1072
|
//#endregion
|
|
1018
1073
|
//#region src/core/samples.ts
|
|
1019
|
-
var
|
|
1074
|
+
var wt = [
|
|
1020
1075
|
{
|
|
1021
1076
|
name: "Basic Shapes",
|
|
1022
1077
|
args: {
|
|
1023
1078
|
title: "Basic 3D Shapes",
|
|
1024
|
-
script: "// Basic shapes demonstration\ncube { position -2 0 0 size 1 color (1 0.3 0.3)
|
|
1079
|
+
script: "// Basic shapes demonstration\ncube {\n position -2 0 0\n size 1\n color (1 0.3 0.3)\n}\nsphere {\n position 0 0 0\n size 1\n color (0.3 1 0.3)\n}\ncylinder {\n position 2 0 0\n size 0.5 1\n color (0.3 0.3 1)\n}"
|
|
1025
1080
|
}
|
|
1026
1081
|
},
|
|
1027
1082
|
{
|
|
@@ -1035,9 +1090,9 @@ var ht = [
|
|
|
1035
1090
|
name: "CSG Difference",
|
|
1036
1091
|
args: {
|
|
1037
1092
|
title: "Hollow Sphere",
|
|
1038
|
-
script: "// Create a hollow sphere using CSG difference\ndifference {\n sphere {
|
|
1093
|
+
script: "// Create a hollow sphere using CSG difference\ndifference {\n sphere {\n size 2\n color (1 0.5 0)\n }\n sphere {\n size 1.7\n color (1 1 1)\n }\n cube {\n position 0 0 2\n size 2\n }\n}"
|
|
1039
1094
|
}
|
|
1040
1095
|
}
|
|
1041
1096
|
];
|
|
1042
1097
|
//#endregion
|
|
1043
|
-
export {
|
|
1098
|
+
export { D as _, Ct as a, B as c, C as d, A as f, k as g, w as h, _t as i, M as l, E as m, gt as n, te as o, O as p, ht as r, V as s, wt as t, j as u, b as v, y };
|