@fleox/agent3d 0.4.0 → 0.5.2

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 (101) hide show
  1. package/README.md +45 -14
  2. package/changelog.json +24 -0
  3. package/dist/agent/agent3d.mjs +779 -85
  4. package/dist/agent/chunks/{assets-YBkgdfgy.mjs → assets-DdzHgVcn.mjs} +2 -2
  5. package/dist/agent/chunks/{browser-Dil7VM5m.mjs → browser-nFaRUETt.mjs} +1 -1
  6. package/dist/agent/chunks/{cdp-DLEis_Z3.mjs → cdp-6vF_gP-H.mjs} +1 -1
  7. package/dist/agent/chunks/{check-DP9fRYbK.mjs → check-E7GdPxTt.mjs} +14 -2
  8. package/dist/agent/chunks/{depth-CD_ql3QJ.mjs → depth-Bf7cHwod.mjs} +4 -4
  9. package/dist/agent/chunks/{depth-BZT4gseQ.mjs → depth-DEaogEAi.mjs} +4 -114
  10. package/dist/agent/chunks/{export-CEX5DFLo.mjs → export-BSOqVfPT.mjs} +8 -4
  11. package/dist/agent/chunks/{imageCodec-DeGfmBp3.mjs → imageCodec-DXxqkEQA.mjs} +53 -4
  12. package/dist/agent/chunks/{objects-DuytRxiC.mjs → objects-DvzrcVmK.mjs} +2 -2
  13. package/dist/agent/chunks/{optimizeSizing-B-BBiUkD.mjs → optimizeSizing-Dd8vaSnE.mjs} +24 -1
  14. package/dist/agent/chunks/{package-DjRnLzcU.mjs → package-Bn7PKfXn.mjs} +1 -1
  15. package/dist/agent/chunks/photoPlacement-D-k3mD0T.mjs +138 -0
  16. package/dist/agent/chunks/plate-Cwl35I2T.mjs +604 -0
  17. package/dist/agent/chunks/pngEncode-BMc3U9QC.mjs +119 -0
  18. package/dist/agent/chunks/{render-B05DU4Q5.mjs → render-CCKciCgu.mjs} +76 -11
  19. package/dist/agent/chunks/{scene-DWgXH6As.mjs → scene-DSjsun-3.mjs} +22 -5
  20. package/dist/agent/chunks/{server-Dt_YFvN7.mjs → server-CLvLORgA.mjs} +1 -1
  21. package/dist/agent/chunks/{tools-CZyIc4zw.mjs → tools-Vs74Xopx.mjs} +142 -13
  22. package/dist/runtime/agent3d-photo.js +51 -10
  23. package/dist/runtime/agent3d-runtime.js +23 -23
  24. package/dist/runtime/agent3d-runtime.single.js +405 -134
  25. package/dist/runtime/chunks/photo-Dq-AKlfw.js +526 -0
  26. package/dist/studio/assets/BufferGeometryUtils-BbzK4rCj.js +1 -0
  27. package/dist/studio/assets/{EXRLoader-BKkzlNd8.js → EXRLoader-CuDOo1xG.js} +1 -1
  28. package/dist/studio/assets/{FontLoader-Bzjx8mXt.js → FontLoader-DlBfss5q.js} +1 -1
  29. package/dist/studio/assets/{GLTFLoader-1Zd9N406.js → GLTFLoader-bl1eymL4.js} +1 -1
  30. package/dist/studio/assets/{GroundedSkybox-BEMqNCBD.js → GroundedSkybox-cLn9JVlt.js} +1 -1
  31. package/dist/studio/assets/{HDRLoader-DxB0kxPH.js → HDRLoader-8EiZoQQP.js} +1 -1
  32. package/dist/studio/assets/{OrbitControls-MlE9XiCg.js → OrbitControls-1xEm394I.js} +1 -1
  33. package/dist/studio/assets/{RectAreaLightUniformsLib-ClHrtYY6.js → RectAreaLightUniformsLib-S0AelTmO.js} +1 -1
  34. package/dist/studio/assets/{RoomEnvironment-MJ-jIEC8.js → RoomEnvironment-v4QurKxu.js} +1 -1
  35. package/dist/studio/assets/{SVGLoader-CIYl0nEy.js → SVGLoader-KDBVv02P.js} +1 -1
  36. package/dist/studio/assets/{Sky-DNMfpp92.js → Sky-D8Lp9Zh3.js} +1 -1
  37. package/dist/studio/assets/assets-DICv7P37.js +2 -0
  38. package/dist/studio/assets/camera-HsMeC1mn.js +2 -0
  39. package/dist/studio/assets/catalog-DDg904x2.js +1 -0
  40. package/dist/studio/assets/{editor-DzyukvQl.js → editor-BZLIZJC8.js} +1 -1
  41. package/dist/studio/assets/{extrude-9bG8hr2C.js → extrude-BpJda0hq.js} +1 -1
  42. package/dist/studio/assets/game-DnnuBk26.js +19 -0
  43. package/dist/studio/assets/{generators-BuVeRXnC.js → generators-C4n9MsXd.js} +1 -1
  44. package/dist/studio/assets/index-D-TPNQMQ.css +1 -0
  45. package/dist/studio/assets/index-cDbmaVDl.js +479 -0
  46. package/dist/studio/assets/model-CkPfLOl0.js +2 -0
  47. package/dist/studio/assets/params-BZqUA__U.js +1 -0
  48. package/dist/studio/assets/photo-CPGGCRa-.js +526 -0
  49. package/dist/studio/assets/{physicsHost-z9qn_mpg.js → physicsHost-EkPuIy04.js} +1 -1
  50. package/dist/studio/assets/{postfx-B3jDEaEK.js → postfx-Dp7mgfGJ.js} +2 -2
  51. package/dist/studio/assets/rolldown-runtime-4tVxZq34.js +1 -0
  52. package/dist/studio/assets/runtime-ByR4qfyV.js +572 -0
  53. package/dist/studio/assets/{shaders-bFhELLmD.js → shaders-DoRMwJE_.js} +1 -1
  54. package/dist/studio/assets/svg-n3rkKAm5.js +2 -0
  55. package/dist/studio/assets/text-BkPPDghK.js +3 -0
  56. package/dist/studio/assets/three.module-B9FlcKtd.js +4225 -0
  57. package/dist/studio/index.html +5 -3
  58. package/package.json +1 -1
  59. package/plugin/.claude-plugin/plugin.json +1 -1
  60. package/plugin/skills/agent3d-assets/SKILL.md +42 -27
  61. package/plugin/skills/agent3d-create/SKILL.md +77 -29
  62. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  63. package/plugin/skills/agent3d-create/references/recipes.md +6 -6
  64. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  65. package/plugin/skills/agent3d-edit/references/patch-ops.md +3 -3
  66. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  67. package/plugin/skills/agent3d-publish/SKILL.md +30 -23
  68. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  69. package/templates/hero-scroll-story/README.md +1 -1
  70. package/templates/photo-scroll-story/README.md +29 -0
  71. package/templates/photo-scroll-story/agent3d.json +8 -0
  72. package/templates/photo-scroll-story/assets/depth/lake-depth.png +0 -0
  73. package/templates/photo-scroll-story/assets/depth/street-depth.png +0 -0
  74. package/templates/photo-scroll-story/assets/manifest.json +46 -0
  75. package/templates/photo-scroll-story/assets/textures/lake.webp +0 -0
  76. package/templates/photo-scroll-story/assets/textures/street.webp +0 -0
  77. package/templates/photo-scroll-story/preview.png +0 -0
  78. package/templates/photo-scroll-story/scene.json +112 -0
  79. package/templates/photo-scroll-story/template.json +8 -0
  80. package/templates/photo-title-inside/README.md +31 -0
  81. package/templates/photo-title-inside/agent3d.json +8 -0
  82. package/templates/photo-title-inside/assets/depth/street-depth.png +0 -0
  83. package/templates/photo-title-inside/assets/manifest.json +25 -0
  84. package/templates/photo-title-inside/assets/textures/street.webp +0 -0
  85. package/templates/photo-title-inside/preview.png +0 -0
  86. package/templates/photo-title-inside/scene.json +80 -0
  87. package/templates/photo-title-inside/template.json +8 -0
  88. package/dist/runtime/chunks/photo-w6dwHX7j.js +0 -255
  89. package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +0 -1
  90. package/dist/studio/assets/assets--ehPZf8R.js +0 -1
  91. package/dist/studio/assets/camera-C0sxfRxy.js +0 -2
  92. package/dist/studio/assets/game-DNpTN_Ga.js +0 -19
  93. package/dist/studio/assets/index-BQT0otii.css +0 -1
  94. package/dist/studio/assets/index-C2nMYSoW.js +0 -479
  95. package/dist/studio/assets/model-DQgOrTs4.js +0 -2
  96. package/dist/studio/assets/params-D-Ul6GSt.js +0 -1
  97. package/dist/studio/assets/photo-Dx2IBJ11.js +0 -255
  98. package/dist/studio/assets/runtime-rd9RW3WH.js +0 -572
  99. package/dist/studio/assets/svg-BkV9LeqP.js +0 -2
  100. package/dist/studio/assets/text-Dp8gdjSA.js +0 -3
  101. package/dist/studio/assets/three.module-CnI50X0U.js +0 -4225
@@ -0,0 +1,119 @@
1
+ import { createRequire as __a3dRequire } from "node:module";
2
+ import { fileURLToPath as __a3dPath } from "node:url";
3
+ import { dirname as __a3dDirname } from "node:path";
4
+ __a3dRequire(import.meta.url);
5
+ const __filename = __a3dPath(import.meta.url);
6
+ __a3dDirname(__filename);
7
+ import { m as crc32 } from "./assets-DdzHgVcn.mjs";
8
+ // src/ops/pngEncode.ts
9
+ async function deflateZlib(data, deflate) {
10
+ if (deflate) return deflate(data);
11
+ const CS = globalThis.CompressionStream;
12
+ if (!CS) throw new Error("No deflate available: pass `deflate` (CompressionStream is missing).");
13
+ const stream = new Blob([data]).stream().pipeThrough(new CS("deflate"));
14
+ return new Uint8Array(await new Response(stream).arrayBuffer());
15
+ }
16
+ async function encodePng(rgba, width, height, opts = {}) {
17
+ if (rgba.length !== width * height * 4) throw new Error(`encodePng: expected ${width * height * 4} bytes, got ${rgba.length}`);
18
+ let channels = opts.channels ?? "auto";
19
+ if (channels === "auto") {
20
+ let grey = true;
21
+ let opaque = true;
22
+ for (let i = 0; i < rgba.length && (grey || opaque); i += 4) {
23
+ if (rgba[i] !== rgba[i + 1] || rgba[i] !== rgba[i + 2]) grey = false;
24
+ if (rgba[i + 3] !== 255) opaque = false;
25
+ }
26
+ channels = grey ? opaque ? 1 : 2 : opaque ? 3 : 4;
27
+ }
28
+ const colorType = {
29
+ 1: 0,
30
+ 2: 4,
31
+ 3: 2,
32
+ 4: 6
33
+ }[channels];
34
+ const stride = width * channels;
35
+ const raw = new Uint8Array((stride + 1) * height);
36
+ const row = new Uint8Array(stride);
37
+ const prev = new Uint8Array(stride);
38
+ const cand = new Uint8Array(stride);
39
+ for (let y = 0; y < height; y++) {
40
+ for (let x = 0; x < width; x++) {
41
+ const s = (y * width + x) * 4;
42
+ const d = x * channels;
43
+ if (channels === 1) row[d] = rgba[s];
44
+ else if (channels === 2) row[d] = rgba[s], row[d + 1] = rgba[s + 3];
45
+ else for (let c = 0; c < channels; c++) row[d + c] = rgba[s + c];
46
+ }
47
+ let best = 0;
48
+ let bestScore = Infinity;
49
+ const out = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
50
+ for (let f = 0; f < 5; f++) {
51
+ let score = 0;
52
+ for (let i = 0; i < stride; i++) {
53
+ const a = i >= channels ? row[i - channels] : 0;
54
+ const b = prev[i];
55
+ const c = i >= channels ? prev[i - channels] : 0;
56
+ let p;
57
+ if (f === 0) p = 0;
58
+ else if (f === 1) p = a;
59
+ else if (f === 2) p = b;
60
+ else if (f === 3) p = a + b >> 1;
61
+ else {
62
+ const pa = Math.abs(b - c);
63
+ const pb = Math.abs(a - c);
64
+ const pc = Math.abs(a + b - 2 * c);
65
+ p = pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
66
+ }
67
+ const v = row[i] - p & 255;
68
+ cand[i] = v;
69
+ score += v < 128 ? v : 256 - v;
70
+ if (score >= bestScore) break;
71
+ }
72
+ if (score < bestScore) {
73
+ bestScore = score;
74
+ best = f;
75
+ out.set(cand);
76
+ }
77
+ }
78
+ raw[y * (stride + 1)] = best;
79
+ prev.set(row);
80
+ }
81
+ const idat = await deflateZlib(raw, opts.deflate);
82
+ const ihdr = /* @__PURE__ */ new Uint8Array(13);
83
+ const dv = new DataView(ihdr.buffer);
84
+ dv.setUint32(0, width);
85
+ dv.setUint32(4, height);
86
+ ihdr[8] = 8;
87
+ ihdr[9] = colorType;
88
+ const chunks = [
89
+ chunk("IHDR", ihdr),
90
+ chunk("IDAT", idat),
91
+ chunk("IEND", /* @__PURE__ */ new Uint8Array(0))
92
+ ];
93
+ const sig = [
94
+ 137,
95
+ 80,
96
+ 78,
97
+ 71,
98
+ 13,
99
+ 10,
100
+ 26,
101
+ 10
102
+ ];
103
+ const total = 8 + chunks.reduce((n, c) => n + c.length, 0);
104
+ const png = new Uint8Array(total);
105
+ png.set(sig, 0);
106
+ let o = 8;
107
+ for (const c of chunks) png.set(c, o), o += c.length;
108
+ return png;
109
+ }
110
+ function chunk(type, data) {
111
+ const out = new Uint8Array(12 + data.length);
112
+ const dv = new DataView(out.buffer);
113
+ dv.setUint32(0, data.length);
114
+ for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);
115
+ out.set(data, 8);
116
+ dv.setUint32(8 + data.length, crc32(out.subarray(4, 8 + data.length)));
117
+ return out;
118
+ }
119
+ export { encodePng as t };
@@ -6,9 +6,9 @@ const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
7
  import { t as closest } from "./suggest-Cpcgv1RP.mjs";
8
8
  import { n as findObject, o as walkObjects } from "./tree-CqSj-o8T.mjs";
9
- import { B as runtimeBuilt, H as CliError, R as libraryDir, V as runtimeDir, n as sendText, r as startLocalServer } from "../agent3d.mjs";
10
- import { launchBrowser, requireBrowser } from "./browser-Dil7VM5m.mjs";
11
- import { t as CdpClient } from "./cdp-DLEis_Z3.mjs";
9
+ import { J as CliError, K as runtimeBuilt, W as libraryDir, i as SOCIAL_PRESETS, l as socialDuration, n as sendText, o as coverScene, q as runtimeDir, r as startLocalServer, s as imageHeaderSize } from "../agent3d.mjs";
10
+ import { launchBrowser, requireBrowser } from "./browser-nFaRUETt.mjs";
11
+ import { t as CdpClient } from "./cdp-6vF_gP-H.mjs";
12
12
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
13
13
  // agent/render/preview.ts
14
14
  var RUNTIME_URL = "/__runtime/agent3d-runtime.js";
@@ -1217,6 +1217,7 @@ async function renderVideo(opts) {
1217
1217
  duration: opts.duration,
1218
1218
  fps: opts.fps,
1219
1219
  quality: opts.quality,
1220
+ preset: opts.preset,
1220
1221
  write: false,
1221
1222
  timeoutMs: opts.timeoutMs,
1222
1223
  log: opts.log
@@ -1231,7 +1232,11 @@ async function renderVideo(opts) {
1231
1232
  deviceScaleFactor: 1
1232
1233
  },
1233
1234
  ms: r.ms,
1234
- codec: r.codec
1235
+ codec: r.codec,
1236
+ ...r.preset ? {
1237
+ preset: r.preset,
1238
+ notes: r.notes
1239
+ } : {}
1235
1240
  };
1236
1241
  }
1237
1242
  var QUALITY_SS = {
@@ -1270,20 +1275,76 @@ function scrollTime(scene, progress) {
1270
1275
  const d = tl?.trigger === "scroll" && tl.duration > 0 ? tl.duration : 4;
1271
1276
  return Math.round(Math.min(Math.max(progress, 0), 1) * d * 1e3) / 1e3;
1272
1277
  }
1278
+ function socialPlan(opts, authored = readScene(opts.projectDir), readImage = (src) => readProjectImage(opts.projectDir, src)) {
1279
+ const preset = opts.preset ? SOCIAL_PRESETS[opts.preset] : void 0;
1280
+ const size = opts.size ?? (preset ? `${preset.width}x${preset.height}` : void 0);
1281
+ const notes = [];
1282
+ const hasPhoto = (authored.objects ?? []).some((o) => o.kind === "photo");
1283
+ const fit = opts.fit ?? (preset && hasPhoto ? "cover" : void 0);
1284
+ let scene = authored;
1285
+ if (fit === "cover") {
1286
+ const v = viewportFor(authored, {
1287
+ size,
1288
+ width: opts.width ?? 1280
1289
+ });
1290
+ const sizes = /* @__PURE__ */ new Map();
1291
+ const imageSize = (src) => {
1292
+ if (!sizes.has(src)) {
1293
+ const bytes = readImage(src);
1294
+ sizes.set(src, bytes ? imageHeaderSize(bytes) : null);
1295
+ }
1296
+ return sizes.get(src);
1297
+ };
1298
+ const c = coverScene(authored, v.width / v.height, imageSize);
1299
+ scene = c.scene;
1300
+ notes.push(...c.notes);
1301
+ } else if (preset && !hasPhoto) notes.push("No 3D photo: the runtime keeps its own fit (the scene's design width stays visible).");
1302
+ let duration, start = 0;
1303
+ if (preset && opts.duration === void 0) {
1304
+ const d = socialDuration(authored, preset);
1305
+ duration = d.duration;
1306
+ start = d.start;
1307
+ notes.push(`Duration ${d.duration} s: ${d.source}.`);
1308
+ }
1309
+ return {
1310
+ scene,
1311
+ size,
1312
+ duration,
1313
+ start,
1314
+ bitrate: preset?.bitrate,
1315
+ preset: preset?.id,
1316
+ fit,
1317
+ notes
1318
+ };
1319
+ }
1320
+ function readProjectImage(projectDir, src) {
1321
+ try {
1322
+ if (src.startsWith("library:")) {
1323
+ const a = JSON.parse(readFileSync(join(libraryDir(), "index.json"), "utf8")).assets.find((x) => x.id === src.slice(8));
1324
+ return a ? new Uint8Array(readFileSync(join(libraryDir(), a.path))) : null;
1325
+ }
1326
+ if (/^[a-z]+:/i.test(src)) return null;
1327
+ return new Uint8Array(readFileSync(resolve(projectDir, src)));
1328
+ } catch {
1329
+ return null;
1330
+ }
1331
+ }
1273
1332
  var even = (n) => n - n % 2;
1274
1333
  async function renderMedia(opts) {
1275
1334
  const t0 = Date.now();
1276
1335
  const format = opts.format ?? mediaFormatFromPath(opts.out);
1277
1336
  if (!format) throw new CliError("usage", `Unknown video / animation format for "${opts.out}".`, "Use a .mp4, .webm, .gif or .webp file name (or --format).", 2);
1278
1337
  const animated = format === "gif" || format === "webp";
1279
- const scene = sceneForRender(opts.scene ?? readScene(opts.projectDir), { transparent: opts.transparent && animated });
1280
- const fps = Math.max(1, Math.min(60, Math.round(opts.fps ?? (format === "gif" ? 15 : format === "webp" ? 20 : 30))));
1281
- const duration = opts.duration ?? (scene.timeline?.duration && scene.timeline.duration > 0 ? scene.timeline.duration : 5);
1338
+ const social = socialPlan(opts, opts.scene ?? readScene(opts.projectDir));
1339
+ const source = social.scene;
1340
+ const scene = sceneForRender(source, { transparent: opts.transparent && animated });
1341
+ const fps = Math.max(1, Math.min(60, Math.round(opts.fps ?? (opts.preset ? 30 : format === "gif" ? 15 : format === "webp" ? 20 : 30))));
1342
+ const duration = opts.duration ?? social.duration ?? (scene.timeline?.duration && scene.timeline.duration > 0 ? scene.timeline.duration : 5);
1282
1343
  if (!(duration > 0) || duration > 300) throw new CliError("usage", "--duration must be between 0 and 300 seconds.", void 0, 2);
1283
1344
  const count = Math.max(1, Math.round(duration * fps));
1284
1345
  if (animated && count > 900) throw new CliError("usage", `${count} frames is too many for a ${format.toUpperCase()} (max 900).`, "Lower --fps or --duration, or render a video (.mp4 / .webm).", 2);
1285
1346
  const base = viewportFor(scene, {
1286
- size: opts.size,
1347
+ size: social.size,
1287
1348
  width: opts.width ?? (format === "gif" ? 640 : format === "webp" ? 800 : 1280),
1288
1349
  scale: opts.scale ?? 1
1289
1350
  });
@@ -1300,7 +1361,7 @@ async function renderMedia(opts) {
1300
1361
  const transparentScene = !!scene.target?.transparent;
1301
1362
  const bg = parseBg(opts.bg);
1302
1363
  const bgFill = bg && bg !== "none" ? bg : !animated && transparentScene ? "#ffffff" : void 0;
1303
- const start = Math.max(0, opts.start ?? 0);
1364
+ const start = Math.max(0, opts.start ?? (opts.duration === void 0 ? social.start : 0));
1304
1365
  const inputs = [...segmentInputs(opts.segment, start), ...opts.input ?? []].map((e, i) => ({
1305
1366
  e,
1306
1367
  i
@@ -1394,7 +1455,7 @@ async function renderMedia(opts) {
1394
1455
  codec = "vp8 (key frames)";
1395
1456
  } else {
1396
1457
  const pixels = out.width * out.height * fps;
1397
- const bitrate = Math.round(opts.bitrate ?? Math.min(4e7, Math.max(1e6, pixels * (opts.quality === "ultra" ? .16 : opts.quality === "high" ? .12 : .08))));
1458
+ const bitrate = Math.round(opts.bitrate ?? social.bitrate ?? Math.min(4e7, Math.max(1e6, pixels * (opts.quality === "ultra" ? .16 : opts.quality === "high" ? .12 : .08))));
1398
1459
  await session.evaluate(`window.__agent3dVideoStart(${JSON.stringify({
1399
1460
  codec: chosen,
1400
1461
  width: out.width,
@@ -1448,10 +1509,14 @@ async function renderMedia(opts) {
1448
1509
  frames: count,
1449
1510
  fps,
1450
1511
  duration,
1512
+ ...start ? { start } : {},
1451
1513
  size: out,
1452
1514
  supersampling: ss,
1453
1515
  bytes: data.byteLength,
1454
1516
  ms: Date.now() - t0,
1517
+ ...social.preset ? { preset: social.preset } : {},
1518
+ ...social.fit ? { fit: social.fit } : {},
1519
+ ...social.notes.length ? { notes: social.notes } : {},
1455
1520
  ...inputs.length ? {
1456
1521
  inputs: inputs.length,
1457
1522
  state
@@ -1508,4 +1573,4 @@ async function renderExportImages(opts) {
1508
1573
  await session.close();
1509
1574
  }
1510
1575
  }
1511
- export { INPUT_SHAPES, QUALITY_SS, applyInputsUpTo, checkInputsForScene, clampSs, frameBox, frameSuffix, frameTimes, inputCall, isolateScene, mediaFormatFromPath, openRenderSession, parseAspect, parseBg, parseInputScript, parseQuality, projectPath, renderExportImages, renderMedia, renderPoster, renderProject, renderVideo, sceneForRender, scrollTime, segmentInputs, timestamp, viewportFor };
1576
+ export { INPUT_SHAPES, QUALITY_SS, applyInputsUpTo, checkInputsForScene, clampSs, frameBox, frameSuffix, frameTimes, inputCall, isolateScene, mediaFormatFromPath, openRenderSession, parseAspect, parseBg, parseInputScript, parseQuality, projectPath, renderExportImages, renderMedia, renderPoster, renderProject, renderVideo, sceneForRender, scrollTime, segmentInputs, socialPlan, timestamp, viewportFor };
@@ -6,8 +6,9 @@ const __filename = __a3dPath(import.meta.url);
6
6
  __a3dDirname(__filename);
7
7
  import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
8
8
  import { c as removeAt, i as getAt, l as setAt, n as clone, o as mergePatch, r as deepEqual, s as parsePath, t as PathError } from "./jsonPath-DUCe1JpS.mjs";
9
- import { A as OpsError, D as isValidId, _ as validateScene, d as readSceneFile, f as saveScene, j as hasErrors } from "../agent3d.mjs";
9
+ import { C as validateScene, I as OpsError, L as hasErrors, N as isValidId, _ as readSceneFile, v as saveScene } from "../agent3d.mjs";
10
10
  import { t as closest } from "./suggest-Cpcgv1RP.mjs";
11
+ import { n as photoPlacement } from "./photoPlacement-D-k3mD0T.mjs";
11
12
  import { a as objectDetail, i as isDescendant, n as findObject, o as walkObjects, t as allObjectIds } from "./tree-CqSj-o8T.mjs";
12
13
  // src/ops/scene.ts
13
14
  var scene_exports = /* @__PURE__ */ __exportAll({
@@ -37,20 +38,36 @@ function backgroundText(bg) {
37
38
  function summarizeScene(scene) {
38
39
  let objects = 0;
39
40
  let behaviours = 0;
40
- const node = (o) => {
41
+ const node = (o, base) => {
41
42
  objects++;
42
43
  behaviours += o.behaviours?.length ?? 0;
44
+ const pos = Array.isArray(o.position) ? o.position : [
45
+ 0,
46
+ 0,
47
+ 0
48
+ ];
49
+ const world = [
50
+ base[0] + (Number(pos[0]) || 0),
51
+ base[1] + (Number(pos[1]) || 0),
52
+ base[2] + (Number(pos[2]) || 0)
53
+ ];
54
+ const placed = o.kind === "photo" ? photoPlacement(scene, o, world) : null;
43
55
  return {
44
56
  id: o.id,
45
57
  kind: o.kind,
46
- detail: objectDetail(o),
58
+ detail: objectDetail(o) + (placed ? ` · z ${placed.zFar} (far) … ${placed.zNear} (near)${placed.occlude ? " · occlude" : ""}` : ""),
47
59
  ...o.position ? { position: o.position } : {},
48
60
  ...o.behaviours?.length ? { behaviours: o.behaviours.map((b) => b.type) } : {},
49
61
  ...o.visible === false ? { hidden: true } : {},
50
- ...o.children?.length ? { children: o.children.map(node) } : {}
62
+ ...placed ? { depthRange: [placed.zFar, placed.zNear] } : {},
63
+ ...o.children?.length ? { children: o.children.map((c) => node(c, world)) } : {}
51
64
  };
52
65
  };
53
- const tree = (scene.objects ?? []).filter((o) => o && typeof o === "object").map(node);
66
+ const tree = (scene.objects ?? []).filter((o) => o && typeof o === "object").map((o) => node(o, [
67
+ 0,
68
+ 0,
69
+ 0
70
+ ]));
54
71
  const lighting = scene.environment?.lighting;
55
72
  return {
56
73
  id: scene.id,
@@ -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 { U as toCliError } from "../agent3d.mjs";
7
+ import { Y as toCliError } from "../agent3d.mjs";
8
8
  // agent/mcp/server.ts
9
9
  var SUPPORTED_PROTOCOLS = [
10
10
  "2025-06-18",
@@ -4,16 +4,17 @@ 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 { A as OpsError, C as CATALOG, _ as validateScene, a as listTemplates, d as readSceneFile, g as TARGET_KINDS, i as findTemplate, l as createProject, p as DEFAULT_ASPECT, u as loadProject } from "../agent3d.mjs";
7
+ import { C as validateScene, I as OpsError, S as TARGET_KINDS, _ as readSceneFile, a as SOCIAL_PRESET_IDS, c as parseSocialPreset, d as listTemplates, g as loadProject, h as createProject, k as CATALOG, u as findTemplate, y as DEFAULT_ASPECT } from "../agent3d.mjs";
8
8
  import { t as closest } from "./suggest-Cpcgv1RP.mjs";
9
- import { a as listAssets, f as optimizedExportSources, i as importAssetZip, l as searchAssetsDetailed, o as listLibrary, p as SOURCE_IDS, r as downloadAsset, s as parseResolution, t as addAsset, u as optimizeAssets } from "./assets-YBkgdfgy.mjs";
9
+ import { a as listAssets, f as optimizedExportSources, i as importAssetZip, l as searchAssetsDetailed, o as listLibrary, p as SOURCE_IDS, r as downloadAsset, s as parseResolution, t as addAsset, u as optimizeAssets } from "./assets-DdzHgVcn.mjs";
10
10
  import { r as modelFileBounds } from "./gltf-f_f0-OiV.mjs";
11
- import { a as estimateDepth, n as checkDepthRequest } from "./depth-BZT4gseQ.mjs";
12
- import { r as prefixFiles, t as buildExport } from "./export-CEX5DFLo.mjs";
11
+ import { a as estimateDepth, n as checkDepthRequest } from "./depth-DEaogEAi.mjs";
12
+ import { n as generatePlate, t as checkPlateRequest } from "./plate-Cwl35I2T.mjs";
13
+ import { r as prefixFiles, t as buildExport } from "./export-BSOqVfPT.mjs";
13
14
  import { i as getAt, t as PathError } from "./jsonPath-DUCe1JpS.mjs";
14
- import { n as checkProject } from "./check-DP9fRYbK.mjs";
15
- import { a as updateObject, i as removeObject, n as listObjects, t as addObject } from "./objects-DuytRxiC.mjs";
16
- import { i as patchScene, n as applyScene, o as summarizeScene, r as getScene, t as PATCH_OPS } from "./scene-DWgXH6As.mjs";
15
+ import { n as checkProject } from "./check-E7GdPxTt.mjs";
16
+ import { a as updateObject, i as removeObject, n as listObjects, t as addObject } from "./objects-DvzrcVmK.mjs";
17
+ import { i as patchScene, n as applyScene, o as summarizeScene, r as getScene, t as PATCH_OPS } from "./scene-DSjsun-3.mjs";
17
18
  // src/ai/shared.ts
18
19
  function str(input, key, required = true) {
19
20
  const v = input[key];
@@ -1021,7 +1022,7 @@ var ASSET_TOOLS = [
1021
1022
  },
1022
1023
  {
1023
1024
  name: "image_depth",
1024
- description: "Estimate a depth map for a photo (the \"3D photo\" effect: a photo object with `depth`). Runs Depth Anything V2 Small locally (CLI / MCP host: headless Chrome, ~1-3 s per image; the 27 MB Apache-2.0 model is downloaded once into the user cache, later runs work offline). Writes a grey PNG (white = near, transparent where depth jumps) at the photo size (max 1024 px) under assets/depth/, registered in assets/manifest.json with the photo's licence. Returns { path, width, height, ms, model, suggestion: { kind: \"photo\", src, depth } } — then add or update the photo object with `depth: path`. Without a host that can run it, paint a depth map by hand instead.",
1025
+ description: "Estimate a depth map for a photo (the \"3D photo\" effect: a photo object with `depth`). Runs Depth Anything V2 Small locally (CLI / MCP host: headless Chrome, ~1-3 s per image; the 27 MB Apache-2.0 model is downloaded once into the user cache, later runs work offline). Writes a grey PNG (white = near, transparent where depth jumps) at the photo size (max 1024 px) under assets/depth/, registered in assets/manifest.json with the photo's licence. Returns { path, width, height, ms, model, suggestion: { kind: \"photo\", src, depth } } — then add or update the photo object with `depth: path`. `plate: true` also builds the background plate (see image_plate) and returns it as `plate` (suggestion gains plate + plateDepth): use it for bold moves (strength ≥ 0.7, mode mesh / layers). Without a host that can run it, paint a depth map by hand instead.",
1025
1026
  inputSchema: {
1026
1027
  type: "object",
1027
1028
  properties: {
@@ -1044,6 +1045,10 @@ var ASSET_TOOLS = [
1044
1045
  minimum: 16,
1045
1046
  maximum: 8192,
1046
1047
  description: "Longest side of the written depth map (default: the photo size, capped at 1024)."
1048
+ },
1049
+ plate: {
1050
+ type: "boolean",
1051
+ description: "Also build the background plate + its depth (image_plate with the new depth map). Default false."
1047
1052
  }
1048
1053
  },
1049
1054
  required: ["image"]
@@ -1065,15 +1070,123 @@ var ASSET_TOOLS = [
1065
1070
  hint: "Run `agent3d assets depth <image>` from the CLI, or provide a depth map by hand (grey PNG, white = near, same aspect as the photo) and set it as the photo object's `depth`."
1066
1071
  };
1067
1072
  const r = await ctx.host.withDepthEstimator((estimator) => estimateDepth(ctx.fs, req, estimator));
1073
+ if (input.plate === true) {
1074
+ if (!ctx.host.withPixelCodec) return {
1075
+ ...r,
1076
+ plate: {
1077
+ status: "refused",
1078
+ reason: "This host cannot decode images for the plate."
1079
+ },
1080
+ hint: `Set it on the photo object: object_update { id, set: { depth: "${r.path}" } }.`
1081
+ };
1082
+ const plate = await ctx.host.withPixelCodec((codec) => generatePlate(ctx.fs, {
1083
+ image: req.image,
1084
+ depth: r.path,
1085
+ library: ctx.host?.library,
1086
+ deflate: ctx.host?.deflate,
1087
+ inflate: ctx.host?.inflate
1088
+ }, codec));
1089
+ const suggestion = {
1090
+ ...r.suggestion,
1091
+ ...plate.suggestion
1092
+ };
1093
+ return {
1094
+ ...r,
1095
+ plate,
1096
+ suggestion,
1097
+ hint: `Set them on the photo object: object_update { id, set: ${JSON.stringify({
1098
+ depth: r.path,
1099
+ ...plate.suggestion
1100
+ })} }, or object_add with ${JSON.stringify(suggestion)}. Then render_preview with pointer input at the extremes to check the edges.`
1101
+ };
1102
+ }
1068
1103
  return {
1069
1104
  ...r,
1070
1105
  hint: `Set it on the photo object: object_update { id, set: { depth: "${r.path}" } }, or object_add with ${JSON.stringify(r.suggestion)}. Then render_preview to check the parallax.`
1071
1106
  };
1072
1107
  }
1073
1108
  },
1109
+ {
1110
+ name: "image_plate",
1111
+ description: "Build the background plate of a 3D photo: the photo with the foreground removed next to its depth edges and filled with the background behind it (from the far side only), plus the plate depth (the background depth continued). Set them on the photo object as `plate` + `plateDepth`: when the view moves, the runtime shows the plate where the foreground uncovers the background (parallax, mesh backing, layers) instead of smearing / stretching edge pixels — so bigger moves (strength 0.7-1, mode mesh) stay clean. Needs the photo's depth map (image_depth first, or image_depth { plate: true } for both at once); found from `depth`, else the photo object showing `image`, else assets/depth/<name>-depth.png. Writes assets/depth/<name>-plate.webp (WebP, PNG without a WebP encoder) and assets/depth/<name>-plate-depth.png, registered with the photo's licence; pure TS, ≈ 0.5 s (CLI / MCP host: headless Chrome decodes the photo). Returns { path, depthPath, holeWidth, holePercent, ms, suggestion: { plate, plateDepth } }.",
1112
+ inputSchema: {
1113
+ type: "object",
1114
+ properties: {
1115
+ image: {
1116
+ type: "string",
1117
+ description: "The photo: project path (\"assets/textures/photo.jpg\") or \"library:<id>\"."
1118
+ },
1119
+ depth: {
1120
+ type: "string",
1121
+ description: "Its depth map PNG (default: the photo object's depth, else assets/depth/<name>-depth.png)."
1122
+ },
1123
+ out: {
1124
+ type: "string",
1125
+ description: "Project path of the plate (default \"assets/depth/<name>-plate.webp\")."
1126
+ },
1127
+ outDepth: {
1128
+ type: "string",
1129
+ description: "Project path of the plate depth PNG (default \"assets/depth/<name>-plate-depth.png\")."
1130
+ },
1131
+ maxSize: {
1132
+ type: "integer",
1133
+ minimum: 64,
1134
+ maximum: 4096,
1135
+ description: "Longest side of the plate (default: the photo size, capped at 1024)."
1136
+ },
1137
+ strength: {
1138
+ type: "number",
1139
+ minimum: .05,
1140
+ maximum: 1,
1141
+ description: "Strongest photo strength the plate must cover (default 1): sets how far from each edge the foreground is removed."
1142
+ },
1143
+ width: {
1144
+ type: "integer",
1145
+ minimum: 2,
1146
+ maximum: 512,
1147
+ description: "Hole width in plate pixels for a full near-to-far jump (overrides strength; default ≈ 10 % of the short side at strength 1)."
1148
+ },
1149
+ format: {
1150
+ type: "string",
1151
+ enum: ["webp", "png"],
1152
+ description: "Plate image format (default webp)."
1153
+ }
1154
+ },
1155
+ required: ["image"]
1156
+ },
1157
+ mutating: true,
1158
+ async handler(ctx, input) {
1159
+ const fmt = optStr(input, "format");
1160
+ const req = {
1161
+ image: str(input, "image").replace(/^\.\//, ""),
1162
+ depth: optStr(input, "depth"),
1163
+ out: optStr(input, "out"),
1164
+ outDepth: optStr(input, "outDepth"),
1165
+ maxSize: num(input, "maxSize"),
1166
+ strength: num(input, "strength"),
1167
+ width: num(input, "width"),
1168
+ format: fmt === "png" || fmt === "webp" ? fmt : void 0,
1169
+ library: ctx.host?.library,
1170
+ deflate: ctx.host?.deflate,
1171
+ inflate: ctx.host?.inflate
1172
+ };
1173
+ if (fmt !== void 0 && req.format === void 0) throw new OpsError("invalid", `format must be "webp" or "png" (got "${fmt}").`);
1174
+ await checkPlateRequest(ctx.fs, req);
1175
+ if (!ctx.host?.withPixelCodec) return {
1176
+ status: "refused",
1177
+ reason: "This host cannot decode images (the plate needs the CLI / MCP host with headless Chrome).",
1178
+ hint: "Run `agent3d assets plate <image>` from the CLI."
1179
+ };
1180
+ const r = await ctx.host.withPixelCodec((codec) => generatePlate(ctx.fs, req, codec));
1181
+ return {
1182
+ ...r,
1183
+ hint: `Set them on the photo object: object_update { id, set: ${JSON.stringify(r.suggestion)} }. Then render_preview with pointer input at the extremes (e.g. input [{ t: 0.5, pointer: [-1, 0.7] }, { t: 1.5, pointer: [1, -0.7] }]) to check the edges.`
1184
+ };
1185
+ }
1186
+ },
1074
1187
  {
1075
1188
  name: "export",
1076
- description: "Build the self-contained embed and write it into the project (default dist/<format>/). \"embed\": a folder for any static site — agent3d-runtime/ (shared), <name>/scene.json + assets + scripts, index.html (demo page), snippet.html (paste into the page), EMBED.md and frameworks/ (React / Vue / Svelte wrappers). \"zip\": the same folder as one <name>-embed.zip. \"single-html\": one <name>.html with everything inline. Library assets are copied; nothing is hotlinked. Options: `baseUrl` (where the folder is served, so the snippet works from any page), `cacheBust` (versioned runtime folder + ?v= hash for long-term caching), `integrity` (SRI hash on the runtime script, default true), `optimize` (export lighter copies of the assets — the project is not modified), `og` (render a 1200×630 og-image.png social preview), `runtime` (\"auto\" default: a scene that is a single 3D photo ships the photo-only lite runtime agent3d-photo.js, ~14 KB gzipped instead of ~210 KB; \"full\" forces agent3d-runtime.js — the result says which in `runtime`, with `runtimeReasons` when full). Run check first; returns the snippet, sizes and budget warnings. When the host can render (CLI / MCP / Studio with Chrome): \"poster\" writes a still image (dist/poster.webp; `time`, `image`), \"video\" an MP4 / WebM (dist/video.webm; `codec`, `duration`, `fps`, `size`), \"gif\" / \"animated-webp\" an animated image (dist/animation.gif / .webp), returning { path } — `quality` supersamples, `transparent` keeps the alpha (poster, gif, animated-webp).",
1189
+ description: "Build the self-contained embed and write it into the project (default dist/<format>/). \"embed\": a folder for any static site — agent3d-runtime/ (shared), <name>/scene.json + assets + scripts, index.html (demo page), snippet.html (paste into the page), EMBED.md and frameworks/ (React / Vue / Svelte wrappers). \"zip\": the same folder as one <name>-embed.zip. \"single-html\": one <name>.html with everything inline. Library assets are copied; nothing is hotlinked. Options: `baseUrl` (where the folder is served, so the snippet works from any page), `cacheBust` (versioned runtime folder + ?v= hash for long-term caching), `integrity` (SRI hash on the runtime script, default true), `optimize` (export lighter copies of the assets — the project is not modified), `og` (render a 1200×630 og-image.png social preview), `runtime` (\"auto\" default: a scene that is a single 3D photo ships the photo-only lite runtime agent3d-photo.js, ~19 KB gzipped instead of ~210 KB; \"full\" forces agent3d-runtime.js — the result says which in `runtime`, with `runtimeReasons` when full). Run check first; returns the snippet, sizes and budget warnings. When the host can render (CLI / MCP / Studio with Chrome): \"poster\" writes a still image (dist/poster.webp; `time`, `image`), \"video\" an MP4 / WebM (dist/video.webm; `codec`, `duration`, `fps`, `size`; `preset` vertical / square / landscape / story = a social-network MP4: 1080×1920 / 1080×1080 / 1920×1080, 30 fps, one seamless loop of the 3D photo motion, a cover fit so the photo fills the frame — dist/video-<preset>.mp4), \"gif\" / \"animated-webp\" an animated image (dist/animation.gif / .webp), returning { path } — `quality` supersamples, `transparent` keeps the alpha (poster, gif, animated-webp).",
1077
1190
  inputSchema: {
1078
1191
  type: "object",
1079
1192
  properties: {
@@ -1154,7 +1267,12 @@ var ASSET_TOOLS = [
1154
1267
  type: "number",
1155
1268
  minimum: .1,
1156
1269
  maximum: 120,
1157
- description: "video / gif / animated-webp: seconds (default the timeline duration, else 5)."
1270
+ description: "video / gif / animated-webp: seconds (default the timeline duration, else 5; with a preset one seamless loop of the 3D photo motion)."
1271
+ },
1272
+ preset: {
1273
+ type: "string",
1274
+ enum: [...SOCIAL_PRESET_IDS],
1275
+ description: "video / gif / animated-webp: social preset — vertical (1080×1920, Reels / TikTok / LinkedIn), square (1080×1080), landscape (1920×1080), story (1080×1920, max 15 s). Sets size, 30 fps, duration (one seamless loop), bitrate and a cover fit (the 3D photo fills the frame). Video default codec: mp4."
1158
1276
  },
1159
1277
  fps: {
1160
1278
  type: "integer",
@@ -1284,9 +1402,16 @@ async function mediaExport(ctx, requested, input) {
1284
1402
  if (quality !== void 0 && !QUALITIES.includes(quality)) throw new OpsError("invalid", `Unknown quality "${quality}".`, `Use ${QUALITIES.join(", ")}.`);
1285
1403
  const outIn = optStr(input, "out")?.replace(/^\.?\//, "");
1286
1404
  const image = optStr(input, "image") ?? (outIn?.endsWith(".png") ? "png" : "webp");
1287
- const codec = optStr(input, "codec") ?? (outIn?.toLowerCase().endsWith(".mp4") ? "mp4" : "webm");
1405
+ const presetIn = optStr(input, "preset");
1406
+ if (presetIn !== void 0 && !SOCIAL_PRESET_IDS.includes(presetIn)) {
1407
+ const p = parseSocialPreset(presetIn);
1408
+ throw new OpsError("invalid", "error" in p ? p.error : `Unknown preset "${presetIn}".`, "error" in p ? p.hint : void 0);
1409
+ }
1410
+ const preset = requested === "poster" ? void 0 : presetIn;
1411
+ const codec = optStr(input, "codec") ?? (outIn?.toLowerCase().endsWith(".mp4") || preset && !outIn ? "mp4" : "webm");
1288
1412
  if (codec !== "webm" && codec !== "mp4") throw new OpsError("invalid", `Unknown codec "${codec}".`, "Use webm or mp4.");
1289
- const def = requested === "poster" ? `dist/poster.${image}` : requested === "video" ? `dist/video.${codec}` : requested === "gif" ? "dist/animation.gif" : "dist/animation.webp";
1413
+ const suffix = preset ? `-${preset}` : "";
1414
+ const def = requested === "poster" ? `dist/poster.${image}` : requested === "video" ? `dist/video${suffix}.${codec}` : requested === "gif" ? `dist/animation${suffix}.gif` : `dist/animation${suffix}.webp`;
1290
1415
  const out = outIn ?? def;
1291
1416
  if (!out.startsWith("dist/") && !out.startsWith("renders/")) throw new OpsError("invalid", `out must be under dist/ or renders/ (got "${out}").`, `Use e.g. "${def}".`);
1292
1417
  const ext = out.split(".").pop()?.toLowerCase();
@@ -1300,6 +1425,7 @@ async function mediaExport(ctx, requested, input) {
1300
1425
  fps: num(input, "fps"),
1301
1426
  size: optStr(input, "size"),
1302
1427
  ...requested === "video" ? { video: codec } : {},
1428
+ ...preset ? { preset } : {},
1303
1429
  ...quality ? { quality } : {},
1304
1430
  ...input.transparent === true ? { transparent: true } : {}
1305
1431
  });
@@ -1315,7 +1441,9 @@ async function mediaExport(ctx, requested, input) {
1315
1441
  frames: r.frames,
1316
1442
  fps: r.fps,
1317
1443
  duration: r.duration
1318
- } : {}
1444
+ } : {},
1445
+ ...preset ? { preset } : {},
1446
+ ...r.notes?.length ? { notes: r.notes } : {}
1319
1447
  };
1320
1448
  }
1321
1449
  var RENDER_TOOL = {
@@ -1447,6 +1575,7 @@ var ORDER = [
1447
1575
  "assets_add",
1448
1576
  "assets_optimize",
1449
1577
  "image_depth",
1578
+ "image_plate",
1450
1579
  "library_list",
1451
1580
  "export"
1452
1581
  ];