@fleox/agent3d 0.2.3 → 0.3.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.
Files changed (70) hide show
  1. package/README.md +20 -13
  2. package/changelog.json +26 -0
  3. package/dist/agent/agent3d.mjs +228 -53
  4. package/dist/agent/chunks/{assets-BUUM9TUB.mjs → assets-YBkgdfgy.mjs} +27 -8
  5. package/dist/agent/chunks/{browser-Br1tURgt.mjs → browser-Dil7VM5m.mjs} +1 -1
  6. package/dist/agent/chunks/{cdp-Bdtm4fBN.mjs → cdp-DLEis_Z3.mjs} +1 -1
  7. package/dist/agent/chunks/{check-CfZcfaPs.mjs → check-DP9fRYbK.mjs} +64 -4
  8. package/dist/agent/chunks/depth-BZT4gseQ.mjs +483 -0
  9. package/dist/agent/chunks/depth-CD_ql3QJ.mjs +190 -0
  10. package/dist/agent/chunks/{export-BHugc2H7.mjs → export-bJwh2SqG.mjs} +12 -6
  11. package/dist/agent/chunks/{imageCodec-QM0EXQDJ.mjs → imageCodec-DeGfmBp3.mjs} +3 -3
  12. package/dist/agent/chunks/{objects-DBAws7uf.mjs → objects-DuytRxiC.mjs} +3 -3
  13. package/dist/agent/chunks/{optimizeSizing-CkZ3fZRp.mjs → optimizeSizing-B-BBiUkD.mjs} +51 -3
  14. package/dist/agent/chunks/{package-fw4h5vsh.mjs → package-fMbw9UGh.mjs} +2 -1
  15. package/dist/agent/chunks/{render-EHb40avl.mjs → render-B05DU4Q5.mjs} +4 -4
  16. package/dist/agent/chunks/{scene-BgajNvBf.mjs → scene-DWgXH6As.mjs} +2 -2
  17. package/dist/agent/chunks/{server-CACCerkZ.mjs → server-Dt_YFvN7.mjs} +6 -2
  18. package/dist/agent/chunks/{tools-DKxgjQSJ.mjs → tools-Cm4BqDkO.mjs} +60 -6
  19. package/dist/agent/chunks/{tree-BrNYGui2.mjs → tree-CqSj-o8T.mjs} +1 -0
  20. package/dist/agent/ort/LICENSE.txt +9 -0
  21. package/dist/agent/ort/ort-wasm-simd-threaded.wasm +0 -0
  22. package/dist/agent/ort/ort.wasm.bundle.min.mjs +9 -0
  23. package/dist/runtime/agent3d-runtime.js +6 -6
  24. package/dist/runtime/agent3d-runtime.single.js +311 -62
  25. package/dist/runtime/chunks/assets-qnxDnVkj.js +1 -0
  26. package/dist/runtime/chunks/materials-dC4vDNHh.js +107 -0
  27. package/dist/runtime/chunks/{model-DbfZaLni.js → model-BCAl_NRl.js} +1 -1
  28. package/dist/runtime/chunks/photo-DNf14X7B.js +250 -0
  29. package/dist/runtime/chunks/svg-CLUxY6Zy.js +1 -0
  30. package/dist/runtime/chunks/{text-BaON-ISS.js → text-rSo_2Luk.js} +2 -2
  31. package/dist/studio/assets/assets-BW5lQkYR.js +1 -0
  32. package/dist/studio/assets/{camera-Be6lnp3k.js → camera-BgzPVnn-.js} +1 -1
  33. package/dist/studio/assets/{editor-Mpnz-b2E.js → editor-NkBUKsDB.js} +1 -1
  34. package/dist/studio/assets/{game-WMgRSJUD.js → game-DARpu0ah.js} +3 -3
  35. package/dist/studio/assets/{generators-DozXE7ta.js → generators-BjIs-kHx.js} +1 -1
  36. package/dist/studio/assets/index-L-N-e2KM.js +479 -0
  37. package/dist/studio/assets/{model-C2bZTK7-.js → model-CqI8j03Z.js} +1 -1
  38. package/dist/studio/assets/params-DhsDKSDs.js +1 -0
  39. package/dist/studio/assets/photo-DAHd1yNF.js +250 -0
  40. package/dist/studio/assets/{physicsHost-CTRsIvfu.js → physicsHost-tEUto2-_.js} +1 -1
  41. package/dist/studio/assets/{postfx-DQtp0JIy.js → postfx-BGu30OJK.js} +1 -1
  42. package/dist/studio/assets/runtime-C_qkIpAK.js +572 -0
  43. package/dist/studio/assets/{shaders-BOb6Uter.js → shaders-Dt6FGXH_.js} +12 -12
  44. package/dist/studio/assets/svg-ZZt5MdNf.js +2 -0
  45. package/dist/studio/assets/{text-CGIZs8HE.js → text-B-HM422i.js} +2 -2
  46. package/dist/studio/index.html +1 -1
  47. package/package.json +2 -1
  48. package/plugin/.claude-plugin/plugin.json +1 -1
  49. package/plugin/skills/agent3d-assets/SKILL.md +40 -25
  50. package/plugin/skills/agent3d-create/SKILL.md +57 -21
  51. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  52. package/plugin/skills/agent3d-create/references/recipes.md +71 -6
  53. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  54. package/plugin/skills/agent3d-edit/references/patch-ops.md +11 -3
  55. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  56. package/plugin/skills/agent3d-publish/SKILL.md +23 -21
  57. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  58. package/templates/hero-photo-3d/README.md +28 -0
  59. package/templates/hero-photo-3d/agent3d.json +8 -0
  60. package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
  61. package/templates/hero-photo-3d/assets/manifest.json +25 -0
  62. package/templates/hero-photo-3d/assets/textures/street.webp +0 -0
  63. package/templates/hero-photo-3d/preview.png +0 -0
  64. package/templates/hero-photo-3d/scene.json +120 -0
  65. package/templates/hero-photo-3d/template.json +8 -0
  66. package/dist/runtime/chunks/materials-w3EW0g-7.js +0 -107
  67. package/dist/runtime/chunks/svg-CfPIQnDG.js +0 -1
  68. package/dist/studio/assets/index-tSGZFEt5.js +0 -479
  69. package/dist/studio/assets/runtime-NGp1VdnH.js +0 -572
  70. package/dist/studio/assets/svg-CnUMpv_N.js +0 -2
@@ -5,9 +5,9 @@ __a3dRequire(import.meta.url);
5
5
  const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
7
  import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
8
- import { D as slugify, F as normalizePath, M as readJsonOr, O as KB, P as writeJson, a as ASSET_MANIFEST_FILE, d as saveScene, j as nowIso, k as OpsError, u as readSceneFile } from "../agent3d.mjs";
8
+ import { A as OpsError, F as writeJson, I as normalizePath, M as nowIso, N as readJsonOr, O as slugify, d as readSceneFile, f as saveScene, k as KB, o as ASSET_MANIFEST_FILE } from "../agent3d.mjs";
9
9
  import { t as closest } from "./suggest-Cpcgv1RP.mjs";
10
- import { a as collectAssetRefs, i as planTextureSizes, l as visitAssetRefs, n as imageHeader, s as kindFromPath } from "./optimizeSizing-CkZ3fZRp.mjs";
10
+ import { a as collectAssetRefs, i as planTextureSizes, l as visitAssetRefs, n as imageHeader, s as kindFromPath } from "./optimizeSizing-B-BBiUkD.mjs";
11
11
  import { i as modelInfo, r as modelFileBounds } from "./gltf-f_f0-OiV.mjs";
12
12
  // src/ops/zip.ts
13
13
  var ZipError = class extends Error {
@@ -1672,6 +1672,10 @@ function decisionFor(plan, path, forced) {
1672
1672
  uses: []
1673
1673
  };
1674
1674
  }
1675
+ function isDepthMap(plan, path) {
1676
+ return !!plan.files.get(path)?.uses.some((u) => u.role === "depth");
1677
+ }
1678
+ var DEPTH_KEPT = "Depth map of a 3D photo: only PNG depth maps are resized (losslessly); re-encoding a lossy one adds relief artefacts. Regenerate it as PNG with `agent3d assets depth <photo>`.";
1675
1679
  function roleDecision(plan, path, role, forced) {
1676
1680
  if (forced) return {
1677
1681
  maxSize: forced,
@@ -1734,6 +1738,13 @@ async function planOptimize(fs, opts) {
1734
1738
  } else {
1735
1739
  const d = decisionFor(sizing, path, opts.maxSize);
1736
1740
  const h = imageHeader(bytes);
1741
+ if (isDepthMap(sizing, path) && ext(path) !== "png") {
1742
+ skipped.push({
1743
+ path,
1744
+ reason: DEPTH_KEPT
1745
+ });
1746
+ continue;
1747
+ }
1737
1748
  entries.push({
1738
1749
  path,
1739
1750
  kb,
@@ -1745,7 +1756,7 @@ async function planOptimize(fs, opts) {
1745
1756
  height: h.height
1746
1757
  } : {},
1747
1758
  resize: h ? Math.max(h.width, h.height) > d.maxSize : true,
1748
- format: format === "auto" ? "webp" : format
1759
+ format: isDepthMap(sizing, path) ? "png" : format === "auto" ? "webp" : format
1749
1760
  });
1750
1761
  }
1751
1762
  }
@@ -1836,10 +1847,18 @@ async function optimizeAssets(fs, opts, codec) {
1836
1847
  }
1837
1848
  const d = decisionFor(sizing, path, forced);
1838
1849
  const mime = IMAGE_EXT[ext(path)];
1850
+ const depthMap = isDepthMap(sizing, path);
1851
+ if (depthMap && mime !== "image/png") {
1852
+ skipped.push({
1853
+ path,
1854
+ reason: DEPTH_KEPT
1855
+ });
1856
+ continue;
1857
+ }
1839
1858
  const role = d.uses.some((u) => u.role === "color" || u.role === "background") ? "color" : d.uses.length && d.uses.every((u) => u.role === "data") ? "data" : d.uses.some((u) => u.role === "normal") ? "normal" : "color";
1840
- let fmt = format;
1841
- let renameNote;
1842
- const wanted = format === "auto" || format === "webp" ? "image/webp" : format === "jpeg" ? "image/jpeg" : format === "png" ? "image/png" : mime;
1859
+ let fmt = depthMap ? "keep" : format;
1860
+ let renameNote = depthMap && format !== "keep" && format !== "png" ? "Depth map: kept as lossless PNG." : void 0;
1861
+ const wanted = depthMap ? mime : format === "auto" || format === "webp" ? "image/webp" : format === "jpeg" ? "image/jpeg" : format === "png" ? "image/png" : mime;
1843
1862
  if (wanted !== mime) {
1844
1863
  const to = path.slice(0, path.lastIndexOf(".") + 1) + EXT_FOR_MIME[wanted];
1845
1864
  const blocker = await renameBlocker(fs, scene, path, to);
@@ -1858,7 +1877,7 @@ async function optimizeAssets(fs, opts, codec) {
1858
1877
  const ok = worthIt(out, bytes.byteLength);
1859
1878
  const image = {
1860
1879
  name: "image",
1861
- role: d.uses.some((u) => u.role === "background") ? "background" : d.uses.length && d.uses.every((u) => u.role === "lighting") ? "lighting" : role,
1880
+ role: depthMap ? "depth" : d.uses.some((u) => u.role === "background") ? "background" : d.uses.length && d.uses.every((u) => u.role === "lighting") ? "lighting" : role,
1862
1881
  from: describe(out.srcWidth, out.srcHeight, mime, bytes.byteLength),
1863
1882
  to: describe(out.width, out.height, out.mimeType, out.bytes.byteLength),
1864
1883
  replaced: ok,
@@ -2053,7 +2072,7 @@ async function optimizedExportSources(fs, library, opts = {}) {
2053
2072
  compress: true,
2054
2073
  roleSizes: roleSizes ? Object.fromEntries(Object.entries(roleSizes).map(([r, v]) => [r, v.maxSize])) : void 0
2055
2074
  }, opts.codec)).bytes;
2056
- } else if (IMAGE_EXT[e] && opts.codec && d) {
2075
+ } else if (IMAGE_EXT[e] && opts.codec && d && !(isDepthMap(sizing, key) && e !== "png")) {
2057
2076
  const role = d.uses.every((u) => u.role === "normal") ? "normal" : "color";
2058
2077
  const r = await opts.codec({
2059
2078
  bytes,
@@ -4,7 +4,7 @@ import { dirname as __a3dDirname, delimiter, join } from "node:path";
4
4
  __a3dRequire(import.meta.url);
5
5
  const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
- import { z as CliError } from "../agent3d.mjs";
7
+ import { H as CliError } from "../agent3d.mjs";
8
8
  import { existsSync, mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
9
9
  import { homedir, tmpdir } from "node:os";
10
10
  import { execFile, spawn } from "node:child_process";
@@ -4,7 +4,7 @@ import { dirname as __a3dDirname } from "node:path";
4
4
  __a3dRequire(import.meta.url);
5
5
  const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
- import { z as CliError } from "../agent3d.mjs";
7
+ import { H as CliError } from "../agent3d.mjs";
8
8
  // agent/render/cdp.ts
9
9
  var DEFAULT_TIMEOUT_MS = Number(process.env.AGENT3D_CDP_TIMEOUT_MS) || 6e4;
10
10
  var CdpError = class extends Error {
@@ -5,11 +5,11 @@ __a3dRequire(import.meta.url);
5
5
  const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
7
  import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
8
- import { C as GENERATORS, M as readJsonOr, O as KB, S as CATALOG, _ as expandPostFx, a as ASSET_MANIFEST_FILE, b as isLibraryRef, g as validateScene, p as DEFAULT_BUDGET_KB, s as SCENE_FILE, u as readSceneFile, v as postfxCost, w as catalogEntry, x as libraryId, y as findLibraryAsset } from "../agent3d.mjs";
8
+ import { C as CATALOG, N as readJsonOr, S as libraryId, T as catalogEntry, _ as validateScene, b as findLibraryAsset, c as SCENE_FILE, d as readSceneFile, k as KB, m as DEFAULT_BUDGET_KB, o as ASSET_MANIFEST_FILE, v as expandPostFx, w as GENERATORS, x as isLibraryRef, y as postfxCost } from "../agent3d.mjs";
9
9
  import { t as closest } from "./suggest-Cpcgv1RP.mjs";
10
- import { o as walkObjects } from "./tree-BrNYGui2.mjs";
10
+ import { o as walkObjects } from "./tree-CqSj-o8T.mjs";
11
11
  import { i as modelInfo } from "./gltf-f_f0-OiV.mjs";
12
- import { a as collectAssetRefs, o as gltfDependencies, r as optimizeSuggestions } from "./optimizeSizing-CkZ3fZRp.mjs";
12
+ import { a as collectAssetRefs, n as imageHeader, o as gltfDependencies, r as optimizeSuggestions } from "./optimizeSizing-B-BBiUkD.mjs";
13
13
  // src/ops/budget.ts
14
14
  function evalCost(formula, vars) {
15
15
  const src = formula.replace(/~/g, "");
@@ -148,9 +148,23 @@ function objectTriangles(o, models) {
148
148
  }
149
149
  case "particles": return (o.count ?? 200) * 2;
150
150
  case "svg": return 2e3;
151
+ case "photo": return photoTriangles(o);
151
152
  default: return 0;
152
153
  }
153
154
  }
155
+ function photoTriangles(o) {
156
+ if (typeof o.depth !== "string" || !o.depth) return 2;
157
+ const mode = o.mode ?? "parallax";
158
+ if (mode === "layers") return 2 * (typeof o.layers === "number" && o.layers > 0 ? Math.round(o.layers) : 6);
159
+ if (mode === "mesh") {
160
+ const seg = typeof o.segments === "number" && o.segments > 0 ? Math.round(o.segments) : 256;
161
+ const w = Number(o.width);
162
+ const h = Number(o.height);
163
+ const aspect = w > 0 && h > 0 ? Math.min(w, h) / Math.max(w, h) : 1;
164
+ return Math.round(seg * Math.max(1, Math.round(seg * aspect)) * 2 * 1.25);
165
+ }
166
+ return 2;
167
+ }
154
168
  function estimateTriangles(scene, opts = {}) {
155
169
  const byObject = [];
156
170
  walkObjects(scene.objects, (o) => {
@@ -577,6 +591,7 @@ async function checkProject(fs, opts = {}) {
577
591
  message: `${l.path} is ${l.license}: it requires attribution.`,
578
592
  hint: `Show this credit near the embed (the export's index.html lists it): ${l.attribution}`
579
593
  });
594
+ issues.push(...await photoIssues(fs, scene));
580
595
  let scriptBytes = 0;
581
596
  for (const [i, path] of (scene.scripts ?? []).entries()) {
582
597
  if (typeof path !== "string" || !path.startsWith("scripts/")) continue;
@@ -806,6 +821,50 @@ function passHint(f) {
806
821
  if (p.contactShadows) parts.push("contactShadows re-draws the casters from below");
807
822
  return parts.length ? ` Passes: ${parts.join("; ")}.` : "";
808
823
  }
824
+ async function photoIssues(fs, scene) {
825
+ const out = [];
826
+ const photos = [];
827
+ walkObjects(scene.objects, (o) => void (o.kind === "photo" && photos.push(o)));
828
+ const header = async (path) => {
829
+ if (typeof path !== "string" || !path || isLibraryRef(path) || !await fs.exists(path)) return null;
830
+ const bytes = await fs.readBytes(path);
831
+ return {
832
+ bytes: bytes.byteLength,
833
+ h: imageHeader(bytes)
834
+ };
835
+ };
836
+ for (const o of photos) {
837
+ const at = `objects#${o.id}`;
838
+ const src = await header(o.src).catch(() => null);
839
+ if (src && src.bytes > 1572864) out.push({
840
+ severity: "warning",
841
+ code: "photo-heavy",
842
+ path: `${at}.src`,
843
+ message: `Photo "${String(o.src)}" weighs ${KB(src.bytes)} KB${src.h ? ` (${src.h.width}x${src.h.height})` : ""}: slow to load on phones.`,
844
+ hint: `Run \`agent3d assets optimize ${String(o.src)}\` (sized from how big the photo shows on screen, WebP; plan first, then --yes).`
845
+ });
846
+ const depth = await header(o.depth).catch(() => null);
847
+ if (src?.h && depth?.h && src.h.height > 0 && depth.h.height > 0) {
848
+ const a = src.h.width / src.h.height;
849
+ const b = depth.h.width / depth.h.height;
850
+ if (Math.abs(a - b) / a > .02) out.push({
851
+ severity: "warning",
852
+ code: "photo-depth-aspect",
853
+ path: `${at}.depth`,
854
+ message: `Depth map "${String(o.depth)}" is ${depth.h.width}x${depth.h.height} but the photo is ${src.h.width}x${src.h.height}: different aspect ratios, the relief will not line up with the picture.`,
855
+ hint: `Regenerate it from this image: \`agent3d assets depth ${String(o.src)}\` (or crop both the same way).`
856
+ });
857
+ }
858
+ if (depth?.h && depth.h.mimeType === "image/jpeg") out.push({
859
+ severity: "info",
860
+ code: "photo-depth-lossy",
861
+ path: `${at}.depth`,
862
+ message: `Depth map "${String(o.depth)}" is a JPEG: lossy compression adds steps and noise to the relief and drops the alpha cut-edge mask.`,
863
+ hint: `Use a PNG depth map (\`agent3d assets depth ${String(o.src)}\` writes one).`
864
+ });
865
+ }
866
+ return out;
867
+ }
809
868
  function textureFiles(scene) {
810
869
  return [...new Set(collectAssetRefs(scene).filter((r) => r.kind === "texture" || r.kind === "hdri").map((r) => r.path))];
811
870
  }
@@ -835,6 +894,7 @@ function drawCallCauses(scene, shadowLights = 0, prepass = false) {
835
894
  why.push(`"${o.id}" per-letter text (splitLetters / reveal), ${glyphs} glyphs${layers > 1 ? " × outline" : ""}`);
836
895
  } else calls += layers;
837
896
  } else if (d.kind === "mesh" || d.kind === "instances" || d.kind === "particles" || d.kind === "svg") calls += 1;
897
+ else if (d.kind === "photo") calls += d.mode === "layers" && d.depth ? typeof d.layers === "number" ? d.layers : 6 : 1;
838
898
  else if (d.kind === "model" || d.kind === "generator") {
839
899
  calls += d.kind === "model" ? 4 : 2;
840
900
  const key = d.kind === "model" ? `model:${String(d.src)}` : `generator:${String(d.generator)}:${JSON.stringify(d.params ?? {})}`;
@@ -879,7 +939,7 @@ function framingIssues(scene, inspect) {
879
939
  walkObjects(scene.objects, (o) => {
880
940
  declared.add(o.id);
881
941
  const def = o;
882
- if (def.kind === "particles" || def.kind === "generator" && def.generator && scatter.has(def.generator)) spread.add(o.id);
942
+ if (def.kind === "particles" || def.kind === "photo" || def.kind === "generator" && def.generator && scatter.has(def.generator)) spread.add(o.id);
883
943
  });
884
944
  const animated = /* @__PURE__ */ new Set();
885
945
  let cameraMoves = (scene.camera?.shots?.length ?? 0) > 0;