@fleox/agent3d 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/changelog.json +15 -0
- package/dist/agent/agent3d.mjs +779 -85
- package/dist/agent/chunks/{assets-YBkgdfgy.mjs → assets-DdzHgVcn.mjs} +2 -2
- package/dist/agent/chunks/{browser-Dil7VM5m.mjs → browser-nFaRUETt.mjs} +1 -1
- package/dist/agent/chunks/{cdp-DLEis_Z3.mjs → cdp-6vF_gP-H.mjs} +1 -1
- package/dist/agent/chunks/{check-DP9fRYbK.mjs → check-E7GdPxTt.mjs} +14 -2
- package/dist/agent/chunks/{depth-CD_ql3QJ.mjs → depth-Bf7cHwod.mjs} +4 -4
- package/dist/agent/chunks/{depth-BZT4gseQ.mjs → depth-DEaogEAi.mjs} +4 -114
- package/dist/agent/chunks/{export-CEX5DFLo.mjs → export-BSOqVfPT.mjs} +8 -4
- package/dist/agent/chunks/{imageCodec-DeGfmBp3.mjs → imageCodec-DXxqkEQA.mjs} +53 -4
- package/dist/agent/chunks/{objects-DuytRxiC.mjs → objects-DvzrcVmK.mjs} +2 -2
- package/dist/agent/chunks/{optimizeSizing-B-BBiUkD.mjs → optimizeSizing-Dd8vaSnE.mjs} +24 -1
- package/dist/agent/chunks/{package-DjRnLzcU.mjs → package-DzXqX5Oe.mjs} +1 -1
- package/dist/agent/chunks/photoPlacement-D-k3mD0T.mjs +138 -0
- package/dist/agent/chunks/plate-Cwl35I2T.mjs +604 -0
- package/dist/agent/chunks/pngEncode-BMc3U9QC.mjs +119 -0
- package/dist/agent/chunks/{render-B05DU4Q5.mjs → render-CCKciCgu.mjs} +76 -11
- package/dist/agent/chunks/{scene-DWgXH6As.mjs → scene-DSjsun-3.mjs} +22 -5
- package/dist/agent/chunks/{server-Dt_YFvN7.mjs → server-CLvLORgA.mjs} +1 -1
- package/dist/agent/chunks/{tools-CZyIc4zw.mjs → tools-Vs74Xopx.mjs} +142 -13
- package/dist/runtime/agent3d-photo.js +51 -10
- package/dist/runtime/agent3d-runtime.js +23 -23
- package/dist/runtime/agent3d-runtime.single.js +405 -134
- package/dist/runtime/chunks/photo-Dq-AKlfw.js +526 -0
- package/dist/studio/assets/BufferGeometryUtils-BbzK4rCj.js +1 -0
- package/dist/studio/assets/{EXRLoader-BKkzlNd8.js → EXRLoader-CuDOo1xG.js} +1 -1
- package/dist/studio/assets/{FontLoader-Bzjx8mXt.js → FontLoader-DlBfss5q.js} +1 -1
- package/dist/studio/assets/{GLTFLoader-1Zd9N406.js → GLTFLoader-bl1eymL4.js} +1 -1
- package/dist/studio/assets/{GroundedSkybox-BEMqNCBD.js → GroundedSkybox-cLn9JVlt.js} +1 -1
- package/dist/studio/assets/{HDRLoader-DxB0kxPH.js → HDRLoader-8EiZoQQP.js} +1 -1
- package/dist/studio/assets/{OrbitControls-MlE9XiCg.js → OrbitControls-1xEm394I.js} +1 -1
- package/dist/studio/assets/{RectAreaLightUniformsLib-ClHrtYY6.js → RectAreaLightUniformsLib-S0AelTmO.js} +1 -1
- package/dist/studio/assets/{RoomEnvironment-MJ-jIEC8.js → RoomEnvironment-v4QurKxu.js} +1 -1
- package/dist/studio/assets/{SVGLoader-CIYl0nEy.js → SVGLoader-KDBVv02P.js} +1 -1
- package/dist/studio/assets/{Sky-DNMfpp92.js → Sky-D8Lp9Zh3.js} +1 -1
- package/dist/studio/assets/assets-DnOt59SU.js +2 -0
- package/dist/studio/assets/camera-DrubOxWu.js +2 -0
- package/dist/studio/assets/catalog-DDg904x2.js +1 -0
- package/dist/studio/assets/{editor-DzyukvQl.js → editor-V--luWVq.js} +1 -1
- package/dist/studio/assets/{extrude-9bG8hr2C.js → extrude-BpJda0hq.js} +1 -1
- package/dist/studio/assets/game-43BhY_EE.js +19 -0
- package/dist/studio/assets/{generators-BuVeRXnC.js → generators-lG93qWTO.js} +1 -1
- package/dist/studio/assets/index-BPVRhKVV.js +479 -0
- package/dist/studio/assets/index-D-TPNQMQ.css +1 -0
- package/dist/studio/assets/model-D8-inS_D.js +2 -0
- package/dist/studio/assets/params-BZqUA__U.js +1 -0
- package/dist/studio/assets/photo-BuVK-UvQ.js +526 -0
- package/dist/studio/assets/{physicsHost-z9qn_mpg.js → physicsHost-EkPuIy04.js} +1 -1
- package/dist/studio/assets/{postfx-B3jDEaEK.js → postfx-Bcnem9ci.js} +2 -2
- package/dist/studio/assets/rolldown-runtime-4tVxZq34.js +1 -0
- package/dist/studio/assets/runtime-5Ti8UJJR.js +572 -0
- package/dist/studio/assets/{shaders-bFhELLmD.js → shaders-WM5brr9C.js} +1 -1
- package/dist/studio/assets/svg-CJ_RtiER.js +2 -0
- package/dist/studio/assets/text-NO7lyCoH.js +3 -0
- package/dist/studio/assets/three.module-B9FlcKtd.js +4225 -0
- package/dist/studio/index.html +5 -3
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +42 -27
- package/plugin/skills/agent3d-create/SKILL.md +77 -29
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +6 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +3 -3
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +30 -23
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/templates/hero-scroll-story/README.md +1 -1
- package/templates/photo-scroll-story/README.md +29 -0
- package/templates/photo-scroll-story/agent3d.json +8 -0
- package/templates/photo-scroll-story/assets/depth/lake-depth.png +0 -0
- package/templates/photo-scroll-story/assets/depth/street-depth.png +0 -0
- package/templates/photo-scroll-story/assets/manifest.json +46 -0
- package/templates/photo-scroll-story/assets/textures/lake.webp +0 -0
- package/templates/photo-scroll-story/assets/textures/street.webp +0 -0
- package/templates/photo-scroll-story/preview.png +0 -0
- package/templates/photo-scroll-story/scene.json +112 -0
- package/templates/photo-scroll-story/template.json +8 -0
- package/templates/photo-title-inside/README.md +31 -0
- package/templates/photo-title-inside/agent3d.json +8 -0
- package/templates/photo-title-inside/assets/depth/street-depth.png +0 -0
- package/templates/photo-title-inside/assets/manifest.json +25 -0
- package/templates/photo-title-inside/assets/textures/street.webp +0 -0
- package/templates/photo-title-inside/preview.png +0 -0
- package/templates/photo-title-inside/scene.json +80 -0
- package/templates/photo-title-inside/template.json +8 -0
- package/dist/runtime/chunks/photo-w6dwHX7j.js +0 -255
- package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +0 -1
- package/dist/studio/assets/assets--ehPZf8R.js +0 -1
- package/dist/studio/assets/camera-C0sxfRxy.js +0 -2
- package/dist/studio/assets/game-DNpTN_Ga.js +0 -19
- package/dist/studio/assets/index-BQT0otii.css +0 -1
- package/dist/studio/assets/index-C2nMYSoW.js +0 -479
- package/dist/studio/assets/model-DQgOrTs4.js +0 -2
- package/dist/studio/assets/params-D-Ul6GSt.js +0 -1
- package/dist/studio/assets/photo-Dx2IBJ11.js +0 -255
- package/dist/studio/assets/runtime-rd9RW3WH.js +0 -572
- package/dist/studio/assets/svg-BkV9LeqP.js +0 -2
- package/dist/studio/assets/text-Dp8gdjSA.js +0 -3
- package/dist/studio/assets/three.module-CnI50X0U.js +0 -4225
package/dist/agent/agent3d.mjs
CHANGED
|
@@ -6,7 +6,7 @@ __a3dRequire(import.meta.url);
|
|
|
6
6
|
const __filename = __a3dPath(import.meta.url);
|
|
7
7
|
__a3dDirname(__filename);
|
|
8
8
|
import { t as __exportAll } from "./chunks/rolldown-runtime-ebOQtxsr.mjs";
|
|
9
|
-
import { r as version, t as package_default } from "./chunks/package-
|
|
9
|
+
import { r as version, t as package_default } from "./chunks/package-DzXqX5Oe.mjs";
|
|
10
10
|
import { n as didYouMean, r as listOptions, t as closest } from "./chunks/suggest-Cpcgv1RP.mjs";
|
|
11
11
|
import { format, parseArgs } from "node:util";
|
|
12
12
|
import { createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
@@ -255,7 +255,7 @@ function slugify(text, fallback = "item") {
|
|
|
255
255
|
}
|
|
256
256
|
// src/core/aspect.ts
|
|
257
257
|
var ASPECT_RE = /^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/;
|
|
258
|
-
function parseAspect(value) {
|
|
258
|
+
function parseAspect$1(value) {
|
|
259
259
|
if (typeof value !== "string") return null;
|
|
260
260
|
const m = ASPECT_RE.exec(value);
|
|
261
261
|
if (!m) return null;
|
|
@@ -269,7 +269,7 @@ function parseAspect(value) {
|
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
function isValidAspect(value) {
|
|
272
|
-
return parseAspect(value) !== null;
|
|
272
|
+
return parseAspect$1(value) !== null;
|
|
273
273
|
}
|
|
274
274
|
// src/core/catalog.ts
|
|
275
275
|
var n = (name, description, def, min, max) => ({
|
|
@@ -3409,7 +3409,7 @@ var CSS_COLOR_NAMES = {
|
|
|
3409
3409
|
yellow: "ffff00",
|
|
3410
3410
|
yellowgreen: "9acd32"
|
|
3411
3411
|
};
|
|
3412
|
-
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3412
|
+
var clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3413
3413
|
function parseHex(hex) {
|
|
3414
3414
|
if (!/^[0-9a-f]+$/i.test(hex)) return null;
|
|
3415
3415
|
if (hex.length === 3 || hex.length === 4) hex = [...hex].map((c) => c + c).join("");
|
|
@@ -3505,22 +3505,22 @@ function parseColor(value) {
|
|
|
3505
3505
|
const [r, g, b] = parts.slice(0, 3).map((p) => component(p, 255));
|
|
3506
3506
|
if (r === null || g === null || b === null) return null;
|
|
3507
3507
|
return {
|
|
3508
|
-
r: clamp(r, 0, 255),
|
|
3509
|
-
g: clamp(g, 0, 255),
|
|
3510
|
-
b: clamp(b, 0, 255),
|
|
3511
|
-
a: clamp(alpha, 0, 1)
|
|
3508
|
+
r: clamp$1(r, 0, 255),
|
|
3509
|
+
g: clamp$1(g, 0, 255),
|
|
3510
|
+
b: clamp$1(b, 0, 255),
|
|
3511
|
+
a: clamp$1(alpha, 0, 1)
|
|
3512
3512
|
};
|
|
3513
3513
|
}
|
|
3514
3514
|
const h = hue(parts[0]);
|
|
3515
3515
|
const sat = component(parts[1], 1);
|
|
3516
3516
|
const light = component(parts[2], 1);
|
|
3517
3517
|
if (h === null || sat === null || light === null || !parts[1].trim().endsWith("%") || !parts[2].trim().endsWith("%")) return null;
|
|
3518
|
-
const [r, g, b] = hslToRgb(h, clamp(sat, 0, 1), clamp(light, 0, 1));
|
|
3518
|
+
const [r, g, b] = hslToRgb(h, clamp$1(sat, 0, 1), clamp$1(light, 0, 1));
|
|
3519
3519
|
return {
|
|
3520
3520
|
r,
|
|
3521
3521
|
g,
|
|
3522
3522
|
b,
|
|
3523
|
-
a: clamp(alpha, 0, 1)
|
|
3523
|
+
a: clamp$1(alpha, 0, 1)
|
|
3524
3524
|
};
|
|
3525
3525
|
}
|
|
3526
3526
|
function isValidColor(value) {
|
|
@@ -3623,6 +3623,108 @@ function libraryId(ref) {
|
|
|
3623
3623
|
function findLibraryAsset(index, id) {
|
|
3624
3624
|
return index?.assets.find((a) => a.id === id);
|
|
3625
3625
|
}
|
|
3626
|
+
// src/core/photoEffects.ts
|
|
3627
|
+
var num$1 = (def, min, max) => ({
|
|
3628
|
+
type: "number",
|
|
3629
|
+
default: def,
|
|
3630
|
+
min,
|
|
3631
|
+
max
|
|
3632
|
+
});
|
|
3633
|
+
var PHOTO_EFFECTS = {
|
|
3634
|
+
fog: {
|
|
3635
|
+
needsDepth: true,
|
|
3636
|
+
params: {
|
|
3637
|
+
color: {
|
|
3638
|
+
type: "color",
|
|
3639
|
+
default: "#ffffff"
|
|
3640
|
+
},
|
|
3641
|
+
amount: num$1(.6, 0, 1),
|
|
3642
|
+
start: num$1(.7, 0, 1),
|
|
3643
|
+
end: num$1(0, 0, 1),
|
|
3644
|
+
drift: num$1(.3, 0)
|
|
3645
|
+
}
|
|
3646
|
+
},
|
|
3647
|
+
light: {
|
|
3648
|
+
needsDepth: false,
|
|
3649
|
+
params: {
|
|
3650
|
+
color: {
|
|
3651
|
+
type: "color",
|
|
3652
|
+
default: "#ffffff"
|
|
3653
|
+
},
|
|
3654
|
+
intensity: num$1(1, 0),
|
|
3655
|
+
ambient: num$1(.75, 0, 1),
|
|
3656
|
+
position: {
|
|
3657
|
+
type: "vec2",
|
|
3658
|
+
default: [.4, .4],
|
|
3659
|
+
min: -1,
|
|
3660
|
+
max: 1
|
|
3661
|
+
},
|
|
3662
|
+
height: num$1(.6, 0),
|
|
3663
|
+
radius: num$1(.8, 0),
|
|
3664
|
+
relief: num$1(1, 0),
|
|
3665
|
+
specular: num$1(.25, 0, 1),
|
|
3666
|
+
follow: {
|
|
3667
|
+
type: "enum",
|
|
3668
|
+
default: "pointer",
|
|
3669
|
+
options: [
|
|
3670
|
+
"pointer",
|
|
3671
|
+
"auto",
|
|
3672
|
+
"none"
|
|
3673
|
+
],
|
|
3674
|
+
animatable: false
|
|
3675
|
+
}
|
|
3676
|
+
}
|
|
3677
|
+
},
|
|
3678
|
+
reveal: {
|
|
3679
|
+
needsDepth: true,
|
|
3680
|
+
alpha: true,
|
|
3681
|
+
params: {
|
|
3682
|
+
progress: num$1(1, 0, 1),
|
|
3683
|
+
from: {
|
|
3684
|
+
type: "enum",
|
|
3685
|
+
default: "far",
|
|
3686
|
+
options: ["near", "far"],
|
|
3687
|
+
animatable: false
|
|
3688
|
+
},
|
|
3689
|
+
softness: num$1(.15, 0, 1),
|
|
3690
|
+
duration: num$1(void 0, 0),
|
|
3691
|
+
delay: num$1(0, 0)
|
|
3692
|
+
}
|
|
3693
|
+
},
|
|
3694
|
+
blur: {
|
|
3695
|
+
needsDepth: false,
|
|
3696
|
+
params: {
|
|
3697
|
+
focus: num$1(void 0, 0, 1),
|
|
3698
|
+
amount: num$1(.6, 0, 5),
|
|
3699
|
+
range: num$1(.1, 0, 1),
|
|
3700
|
+
to: num$1(void 0, 0, 1),
|
|
3701
|
+
duration: num$1(void 0, 0),
|
|
3702
|
+
delay: num$1(0, 0)
|
|
3703
|
+
}
|
|
3704
|
+
},
|
|
3705
|
+
frame: {
|
|
3706
|
+
needsDepth: false,
|
|
3707
|
+
alpha: true,
|
|
3708
|
+
params: {
|
|
3709
|
+
inset: {
|
|
3710
|
+
type: "vec2",
|
|
3711
|
+
default: [.12, .12],
|
|
3712
|
+
min: 0,
|
|
3713
|
+
max: .45,
|
|
3714
|
+
scalar: true
|
|
3715
|
+
},
|
|
3716
|
+
threshold: num$1(.6, 0, 1),
|
|
3717
|
+
softness: num$1(.04, 0, 1),
|
|
3718
|
+
border: num$1(.015, 0, .2),
|
|
3719
|
+
color: {
|
|
3720
|
+
type: "color",
|
|
3721
|
+
default: "#ffffff"
|
|
3722
|
+
},
|
|
3723
|
+
shadow: num$1(.35, 0, 1)
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
};
|
|
3727
|
+
var PHOTO_EFFECT_IDS = Object.keys(PHOTO_EFFECTS);
|
|
3626
3728
|
// src/core/qualityTier.ts
|
|
3627
3729
|
/** Upper bound of the device pixel ratio per tier (combined with target.maxDpr). */
|
|
3628
3730
|
var TIER_DPR_CAP = {
|
|
@@ -4116,8 +4218,52 @@ function singleKind(head, prop, ids, target) {
|
|
|
4116
4218
|
hint: "Use \"morph.<name>\" (0..1) or \"animation.<clip>.weight\" | \".speed\" | \".time\"."
|
|
4117
4219
|
} };
|
|
4118
4220
|
}
|
|
4221
|
+
if (parts[0] === "effects") return photoEffectKind(base, parts.slice(1), ids);
|
|
4222
|
+
if (parts[0] === "motion") {
|
|
4223
|
+
if (ids.photos && !ids.photos.has(base)) return { error: {
|
|
4224
|
+
message: `"${prop}" needs a photo object; "${base}" is not one.`,
|
|
4225
|
+
hint: "motion.progress (0..1) drives the auto move of a 3D photo (kind \"photo\")."
|
|
4226
|
+
} };
|
|
4227
|
+
if (prop === "motion.progress") return { kind: "number" };
|
|
4228
|
+
return { error: {
|
|
4229
|
+
message: `Photo motion property "${prop}" is not animatable.`,
|
|
4230
|
+
hint: `${didYouMean(prop, ["motion.progress"])}Use "motion.progress" (0..1 along the photo's motion.auto move).`
|
|
4231
|
+
} };
|
|
4232
|
+
}
|
|
4119
4233
|
return objectKind(prop, false);
|
|
4120
4234
|
}
|
|
4235
|
+
function photoEffectKind(id, parts, ids) {
|
|
4236
|
+
const declared = ids.photoEffects?.get(id);
|
|
4237
|
+
if (ids.photoEffects && !declared) return { error: {
|
|
4238
|
+
message: `"${id}" is not a 3D photo: effects.* tracks animate photo effects.`,
|
|
4239
|
+
hint: "Use \"<photoId>.effects.<effect>.<param>\" on a kind \"photo\" object."
|
|
4240
|
+
} };
|
|
4241
|
+
const [effect, param, axis, ...more] = parts;
|
|
4242
|
+
const spec = PHOTO_EFFECTS[effect];
|
|
4243
|
+
if (!spec) return { error: {
|
|
4244
|
+
message: `Unknown photo effect "${effect ?? ""}".`,
|
|
4245
|
+
hint: `${didYouMean(effect ?? "", PHOTO_EFFECT_IDS)}Effects: ${listOptions(PHOTO_EFFECT_IDS)}.`
|
|
4246
|
+
} };
|
|
4247
|
+
if (declared && !declared.has(effect)) return { error: {
|
|
4248
|
+
message: `"${id}" has no ${effect} effect, so this track animates nothing.`,
|
|
4249
|
+
hint: `Add "effects": { "${effect}": {} } to the photo "${id}" first.`
|
|
4250
|
+
} };
|
|
4251
|
+
const params = spec.params;
|
|
4252
|
+
const animatable = Object.keys(params).filter((k) => params[k].animatable !== false);
|
|
4253
|
+
const p = param ? params[param] : void 0;
|
|
4254
|
+
if (!p || p.animatable === false || more.length) return { error: {
|
|
4255
|
+
message: `Photo effect property "${effect}.${param ?? ""}" is not animatable.`,
|
|
4256
|
+
hint: `${didYouMean(param ?? "", animatable)}Animatable ${effect} params: ${listOptions(animatable)}.`
|
|
4257
|
+
} };
|
|
4258
|
+
if (axis !== void 0) {
|
|
4259
|
+
if (p.type === "vec2" && (axis === "x" || axis === "y")) return { kind: "number" };
|
|
4260
|
+
return { error: {
|
|
4261
|
+
message: `"${effect}.${param}.${axis}" is not animatable.`,
|
|
4262
|
+
hint: p.type === "vec2" ? "Use \".x\" or \".y\"." : `Animate "${effect}.${param}" itself.`
|
|
4263
|
+
} };
|
|
4264
|
+
}
|
|
4265
|
+
return { kind: p.type === "vec2" ? "vec2" : p.type === "color" ? "color" : "number" };
|
|
4266
|
+
}
|
|
4121
4267
|
function objectKind(prop, multi) {
|
|
4122
4268
|
const parts = prop.split(".");
|
|
4123
4269
|
if (VEC3_PROPS.includes(parts[0])) {
|
|
@@ -4129,7 +4275,7 @@ function objectKind(prop, multi) {
|
|
|
4129
4275
|
if (parts.length === 2 && MATERIAL_TRACK_PROPS[parts[1]]) return { kind: MATERIAL_TRACK_PROPS[parts[1]] };
|
|
4130
4276
|
if (parts.length === 3 && parts[1] === "uniforms") return { kind: "number" };
|
|
4131
4277
|
}
|
|
4132
|
-
if (multi && (parts[0] === "morph" || parts[0] === "animation")) return { kind: "number" };
|
|
4278
|
+
if (multi && (parts[0] === "morph" || parts[0] === "animation" || prop === "motion.progress")) return { kind: "number" };
|
|
4133
4279
|
const options = [
|
|
4134
4280
|
"position",
|
|
4135
4281
|
"position.x",
|
|
@@ -4140,7 +4286,8 @@ function objectKind(prop, multi) {
|
|
|
4140
4286
|
...Object.keys(MATERIAL_TRACK_PROPS).map((k) => `material.${k}`),
|
|
4141
4287
|
"material.uniforms.<name>",
|
|
4142
4288
|
"morph.<name>",
|
|
4143
|
-
"animation.<clip>.weight"
|
|
4289
|
+
"animation.<clip>.weight",
|
|
4290
|
+
"motion.progress"
|
|
4144
4291
|
];
|
|
4145
4292
|
return { error: {
|
|
4146
4293
|
message: `Property "${prop}" is not animatable.`,
|
|
@@ -4152,6 +4299,7 @@ function keyValueOk(kind, value) {
|
|
|
4152
4299
|
const vec = (x) => Array.isArray(x) && x.length === 3 && x.every(num);
|
|
4153
4300
|
switch (kind) {
|
|
4154
4301
|
case "vec3": return vec(value) || isRel(value);
|
|
4302
|
+
case "vec2": return Array.isArray(value) && value.length === 2 && value.every(num);
|
|
4155
4303
|
case "number": return num(value);
|
|
4156
4304
|
case "color": return isValidColor(value);
|
|
4157
4305
|
case "boolean": return typeof value === "boolean";
|
|
@@ -4160,6 +4308,7 @@ function keyValueOk(kind, value) {
|
|
|
4160
4308
|
}
|
|
4161
4309
|
var KIND_EXAMPLE = {
|
|
4162
4310
|
vec3: "[0, 1, 0] or [\"+=0\", \"+=1\", \"+=0\"]",
|
|
4311
|
+
vec2: "[0.4, -0.2]",
|
|
4163
4312
|
number: "1.5 or \"+=1\"",
|
|
4164
4313
|
color: "\"#ff8800\"",
|
|
4165
4314
|
boolean: "true",
|
|
@@ -4218,7 +4367,8 @@ var C = class {
|
|
|
4218
4367
|
}
|
|
4219
4368
|
};
|
|
4220
4369
|
function collect(scene, ids) {
|
|
4221
|
-
const tags = /* @__PURE__ */ new Set(), models = /* @__PURE__ */ new Set(), parents = /* @__PURE__ */ new Set();
|
|
4370
|
+
const tags = /* @__PURE__ */ new Set(), models = /* @__PURE__ */ new Set(), parents = /* @__PURE__ */ new Set(), photos = /* @__PURE__ */ new Set();
|
|
4371
|
+
const photoEffects = /* @__PURE__ */ new Map();
|
|
4222
4372
|
const walk = (list) => {
|
|
4223
4373
|
if (!Array.isArray(list)) return;
|
|
4224
4374
|
for (const o of list) {
|
|
@@ -4227,6 +4377,8 @@ function collect(scene, ids) {
|
|
|
4227
4377
|
for (const t of o.tags) if (typeof t === "string") tags.add(t);
|
|
4228
4378
|
}
|
|
4229
4379
|
if (o.kind === "model") models.add(o.id);
|
|
4380
|
+
if (o.kind === "photo") photoEffects.set(o.id, new Set(isObj$1(o.effects) ? Object.keys(o.effects) : []));
|
|
4381
|
+
if (o.kind === "photo") photos.add(o.id);
|
|
4230
4382
|
if (Array.isArray(o.children) && o.children.length || o.kind === "text" && (o.splitLetters === true || isObj$1(o.reveal))) parents.add(o.id);
|
|
4231
4383
|
walk(o.children);
|
|
4232
4384
|
}
|
|
@@ -4238,8 +4390,10 @@ function collect(scene, ids) {
|
|
|
4238
4390
|
...ids,
|
|
4239
4391
|
tags,
|
|
4240
4392
|
models,
|
|
4393
|
+
photos,
|
|
4241
4394
|
parents,
|
|
4242
|
-
postfx
|
|
4395
|
+
postfx,
|
|
4396
|
+
photoEffects
|
|
4243
4397
|
};
|
|
4244
4398
|
}
|
|
4245
4399
|
var TIMELINE_TRIGGERS_ALL = [
|
|
@@ -4742,7 +4896,11 @@ var PHOTO_AUTO_MOTIONS = [
|
|
|
4742
4896
|
"none",
|
|
4743
4897
|
"sway",
|
|
4744
4898
|
"orbit",
|
|
4745
|
-
"zoom"
|
|
4899
|
+
"zoom",
|
|
4900
|
+
"dolly",
|
|
4901
|
+
"pan",
|
|
4902
|
+
"rise",
|
|
4903
|
+
"vertigo"
|
|
4746
4904
|
];
|
|
4747
4905
|
var PHOTO_MOTION_KEYS = [
|
|
4748
4906
|
"pointer",
|
|
@@ -4750,7 +4908,10 @@ var PHOTO_MOTION_KEYS = [
|
|
|
4750
4908
|
"gyro",
|
|
4751
4909
|
"auto",
|
|
4752
4910
|
"speed",
|
|
4753
|
-
"smoothing"
|
|
4911
|
+
"smoothing",
|
|
4912
|
+
"loop",
|
|
4913
|
+
"duration",
|
|
4914
|
+
"progress"
|
|
4754
4915
|
];
|
|
4755
4916
|
var PHOTO_MATERIAL_KEYS = [
|
|
4756
4917
|
"opacity",
|
|
@@ -4831,6 +4992,8 @@ var OBJECT_KEYS = {
|
|
|
4831
4992
|
photo: [
|
|
4832
4993
|
"src",
|
|
4833
4994
|
"depth",
|
|
4995
|
+
"plate",
|
|
4996
|
+
"plateDepth",
|
|
4834
4997
|
"mode",
|
|
4835
4998
|
"width",
|
|
4836
4999
|
"height",
|
|
@@ -4839,8 +5002,10 @@ var OBJECT_KEYS = {
|
|
|
4839
5002
|
"segments",
|
|
4840
5003
|
"layers",
|
|
4841
5004
|
"edgeCut",
|
|
5005
|
+
"occlude",
|
|
4842
5006
|
"motion",
|
|
4843
|
-
"material"
|
|
5007
|
+
"material",
|
|
5008
|
+
"effects"
|
|
4844
5009
|
]
|
|
4845
5010
|
};
|
|
4846
5011
|
var SCENE_KEYS = [
|
|
@@ -6218,6 +6383,13 @@ function object(v, o, fallback) {
|
|
|
6218
6383
|
function photo(v, o, p) {
|
|
6219
6384
|
if (v.required(o, "src", p, "an image path (\"assets/textures/photo.jpg\") or \"library:<id>\" (.jpg / .png / .webp)")) v.assetPath(o.src, `${p}.src`, PHOTO_EXT, "an image (.jpg / .png / .webp)");
|
|
6220
6385
|
v.assetPath(o.depth, `${p}.depth`, PHOTO_EXT, "a depth map image (grayscale PNG, white = near)");
|
|
6386
|
+
v.assetPath(o.plate, `${p}.plate`, PHOTO_EXT, "a background plate image (.webp / .png / .jpg)");
|
|
6387
|
+
v.assetPath(o.plateDepth, `${p}.plateDepth`, PHOTO_EXT, "the plate depth map (grayscale PNG, white = near)");
|
|
6388
|
+
if (o.plate === void 0 !== (o.plateDepth === void 0)) {
|
|
6389
|
+
const has = o.plate !== void 0 ? "plate" : "plateDepth";
|
|
6390
|
+
const miss = has === "plate" ? "plateDepth" : "plate";
|
|
6391
|
+
v.warn("photo-plate", `${p}.${miss}`, `Photo "${String(o.id)}" has ${has} but no ${miss}: the plate is ignored (it needs both).`, `Set both from \`agent3d assets plate ${typeof o.src === "string" ? o.src : "<image>"}\` (it returns { plate, plateDepth }).`);
|
|
6392
|
+
} else if (o.plate !== void 0 && o.depth === void 0) v.info("ignored", `${p}.plate`, `plate only applies to a photo with a depth map (this one is flat).`, "Set depth too, or remove plate / plateDepth.");
|
|
6221
6393
|
v.enumOf(o.mode, PHOTO_MODES, `${p}.mode`);
|
|
6222
6394
|
v.number(o.width, `${p}.width`, {
|
|
6223
6395
|
min: 0,
|
|
@@ -6246,6 +6418,8 @@ function photo(v, o, p) {
|
|
|
6246
6418
|
max: 16
|
|
6247
6419
|
});
|
|
6248
6420
|
const mode = typeof o.mode === "string" ? o.mode : "parallax";
|
|
6421
|
+
v.boolean(o.occlude, `${p}.occlude`);
|
|
6422
|
+
if (o.occlude === true && o.depth === void 0) v.info("ignored", `${p}.occlude`, `occlude needs a depth map: photo "${String(o.id)}" is flat (it already hides what is behind its plane).`, `Set ${p}.depth (\`agent3d assets depth ${String(o.src ?? "<image>")}\`), or remove occlude.`);
|
|
6249
6423
|
if (o.segments !== void 0 && mode !== "mesh") v.info("ignored", `${p}.segments`, `segments only applies to mode "mesh" (this photo is "${mode}").`, "Set mode: \"mesh\", or remove segments.");
|
|
6250
6424
|
if (o.layers !== void 0 && mode !== "layers") v.info("ignored", `${p}.layers`, `layers only applies to mode "layers" (this photo is "${mode}").`, "Set mode: \"layers\", or remove layers.");
|
|
6251
6425
|
if (o.depth === void 0 && typeof o.src === "string" && PHOTO_MODES.includes(mode)) v.warn("photo-flat", p, `Photo "${String(o.id)}" has no depth map: it renders flat (mode "${mode}" needs one).`, `Run \`agent3d assets depth ${o.src}\` (writes a depth PNG next to it), then set ${p}.depth to its path.`);
|
|
@@ -6269,8 +6443,20 @@ function photo(v, o, p) {
|
|
|
6269
6443
|
min: 0,
|
|
6270
6444
|
max: 1
|
|
6271
6445
|
});
|
|
6446
|
+
v.boolean(m.loop, `${p}.motion.loop`);
|
|
6447
|
+
v.number(m.duration, `${p}.motion.duration`, {
|
|
6448
|
+
min: .1,
|
|
6449
|
+
max: 600
|
|
6450
|
+
});
|
|
6451
|
+
v.number(m.progress, `${p}.motion.progress`, {
|
|
6452
|
+
min: 0,
|
|
6453
|
+
max: 1
|
|
6454
|
+
});
|
|
6455
|
+
if (m.duration !== void 0 && m.loop !== false) v.info("ignored", `${p}.motion.duration`, "motion.duration only applies to one-way moves (loop: false); a loop lasts 10 / speed seconds.", "Set \"loop\": false for a one-way move, or change speed (cycles per 10 s).");
|
|
6456
|
+
if (m.auto === "none" && (m.loop !== void 0 || m.duration !== void 0 || m.progress !== void 0)) v.info("ignored", `${p}.motion`, "loop / duration / progress shape the auto move, but this photo has auto \"none\".", "Set \"auto\" to a move: \"dolly\", \"pan\", \"rise\", \"vertigo\", \"zoom\", \"sway\" or \"orbit\".");
|
|
6272
6457
|
}
|
|
6273
6458
|
}
|
|
6459
|
+
if (o.effects !== void 0) photoEffects(v, o.effects, `${p}.effects`, o.depth !== void 0);
|
|
6274
6460
|
if (o.material !== void 0) {
|
|
6275
6461
|
const m = o.material;
|
|
6276
6462
|
if (!isObj(m)) v.error("type", `${p}.material`, "material must be an object.", "A photo material only takes { \"opacity\", \"color\", \"emissiveIntensity\" }, e.g. { \"opacity\": 0.9 }.");
|
|
@@ -6289,6 +6475,50 @@ function photo(v, o, p) {
|
|
|
6289
6475
|
}
|
|
6290
6476
|
}
|
|
6291
6477
|
}
|
|
6478
|
+
var EFFECT_EXAMPLE = "{ \"fog\": { \"color\": \"#dfe8f2\", \"amount\": 0.6 }, \"light\": { \"follow\": \"pointer\" }, \"reveal\": { \"duration\": 2 } }";
|
|
6479
|
+
function photoEffects(v, fx, p, hasDepth) {
|
|
6480
|
+
if (!isObj(fx)) return v.error("type", p, "effects must be an object.", `Example: ${EFFECT_EXAMPLE}.`);
|
|
6481
|
+
v.unknownKeys(fx, PHOTO_EFFECT_IDS, p, "photo effects");
|
|
6482
|
+
for (const id of PHOTO_EFFECT_IDS) {
|
|
6483
|
+
const e = fx[id];
|
|
6484
|
+
if (e === void 0) continue;
|
|
6485
|
+
const ep = `${p}.${id}`;
|
|
6486
|
+
if (!isObj(e)) {
|
|
6487
|
+
v.error("type", ep, `effects.${id} must be an object (use {} for the defaults).`, `Example: ${EFFECT_EXAMPLE}.`);
|
|
6488
|
+
continue;
|
|
6489
|
+
}
|
|
6490
|
+
const spec = PHOTO_EFFECTS[id];
|
|
6491
|
+
const params = spec.params;
|
|
6492
|
+
v.unknownKeys(e, Object.keys(params), ep, `the ${id} effect`);
|
|
6493
|
+
for (const [k, ps] of Object.entries(params)) {
|
|
6494
|
+
const val = e[k];
|
|
6495
|
+
if (val === void 0) continue;
|
|
6496
|
+
const at = `${ep}.${k}`;
|
|
6497
|
+
const sp = ps;
|
|
6498
|
+
if (sp.type === "number") v.number(val, at, {
|
|
6499
|
+
min: sp.min,
|
|
6500
|
+
max: sp.max
|
|
6501
|
+
});
|
|
6502
|
+
else if (sp.type === "color") v.color(val, at);
|
|
6503
|
+
else if (sp.type === "enum") v.enumOf(val, sp.options ?? [], at);
|
|
6504
|
+
else if (sp.type === "vec2" && sp.scalar && typeof val === "number") v.number(val, at, {
|
|
6505
|
+
min: sp.min,
|
|
6506
|
+
max: sp.max
|
|
6507
|
+
});
|
|
6508
|
+
else if (sp.type === "vec2" && v.vec(val, 2, at)) {
|
|
6509
|
+
if (val.some((x) => x < (sp.min ?? -Infinity) || x > (sp.max ?? Infinity))) v.error("range", at, `${JSON.stringify(val)} is out of range (each coordinate in ${sp.min}..${sp.max}${sp.min === -1 ? ", photo space: -1 left / bottom, 1 right / top" : ""}).`);
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
if (spec.needsDepth && !hasDepth) v.info("ignored", ep, `The ${id} effect needs a depth map: this photo has none, so it is ignored.`, `Set the photo's depth (agent3d assets depth <image>), or remove effects.${id}.`);
|
|
6513
|
+
}
|
|
6514
|
+
const r = fx.reveal;
|
|
6515
|
+
if (isObj(r) && r.duration !== void 0 && r.progress !== void 0) v.info("ignored", `${p}.reveal.progress`, "reveal.progress is ignored when reveal.duration is set (progress animates 0 → 1 from delay).", "Remove duration to drive progress yourself (e.g. a timeline track on effects.reveal.progress).");
|
|
6516
|
+
const b = fx.blur;
|
|
6517
|
+
if (isObj(b) && b.to === void 0 !== (b.duration === void 0)) v.info("ignored", `${p}.blur.${b.to === void 0 ? "duration" : "to"}`, "The blur racks focus only with both `to` and `duration`: this one is ignored.", "Set both (e.g. { \"focus\": 0.9, \"to\": 0.1, \"duration\": 3 }) or drive effects.blur.focus from a timeline track.");
|
|
6518
|
+
if (isObj(b) && !hasDepth) v.info("flat", `${p}.blur`, "On a photo without a depth map the blur is even over the whole image (its depth is 0.5).", "Set the photo's depth (agent3d assets depth <image>) for a depth-of-field blur.");
|
|
6519
|
+
const f = fx.frame;
|
|
6520
|
+
if (isObj(f) && !hasDepth) v.info("flat", `${p}.frame`, "On a photo without a depth map nothing pops out of the frame (its depth is 0.5): the photo is just framed.", "Set the photo's depth (agent3d assets depth <image>) for the out-of-frame pop-out.");
|
|
6521
|
+
}
|
|
6292
6522
|
function catalogRef(v, section, id, path) {
|
|
6293
6523
|
const ids = CATALOG[section].map((x) => x.id);
|
|
6294
6524
|
if (typeof id !== "string") {
|
|
@@ -8275,8 +8505,8 @@ var DIR_BY_KIND = {
|
|
|
8275
8505
|
};
|
|
8276
8506
|
var assetsCommand = {
|
|
8277
8507
|
name: "assets",
|
|
8278
|
-
usage: "assets <list|search|add|optimize|depth|remove|library> [--project <dir>]",
|
|
8279
|
-
summary: "Project assets (assets/ + manifest with licences): list, search free CC0 sources (Poly Haven, ambientCG, Kenney, Quaternius, Khronos), add (local file or a search hit — downloaded once into the project), optimize (smart-size + WebP textures, meshopt .glb geometry), depth (estimate a depth map for a 3D photo), remove, and browse the built-in library.",
|
|
8508
|
+
usage: "assets <list|search|add|optimize|depth|plate|remove|library> [--project <dir>]",
|
|
8509
|
+
summary: "Project assets (assets/ + manifest with licences): list, search free CC0 sources (Poly Haven, ambientCG, Kenney, Quaternius, Khronos), add (local file or a search hit — downloaded once into the project), optimize (smart-size + WebP textures, meshopt .glb geometry), depth (estimate a depth map for a 3D photo), plate (its background plate, for bigger moves), remove, and browse the built-in library.",
|
|
8280
8510
|
subcommands: [
|
|
8281
8511
|
{
|
|
8282
8512
|
name: "list",
|
|
@@ -8303,8 +8533,14 @@ var assetsCommand = {
|
|
|
8303
8533
|
},
|
|
8304
8534
|
{
|
|
8305
8535
|
name: "depth",
|
|
8306
|
-
usage: "assets depth <image> [--out assets/depth/<name>-depth.png] [--size 518] [--max-size 1024]",
|
|
8307
|
-
summary: "Estimate a depth map for a photo of the project (or \"library:<id>\") with Depth Anything V2 Small, run locally in headless Chrome (onnxruntime-web, WASM). Writes a grey PNG (white = near, transparent on depth jumps) at the photo size (capped by --max-size, default 1024) to use as a photo object's `depth`, registered in assets/manifest.json with the photo's licence. The model (27 MB, Apache-2.0) is downloaded once into ~/.agent3d/models (AGENT3D_MODELS overrides); later runs work offline. --size is the model input long side (default 518, up to 1036 for finer edges, slower).",
|
|
8536
|
+
usage: "assets depth <image> [--out assets/depth/<name>-depth.png] [--size 518] [--max-size 1024] [--plate]",
|
|
8537
|
+
summary: "Estimate a depth map for a photo of the project (or \"library:<id>\") with Depth Anything V2 Small, run locally in headless Chrome (onnxruntime-web, WASM). Writes a grey PNG (white = near, transparent on depth jumps) at the photo size (capped by --max-size, default 1024) to use as a photo object's `depth`, registered in assets/manifest.json with the photo's licence. The model (27 MB, Apache-2.0) is downloaded once into ~/.agent3d/models (AGENT3D_MODELS overrides); later runs work offline. --size is the model input long side (default 518, up to 1036 for finer edges, slower). --plate also builds the background plate (see `assets plate`).",
|
|
8538
|
+
writes: true
|
|
8539
|
+
},
|
|
8540
|
+
{
|
|
8541
|
+
name: "plate",
|
|
8542
|
+
usage: "assets plate <image> [--depth <png>] [--strength 1] [--width <px>] [--max-size 1024] [--format webp|png] [--out <path>] [--out-depth <path>]",
|
|
8543
|
+
summary: "Build the background plate of a 3D photo: the photo with the foreground removed next to its depth edges, filled with the background from the far side only, + the plate depth (the background depth continued). Set them on the photo object as `plate` and `plateDepth`: the runtime shows the plate where moving foreground uncovers the background (parallax, mesh backing, layers) instead of smears and stretched edges. Needs the depth map (--depth, else the photo object's depth, else assets/depth/<name>-depth.png). Writes assets/depth/<name>-plate.webp + <name>-plate-depth.png (photo's licence). --strength (default 1) or --width (removed band in px for a full depth jump) size the hole. Headless Chrome decodes the photo; the fill itself is pure TS (about 0.5 s).",
|
|
8308
8544
|
writes: true
|
|
8309
8545
|
},
|
|
8310
8546
|
{
|
|
@@ -8376,7 +8612,7 @@ var assetsCommand = {
|
|
|
8376
8612
|
{
|
|
8377
8613
|
name: "max-size",
|
|
8378
8614
|
type: "string",
|
|
8379
|
-
description: "optimize / add --hit: longest texture side in pixels, for every texture (optimize default: a smart size per texture from the scene; never upscales). depth: longest side of the depth map (default 1024)."
|
|
8615
|
+
description: "optimize / add --hit: longest texture side in pixels, for every texture (optimize default: a smart size per texture from the scene; never upscales). depth: longest side of the depth map (default 1024). plate: longest side of the plate (default 1024)."
|
|
8380
8616
|
},
|
|
8381
8617
|
{
|
|
8382
8618
|
name: "quality",
|
|
@@ -8386,7 +8622,7 @@ var assetsCommand = {
|
|
|
8386
8622
|
{
|
|
8387
8623
|
name: "format",
|
|
8388
8624
|
type: "string",
|
|
8389
|
-
description: "optimize: texture output format — auto (default, WebP), webp, jpeg (images with alpha keep their format), png or keep."
|
|
8625
|
+
description: "optimize: texture output format — auto (default, WebP), webp, jpeg (images with alpha keep their format), png or keep. plate: webp (default) or png."
|
|
8390
8626
|
},
|
|
8391
8627
|
{
|
|
8392
8628
|
name: "compress",
|
|
@@ -8411,7 +8647,32 @@ var assetsCommand = {
|
|
|
8411
8647
|
{
|
|
8412
8648
|
name: "out",
|
|
8413
8649
|
type: "string",
|
|
8414
|
-
description: "depth: project path of the depth PNG (default assets/depth/<image name>-depth.png)."
|
|
8650
|
+
description: "depth: project path of the depth PNG (default assets/depth/<image name>-depth.png). plate: project path of the plate (default assets/depth/<image name>-plate.webp)."
|
|
8651
|
+
},
|
|
8652
|
+
{
|
|
8653
|
+
name: "out-depth",
|
|
8654
|
+
type: "string",
|
|
8655
|
+
description: "plate: project path of the plate depth PNG (default assets/depth/<image name>-plate-depth.png)."
|
|
8656
|
+
},
|
|
8657
|
+
{
|
|
8658
|
+
name: "plate",
|
|
8659
|
+
type: "boolean",
|
|
8660
|
+
description: "depth: also build the background plate (assets plate) from the new depth map."
|
|
8661
|
+
},
|
|
8662
|
+
{
|
|
8663
|
+
name: "depth",
|
|
8664
|
+
type: "string",
|
|
8665
|
+
description: "plate: the photo's depth map PNG (default: the photo object's depth, else assets/depth/<image name>-depth.png)."
|
|
8666
|
+
},
|
|
8667
|
+
{
|
|
8668
|
+
name: "strength",
|
|
8669
|
+
type: "string",
|
|
8670
|
+
description: "plate: strongest photo strength to cover, 0-1 (default 1): how far from each edge the foreground is removed."
|
|
8671
|
+
},
|
|
8672
|
+
{
|
|
8673
|
+
name: "width",
|
|
8674
|
+
type: "string",
|
|
8675
|
+
description: "plate: removed band in plate pixels for a full near-to-far depth jump (overrides --strength)."
|
|
8415
8676
|
},
|
|
8416
8677
|
{
|
|
8417
8678
|
name: "size",
|
|
@@ -8443,7 +8704,7 @@ var assetsCommand = {
|
|
|
8443
8704
|
async run({ io, options, positionals }) {
|
|
8444
8705
|
const [action = "list", ...rest] = positionals;
|
|
8445
8706
|
if (action === "library") {
|
|
8446
|
-
const { listLibrary } = await import("./chunks/assets-
|
|
8707
|
+
const { listLibrary } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.n);
|
|
8447
8708
|
const r = listLibrary(readLibraryIndex(), {
|
|
8448
8709
|
query: strOpt(options, "query") ?? rest[0],
|
|
8449
8710
|
kind: strOpt(options, "kind"),
|
|
@@ -8466,7 +8727,7 @@ var assetsCommand = {
|
|
|
8466
8727
|
if (action === "search") {
|
|
8467
8728
|
const query = strOpt(options, "query") ?? rest.join(" ");
|
|
8468
8729
|
if (!query.trim()) usage("assets search needs a query.", "e.g. agent3d assets search \"pine tree\" --kind model");
|
|
8469
|
-
const { searchAssetsDetailed } = await import("./chunks/assets-
|
|
8730
|
+
const { searchAssetsDetailed } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.n);
|
|
8470
8731
|
const r = await searchAssetsDetailed({
|
|
8471
8732
|
query,
|
|
8472
8733
|
kind: strOpt(options, "kind"),
|
|
@@ -8485,7 +8746,7 @@ var assetsCommand = {
|
|
|
8485
8746
|
}
|
|
8486
8747
|
const fs = projectFs(options);
|
|
8487
8748
|
if (action === "list") {
|
|
8488
|
-
const { listAssets } = await import("./chunks/assets-
|
|
8749
|
+
const { listAssets } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.n);
|
|
8489
8750
|
const r = await listAssets(fs);
|
|
8490
8751
|
return printResult(io, r, () => `${table(r.assets, [
|
|
8491
8752
|
"path",
|
|
@@ -8497,7 +8758,7 @@ var assetsCommand = {
|
|
|
8497
8758
|
}
|
|
8498
8759
|
if (action === "add") {
|
|
8499
8760
|
const hit = jsonObjectOpt(options, "hit");
|
|
8500
|
-
const ops = await import("./chunks/assets-
|
|
8761
|
+
const ops = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.n);
|
|
8501
8762
|
if (hit) {
|
|
8502
8763
|
const resolution = strOpt(options, "resolution");
|
|
8503
8764
|
const maxSize = numOpt(options, "max-size") ?? ops.parseResolution(resolution).maxSize;
|
|
@@ -8509,8 +8770,8 @@ var assetsCommand = {
|
|
|
8509
8770
|
inflate: (d) => new Uint8Array(inflateRawSync(d))
|
|
8510
8771
|
});
|
|
8511
8772
|
let entry;
|
|
8512
|
-
if (maxSize && (await import("./chunks/browser-
|
|
8513
|
-
const { withImageCodec } = await import("./chunks/imageCodec-
|
|
8773
|
+
if (maxSize && (await import("./chunks/browser-nFaRUETt.mjs")).findBrowser()) {
|
|
8774
|
+
const { withImageCodec } = await import("./chunks/imageCodec-DXxqkEQA.mjs");
|
|
8514
8775
|
entry = await withImageCodec((codec) => dl(codec), { log: log$1 });
|
|
8515
8776
|
} else entry = await dl();
|
|
8516
8777
|
return printResult(io, { asset: entry }, () => [
|
|
@@ -8567,7 +8828,7 @@ var assetsCommand = {
|
|
|
8567
8828
|
} }, () => `Added ${entry.path}.${bounds ? ` Bounds ${bounds.size.join(" × ")} (w × h × d), up axis ${bounds.upAxis}.` : ""}`);
|
|
8568
8829
|
}
|
|
8569
8830
|
if (action === "optimize") {
|
|
8570
|
-
const { optimizeAssets, planOptimize } = await import("./chunks/assets-
|
|
8831
|
+
const { optimizeAssets, planOptimize } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.d);
|
|
8571
8832
|
const all = boolOpt(options, "all");
|
|
8572
8833
|
if (!rest.length && !all) usage("assets optimize needs paths or --all.", "e.g. agent3d assets optimize --all (plan), then --yes; or a folder: agent3d assets optimize assets/textures/wood --yes (`agent3d assets list` shows sizes).");
|
|
8573
8834
|
const compressRaw = strOpt(options, "compress") ?? "meshopt";
|
|
@@ -8613,7 +8874,7 @@ var assetsCommand = {
|
|
|
8613
8874
|
hint: "--dry-run reports the real savings without writing; --max-size forces one size."
|
|
8614
8875
|
}, humanPlan)) return;
|
|
8615
8876
|
const needsCodec = plan.entries.some((e) => e.kind === "texture" || (e.images ?? 0) > 0);
|
|
8616
|
-
const { findBrowser } = await import("./chunks/browser-
|
|
8877
|
+
const { findBrowser } = await import("./chunks/browser-nFaRUETt.mjs");
|
|
8617
8878
|
const run = (codec) => optimizeAssets(fs, {
|
|
8618
8879
|
...opts,
|
|
8619
8880
|
paths: plan.entries.map((e) => e.path),
|
|
@@ -8622,7 +8883,7 @@ var assetsCommand = {
|
|
|
8622
8883
|
}, codec);
|
|
8623
8884
|
let r;
|
|
8624
8885
|
if (needsCodec && findBrowser()) {
|
|
8625
|
-
const { withImageCodec } = await import("./chunks/imageCodec-
|
|
8886
|
+
const { withImageCodec } = await import("./chunks/imageCodec-DXxqkEQA.mjs");
|
|
8626
8887
|
r = await withImageCodec((codec) => run(codec), { log: log$1 });
|
|
8627
8888
|
} else r = await run();
|
|
8628
8889
|
r.skipped.unshift(...plan.skipped);
|
|
@@ -8644,7 +8905,7 @@ var assetsCommand = {
|
|
|
8644
8905
|
}
|
|
8645
8906
|
if (action === "depth") {
|
|
8646
8907
|
const image = positional(rest, 0, "image (project path or library:<id>)", "assets depth assets/textures/photo.jpg");
|
|
8647
|
-
const { checkDepthRequest, estimateDepth } = await import("./chunks/depth-
|
|
8908
|
+
const { checkDepthRequest, estimateDepth } = await import("./chunks/depth-DEaogEAi.mjs").then((n) => n.r);
|
|
8648
8909
|
const { deflateSync } = await import("node:zlib");
|
|
8649
8910
|
const req = {
|
|
8650
8911
|
image: image.replace(/^\.\//, ""),
|
|
@@ -8656,19 +8917,51 @@ var assetsCommand = {
|
|
|
8656
8917
|
};
|
|
8657
8918
|
if (req.maxSize !== void 0 && !(req.maxSize >= 16 && req.maxSize <= 8192)) usage(`--max-size must be between 16 and 8192, got ${req.maxSize}.`, "e.g. --max-size 1024 (default 2048).");
|
|
8658
8919
|
await checkDepthRequest(fs, req);
|
|
8659
|
-
const { withDepthEstimator } = await import("./chunks/depth-
|
|
8920
|
+
const { withDepthEstimator } = await import("./chunks/depth-Bf7cHwod.mjs");
|
|
8660
8921
|
const r = await withDepthEstimator((estimator) => estimateDepth(fs, req, estimator), { log: log$1 });
|
|
8922
|
+
const depthLine = `Wrote ${r.path} (${r.width}x${r.height}, ${r.kb} KB, licence ${r.license}) in ${(r.ms / 1e3).toFixed(2)} s — ${r.model.id}, ${r.model.backend ?? "wasm"}, model input ${r.input.width}x${r.input.height}.`;
|
|
8923
|
+
if (boolOpt(options, "plate")) {
|
|
8924
|
+
const plate = await runPlate(fs, options, {
|
|
8925
|
+
image: req.image,
|
|
8926
|
+
depth: r.path
|
|
8927
|
+
});
|
|
8928
|
+
const suggestion = {
|
|
8929
|
+
...r.suggestion,
|
|
8930
|
+
...plate.suggestion
|
|
8931
|
+
};
|
|
8932
|
+
return printResult(io, {
|
|
8933
|
+
...r,
|
|
8934
|
+
plate,
|
|
8935
|
+
suggestion,
|
|
8936
|
+
hint: `Use them on a photo object: agent3d object add --json-def '${JSON.stringify({
|
|
8937
|
+
id: "photo",
|
|
8938
|
+
...suggestion
|
|
8939
|
+
})}'`
|
|
8940
|
+
}, () => `${depthLine}\n${plateLine(plate)}\nUse them on a photo object: ${JSON.stringify(suggestion)}`);
|
|
8941
|
+
}
|
|
8661
8942
|
return printResult(io, {
|
|
8662
8943
|
...r,
|
|
8663
8944
|
hint: `Use it on a photo object: agent3d object add --json-def '${JSON.stringify({
|
|
8664
8945
|
id: "photo",
|
|
8665
8946
|
...r.suggestion
|
|
8666
8947
|
})}'`
|
|
8667
|
-
}, () =>
|
|
8948
|
+
}, () => `${depthLine}\nUse it as a photo object's depth: { "kind": "photo", "src": "${r.image}", "depth": "${r.path}" }`);
|
|
8949
|
+
}
|
|
8950
|
+
if (action === "plate") {
|
|
8951
|
+
const r = await runPlate(fs, options, {
|
|
8952
|
+
image: positional(rest, 0, "image (project path or library:<id>)", "assets plate assets/textures/photo.jpg").replace(/^\.\//, ""),
|
|
8953
|
+
depth: strOpt(options, "depth"),
|
|
8954
|
+
out: strOpt(options, "out"),
|
|
8955
|
+
outDepth: strOpt(options, "out-depth")
|
|
8956
|
+
});
|
|
8957
|
+
return printResult(io, {
|
|
8958
|
+
...r,
|
|
8959
|
+
hint: `Set them on the photo object: agent3d object update <id> --json-def '${JSON.stringify(r.suggestion)}'`
|
|
8960
|
+
}, () => `${plateLine(r)}\nSet them on the photo object: ${JSON.stringify(r.suggestion)}`);
|
|
8668
8961
|
}
|
|
8669
8962
|
if (action === "remove") {
|
|
8670
8963
|
const path = positional(rest, 0, "asset path", "assets remove <path>");
|
|
8671
|
-
const { listAssets, removeAsset } = await import("./chunks/assets-
|
|
8964
|
+
const { listAssets, removeAsset } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.n);
|
|
8672
8965
|
const { assets } = await listAssets(fs);
|
|
8673
8966
|
const entry = assets.find((a) => a.path === path);
|
|
8674
8967
|
if (!entry && !await fs.exists(path)) throw new CliError("notFound", `No asset "${path}".`, "`agent3d assets list` lists them.");
|
|
@@ -8683,10 +8976,33 @@ var assetsCommand = {
|
|
|
8683
8976
|
...r
|
|
8684
8977
|
}, () => `Removed ${path}.${r.usedBy.length ? ` Still referenced by: ${r.usedBy.join(", ")} — fix those references.` : ""}`);
|
|
8685
8978
|
}
|
|
8686
|
-
usage(`Unknown assets action "${action}".`, "Use list, search, add, optimize, depth, remove or library.");
|
|
8979
|
+
usage(`Unknown assets action "${action}".`, "Use list, search, add, optimize, depth, plate, remove or library.");
|
|
8687
8980
|
}
|
|
8688
8981
|
};
|
|
8689
8982
|
var log$1 = (m) => void process.stderr.write(`${m}\n`);
|
|
8983
|
+
async function runPlate(fs, options, base) {
|
|
8984
|
+
const { checkPlateRequest, generatePlate } = await import("./chunks/plate-Cwl35I2T.mjs").then((n) => n.r);
|
|
8985
|
+
const { deflateSync } = await import("node:zlib");
|
|
8986
|
+
const fmt = strOpt(options, "format");
|
|
8987
|
+
if (fmt !== void 0 && fmt !== "webp" && fmt !== "png") usage(`--format must be webp or png for a plate, got "${fmt}".`, "e.g. --format webp (default).");
|
|
8988
|
+
const req = {
|
|
8989
|
+
...base,
|
|
8990
|
+
maxSize: numOpt(options, "max-size"),
|
|
8991
|
+
strength: numOpt(options, "strength"),
|
|
8992
|
+
width: numOpt(options, "width"),
|
|
8993
|
+
quality: numOpt(options, "quality"),
|
|
8994
|
+
format: fmt,
|
|
8995
|
+
library: libraryProvider(),
|
|
8996
|
+
deflate: (d) => new Uint8Array(deflateSync(d)),
|
|
8997
|
+
inflate: (d) => new Uint8Array(inflateRawSync(d))
|
|
8998
|
+
};
|
|
8999
|
+
await checkPlateRequest(fs, req);
|
|
9000
|
+
const { withPixelCodec } = await import("./chunks/imageCodec-DXxqkEQA.mjs");
|
|
9001
|
+
return withPixelCodec((codec) => generatePlate(fs, req, codec), { log: log$1 });
|
|
9002
|
+
}
|
|
9003
|
+
function plateLine(r) {
|
|
9004
|
+
return `Wrote ${r.path} (${r.width}x${r.height}, ${r.kb} KB) and ${r.depthPath} (${r.depthKb} KB): ${r.holePercent} % of the photo rebuilt from the background (band ${r.holeWidth} px for a full depth jump${r.unfilled ? `, ${r.unfilled} px without background in reach` : ""}) in ${(r.ms / 1e3).toFixed(2)} s.`;
|
|
9005
|
+
}
|
|
8690
9006
|
async function expandPaths(fs, paths) {
|
|
8691
9007
|
const out = [];
|
|
8692
9008
|
for (const raw of paths) {
|
|
@@ -8772,7 +9088,7 @@ var templatesCommand = {
|
|
|
8772
9088
|
const scene = sceneBytes ? JSON.parse(new TextDecoder().decode(sceneBytes)) : null;
|
|
8773
9089
|
let summary = null;
|
|
8774
9090
|
if (scene) try {
|
|
8775
|
-
summary = (await import("./chunks/scene-
|
|
9091
|
+
summary = (await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a)).summarizeScene(scene);
|
|
8776
9092
|
} catch {
|
|
8777
9093
|
summary = null;
|
|
8778
9094
|
}
|
|
@@ -8806,14 +9122,14 @@ var checkCommand = {
|
|
|
8806
9122
|
],
|
|
8807
9123
|
async run({ io, options }) {
|
|
8808
9124
|
const fs = projectFs(options);
|
|
8809
|
-
const { checkProject } = await import("./chunks/check-
|
|
9125
|
+
const { checkProject } = await import("./chunks/check-E7GdPxTt.mjs").then((n) => n.r);
|
|
8810
9126
|
let extra = {
|
|
8811
9127
|
library: readLibraryIndex(),
|
|
8812
9128
|
...runtimeKb() !== void 0 ? { runtimeKb: runtimeKb() } : {}
|
|
8813
9129
|
};
|
|
8814
9130
|
let renderNote;
|
|
8815
9131
|
if (boolOpt(options, "render")) {
|
|
8816
|
-
const { renderProject } = await import("./chunks/render-
|
|
9132
|
+
const { renderProject } = await import("./chunks/render-CCKciCgu.mjs");
|
|
8817
9133
|
const out = strOpt(options, "out");
|
|
8818
9134
|
const outDir = out ? isAbsolute(out) ? out : resolve(fs.root, out) : checkRenderDir(fs.root);
|
|
8819
9135
|
const r = await renderProject({
|
|
@@ -8958,7 +9274,7 @@ var doctorCommand = {
|
|
|
8958
9274
|
message: `Node ${process.versions.node}${major >= 22 ? "" : " (Agent3D needs Node 22+)"}`,
|
|
8959
9275
|
...major < 22 ? { hint: "Install Node 22 or newer (https://nodejs.org)." } : {}
|
|
8960
9276
|
});
|
|
8961
|
-
const { findBrowser, browserVersion, noBrowserError } = await import("./chunks/browser-
|
|
9277
|
+
const { findBrowser, browserVersion, noBrowserError } = await import("./chunks/browser-nFaRUETt.mjs");
|
|
8962
9278
|
const browser = findBrowser();
|
|
8963
9279
|
if (browser) {
|
|
8964
9280
|
const version = await browserVersion(browser.path);
|
|
@@ -9024,7 +9340,7 @@ var doctorCommand = {
|
|
|
9024
9340
|
const dir = mkdtempSync(join(tmpdir(), "agent3d-doctor-"));
|
|
9025
9341
|
try {
|
|
9026
9342
|
writeFileSync(join(dir, "scene.json"), JSON.stringify(DOCTOR_SCENE));
|
|
9027
|
-
const { renderProject } = await import("./chunks/render-
|
|
9343
|
+
const { renderProject } = await import("./chunks/render-CCKciCgu.mjs");
|
|
9028
9344
|
const { decodePng, pngVariance } = await import("./chunks/png-DXfSGJZt.mjs");
|
|
9029
9345
|
const t0 = Date.now();
|
|
9030
9346
|
const r = await renderProject({
|
|
@@ -9178,7 +9494,7 @@ var infoCommand = {
|
|
|
9178
9494
|
options: [PROJECT_OPTION],
|
|
9179
9495
|
async run({ io, options }) {
|
|
9180
9496
|
const fs = projectFs(options);
|
|
9181
|
-
const [{ loadProject }, { summarizeScene }] = await Promise.all([Promise.resolve().then(() => project_exports), import("./chunks/scene-
|
|
9497
|
+
const [{ loadProject }, { summarizeScene }] = await Promise.all([Promise.resolve().then(() => project_exports), import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a)]);
|
|
9182
9498
|
const { manifest, scene } = await loadProject(fs);
|
|
9183
9499
|
const files = await fs.list();
|
|
9184
9500
|
const renders = files.filter((f) => f.startsWith("renders/") && f.endsWith(".png")).slice(-8);
|
|
@@ -9198,6 +9514,323 @@ var infoCommand = {
|
|
|
9198
9514
|
].join("\n"));
|
|
9199
9515
|
}
|
|
9200
9516
|
};
|
|
9517
|
+
// src/runtime/num.ts
|
|
9518
|
+
function clamp(v, min, max) {
|
|
9519
|
+
return v < min ? min : v > max ? max : v;
|
|
9520
|
+
}
|
|
9521
|
+
function num(v, def) {
|
|
9522
|
+
return typeof v === "number" && Number.isFinite(v) ? v : def;
|
|
9523
|
+
}
|
|
9524
|
+
// src/runtime/build/photoCore.ts
|
|
9525
|
+
var PHOTO_DEFAULTS = {
|
|
9526
|
+
width: 4,
|
|
9527
|
+
strength: .5,
|
|
9528
|
+
focus: .5,
|
|
9529
|
+
segments: 256,
|
|
9530
|
+
layers: 6,
|
|
9531
|
+
edgeCut: .08,
|
|
9532
|
+
speed: 1,
|
|
9533
|
+
smoothing: .9
|
|
9534
|
+
};
|
|
9535
|
+
function photoSize(def, imgW, imgH) {
|
|
9536
|
+
const aspect = imgW > 0 && imgH > 0 ? imgW / imgH : 1;
|
|
9537
|
+
const w = typeof def.width === "number" && def.width > 0 ? def.width : void 0;
|
|
9538
|
+
const h = typeof def.height === "number" && def.height > 0 ? def.height : void 0;
|
|
9539
|
+
if (w !== void 0 && h !== void 0) return {
|
|
9540
|
+
width: w,
|
|
9541
|
+
height: h
|
|
9542
|
+
};
|
|
9543
|
+
if (h !== void 0) return {
|
|
9544
|
+
width: h * aspect,
|
|
9545
|
+
height: h
|
|
9546
|
+
};
|
|
9547
|
+
const width = w ?? PHOTO_DEFAULTS.width;
|
|
9548
|
+
return {
|
|
9549
|
+
width,
|
|
9550
|
+
height: width / aspect
|
|
9551
|
+
};
|
|
9552
|
+
}
|
|
9553
|
+
function motionPeriod(s) {
|
|
9554
|
+
if (s.auto === "none") return {
|
|
9555
|
+
duration: 0,
|
|
9556
|
+
start: 0
|
|
9557
|
+
};
|
|
9558
|
+
const p = s.speed > 0 ? 10 / s.speed : 0;
|
|
9559
|
+
if (!s.loop) return {
|
|
9560
|
+
duration: s.duration > 0 ? s.duration : p,
|
|
9561
|
+
start: 0
|
|
9562
|
+
};
|
|
9563
|
+
return {
|
|
9564
|
+
duration: p,
|
|
9565
|
+
start: s.auto === "orbit" ? p : 0
|
|
9566
|
+
};
|
|
9567
|
+
}
|
|
9568
|
+
function motionSettings(m) {
|
|
9569
|
+
const pointer = clamp(num(m?.pointer, 1), 0, 1);
|
|
9570
|
+
return {
|
|
9571
|
+
pointer,
|
|
9572
|
+
scroll: clamp(num(m?.scroll, 0), 0, 1),
|
|
9573
|
+
gyro: typeof m?.gyro === "boolean" ? m.gyro : pointer > 0,
|
|
9574
|
+
auto: m?.auto ?? "sway",
|
|
9575
|
+
speed: Math.max(0, num(m?.speed, PHOTO_DEFAULTS.speed)),
|
|
9576
|
+
smoothing: clamp(num(m?.smoothing, PHOTO_DEFAULTS.smoothing), 0, .99),
|
|
9577
|
+
loop: m?.loop !== false,
|
|
9578
|
+
duration: Math.max(0, num(m?.duration, 0)),
|
|
9579
|
+
progress: typeof m?.progress === "number" && Number.isFinite(m.progress) ? clamp(m.progress, 0, 1) : null
|
|
9580
|
+
};
|
|
9581
|
+
}
|
|
9582
|
+
// src/ops/social.ts
|
|
9583
|
+
var SOCIAL_PRESET_IDS = [
|
|
9584
|
+
"vertical",
|
|
9585
|
+
"square",
|
|
9586
|
+
"landscape",
|
|
9587
|
+
"story"
|
|
9588
|
+
];
|
|
9589
|
+
var SOCIAL_PRESETS = {
|
|
9590
|
+
vertical: {
|
|
9591
|
+
id: "vertical",
|
|
9592
|
+
width: 1080,
|
|
9593
|
+
height: 1920,
|
|
9594
|
+
aspect: "9:16",
|
|
9595
|
+
bitrate: 1e7,
|
|
9596
|
+
description: "1080×1920 (9:16): Reels, TikTok, Shorts, LinkedIn / Instagram vertical video."
|
|
9597
|
+
},
|
|
9598
|
+
square: {
|
|
9599
|
+
id: "square",
|
|
9600
|
+
width: 1080,
|
|
9601
|
+
height: 1080,
|
|
9602
|
+
aspect: "1:1",
|
|
9603
|
+
bitrate: 8e6,
|
|
9604
|
+
description: "1080×1080 (1:1): Instagram / LinkedIn / Facebook feed."
|
|
9605
|
+
},
|
|
9606
|
+
landscape: {
|
|
9607
|
+
id: "landscape",
|
|
9608
|
+
width: 1920,
|
|
9609
|
+
height: 1080,
|
|
9610
|
+
aspect: "16:9",
|
|
9611
|
+
bitrate: 1e7,
|
|
9612
|
+
description: "1920×1080 (16:9): YouTube, LinkedIn, X, websites."
|
|
9613
|
+
},
|
|
9614
|
+
story: {
|
|
9615
|
+
id: "story",
|
|
9616
|
+
width: 1080,
|
|
9617
|
+
height: 1920,
|
|
9618
|
+
aspect: "9:16",
|
|
9619
|
+
maxDuration: 15,
|
|
9620
|
+
bitrate: 1e7,
|
|
9621
|
+
description: "1080×1920 (9:16), at most 15 s: Instagram / Facebook stories."
|
|
9622
|
+
}
|
|
9623
|
+
};
|
|
9624
|
+
function parseSocialPreset(name) {
|
|
9625
|
+
const id = name.trim().toLowerCase();
|
|
9626
|
+
if (SOCIAL_PRESET_IDS.includes(id)) return SOCIAL_PRESETS[id];
|
|
9627
|
+
const s = closest(id, SOCIAL_PRESET_IDS);
|
|
9628
|
+
return {
|
|
9629
|
+
error: `Unknown video preset "${name}".`,
|
|
9630
|
+
hint: `${s ? `Did you mean "${s}"? ` : ""}Use ${SOCIAL_PRESET_IDS.join(", ")} (${SOCIAL_PRESET_IDS.map((p) => `${p} ${SOCIAL_PRESETS[p].width}x${SOCIAL_PRESETS[p].height}`).join(", ")}).`
|
|
9631
|
+
};
|
|
9632
|
+
}
|
|
9633
|
+
function photos(scene) {
|
|
9634
|
+
return (scene.objects ?? []).filter((o) => o.kind === "photo");
|
|
9635
|
+
}
|
|
9636
|
+
function socialDuration(scene, preset) {
|
|
9637
|
+
let out = null;
|
|
9638
|
+
for (const p of photos(scene)) {
|
|
9639
|
+
const s = motionSettings(p.motion);
|
|
9640
|
+
if (s.progress !== null) continue;
|
|
9641
|
+
const m = motionPeriod(s);
|
|
9642
|
+
if (m.duration > 0) {
|
|
9643
|
+
out = {
|
|
9644
|
+
...m,
|
|
9645
|
+
source: `one ${s.loop ? "loop" : "move"} of "${p.id}" (motion.auto "${s.auto}")`
|
|
9646
|
+
};
|
|
9647
|
+
break;
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9650
|
+
const tl = scene.timeline?.duration;
|
|
9651
|
+
out ??= tl && tl > 0 ? {
|
|
9652
|
+
duration: tl,
|
|
9653
|
+
start: 0,
|
|
9654
|
+
source: "the timeline duration"
|
|
9655
|
+
} : {
|
|
9656
|
+
duration: 5,
|
|
9657
|
+
start: 0,
|
|
9658
|
+
source: "default 5 s"
|
|
9659
|
+
};
|
|
9660
|
+
if (preset?.maxDuration && out.duration > preset.maxDuration) out = {
|
|
9661
|
+
...out,
|
|
9662
|
+
duration: preset.maxDuration,
|
|
9663
|
+
source: `${out.source}, capped to ${preset.maxDuration} s (${preset.id})`
|
|
9664
|
+
};
|
|
9665
|
+
return {
|
|
9666
|
+
...out,
|
|
9667
|
+
duration: Math.round(out.duration * 1e3) / 1e3
|
|
9668
|
+
};
|
|
9669
|
+
}
|
|
9670
|
+
var DEG = Math.PI / 180;
|
|
9671
|
+
var sub = (a, b) => [
|
|
9672
|
+
a[0] - b[0],
|
|
9673
|
+
a[1] - b[1],
|
|
9674
|
+
a[2] - b[2]
|
|
9675
|
+
];
|
|
9676
|
+
var cross = (a, b) => [
|
|
9677
|
+
a[1] * b[2] - a[2] * b[1],
|
|
9678
|
+
a[2] * b[0] - a[0] * b[2],
|
|
9679
|
+
a[0] * b[1] - a[1] * b[0]
|
|
9680
|
+
];
|
|
9681
|
+
var norm = (a) => {
|
|
9682
|
+
const l = Math.hypot(a[0], a[1], a[2]) || 1;
|
|
9683
|
+
return [
|
|
9684
|
+
a[0] / l,
|
|
9685
|
+
a[1] / l,
|
|
9686
|
+
a[2] / l
|
|
9687
|
+
];
|
|
9688
|
+
};
|
|
9689
|
+
function coverScene(scene, aspect, imageSize) {
|
|
9690
|
+
const notes = [];
|
|
9691
|
+
const out = {
|
|
9692
|
+
...scene,
|
|
9693
|
+
target: {
|
|
9694
|
+
...scene.target,
|
|
9695
|
+
aspect: aspectString(aspect)
|
|
9696
|
+
},
|
|
9697
|
+
camera: { ...scene.camera }
|
|
9698
|
+
};
|
|
9699
|
+
const cam = out.camera;
|
|
9700
|
+
const design = parseAspect(scene.target?.aspect);
|
|
9701
|
+
if (design && Math.abs(design - aspect) > .01) notes.push(`The scene (${scene.target?.aspect}) is cropped to ${aspectString(aspect)}: content near the ${aspect < design ? "left and right" : "top and bottom"} edges is cut — look at the frames.`);
|
|
9702
|
+
const C = cam.position;
|
|
9703
|
+
const f = norm(sub(cam.target ?? [
|
|
9704
|
+
0,
|
|
9705
|
+
0,
|
|
9706
|
+
0
|
|
9707
|
+
], C));
|
|
9708
|
+
const r = norm(cross(f, [
|
|
9709
|
+
0,
|
|
9710
|
+
1,
|
|
9711
|
+
0
|
|
9712
|
+
]));
|
|
9713
|
+
const u = cross(r, f);
|
|
9714
|
+
const ortho = cam.type === "orthographic";
|
|
9715
|
+
const tanY = ortho ? 0 : Math.tan((cam.fov ?? 45) * DEG / 2);
|
|
9716
|
+
const halfH = ortho ? (cam.zoom ?? 10) / 2 : 0;
|
|
9717
|
+
let need = 1;
|
|
9718
|
+
for (const p of photos(scene)) {
|
|
9719
|
+
if ((p.rotation ?? [
|
|
9720
|
+
0,
|
|
9721
|
+
0,
|
|
9722
|
+
0
|
|
9723
|
+
]).some((a) => Math.abs(a) > .5) || Math.abs(f[2]) < .97) {
|
|
9724
|
+
notes.push(`"${p.id}" is not facing the camera head-on: cover fit skipped for it.`);
|
|
9725
|
+
continue;
|
|
9726
|
+
}
|
|
9727
|
+
const img = imageSize(p.src);
|
|
9728
|
+
if (!img) {
|
|
9729
|
+
notes.push(`"${p.id}": unknown image size (${p.src}): cover fit skipped for it.`);
|
|
9730
|
+
continue;
|
|
9731
|
+
}
|
|
9732
|
+
const size = photoSize(p, img.width, img.height);
|
|
9733
|
+
const sc = p.scale ?? 1;
|
|
9734
|
+
const [sx, sy] = typeof sc === "number" ? [sc, sc] : [sc[0], sc[1]];
|
|
9735
|
+
const pos = p.position ?? [
|
|
9736
|
+
0,
|
|
9737
|
+
0,
|
|
9738
|
+
0
|
|
9739
|
+
];
|
|
9740
|
+
const hw = size.width * Math.abs(sx) / 2, hh = size.height * Math.abs(sy) / 2;
|
|
9741
|
+
const margin = p.mode === "mesh" ? 1.06 : 1.01;
|
|
9742
|
+
const dist = ortho ? 1 : (pos[2] - C[2]) / f[2];
|
|
9743
|
+
if (!(dist > 0)) continue;
|
|
9744
|
+
const center = [C[0] + f[0] * dist, C[1] + f[1] * dist];
|
|
9745
|
+
const ex = ortho ? halfH * aspect : tanY * aspect * dist, ey = ortho ? halfH : tanY * dist;
|
|
9746
|
+
const fx = Math.abs(r[0]) * ex + Math.abs(u[0]) * ey, fy = Math.abs(r[1]) * ex + Math.abs(u[1]) * ey;
|
|
9747
|
+
const roomX = Math.min(pos[0] + hw - center[0], center[0] - (pos[0] - hw));
|
|
9748
|
+
const roomY = Math.min(pos[1] + hh - center[1], center[1] - (pos[1] - hh));
|
|
9749
|
+
if (roomX <= 0 || roomY <= 0) {
|
|
9750
|
+
notes.push(`"${p.id}" is off the view centre: cover fit skipped for it.`);
|
|
9751
|
+
continue;
|
|
9752
|
+
}
|
|
9753
|
+
need = Math.max(need, fx * margin / roomX, fy * margin / roomY);
|
|
9754
|
+
}
|
|
9755
|
+
if (need > 1.0001) {
|
|
9756
|
+
if (ortho) cam.zoom = (cam.zoom ?? 10) / need;
|
|
9757
|
+
else cam.fov = 2 * Math.atan(tanY / need) / DEG;
|
|
9758
|
+
notes.push(`Camera tightened ${need.toFixed(2)}× (${ortho ? `zoom ${cam.zoom.toFixed(2)}` : `fov ${cam.fov.toFixed(1)}°`}) so the photo covers the ${aspectString(aspect)} frame (no edges).`);
|
|
9759
|
+
if (cam.shots?.length || cam.controls === "scroll") notes.push("Camera shots / scroll paths keep their own fov: check the frames.");
|
|
9760
|
+
}
|
|
9761
|
+
return {
|
|
9762
|
+
scene: out,
|
|
9763
|
+
zoom: need,
|
|
9764
|
+
notes
|
|
9765
|
+
};
|
|
9766
|
+
}
|
|
9767
|
+
function parseAspect(a) {
|
|
9768
|
+
const m = /^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(a ?? "");
|
|
9769
|
+
const v = m ? Number(m[1]) / Number(m[2]) : void 0;
|
|
9770
|
+
return v && Number.isFinite(v) && v > 0 ? v : void 0;
|
|
9771
|
+
}
|
|
9772
|
+
function aspectString(a) {
|
|
9773
|
+
for (const [w, h] of [
|
|
9774
|
+
[9, 16],
|
|
9775
|
+
[1, 1],
|
|
9776
|
+
[16, 9],
|
|
9777
|
+
[4, 5],
|
|
9778
|
+
[4, 3],
|
|
9779
|
+
[3, 4],
|
|
9780
|
+
[21, 9],
|
|
9781
|
+
[4, 1],
|
|
9782
|
+
[3, 1],
|
|
9783
|
+
[2, 1]
|
|
9784
|
+
]) if (Math.abs(a - w / h) < .005) return `${w}:${h}`;
|
|
9785
|
+
return `${Math.round(a * 1e3)}:1000`;
|
|
9786
|
+
}
|
|
9787
|
+
function imageHeaderSize(b) {
|
|
9788
|
+
const be16 = (i) => b[i] << 8 | b[i + 1];
|
|
9789
|
+
const be32 = (i) => (b[i] << 24 | b[i + 1] << 16 | b[i + 2] << 8 | b[i + 3]) >>> 0;
|
|
9790
|
+
const le16 = (i) => b[i] | b[i + 1] << 8;
|
|
9791
|
+
const le24 = (i) => b[i] | b[i + 1] << 8 | b[i + 2] << 16;
|
|
9792
|
+
if (b.length >= 24 && b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) return {
|
|
9793
|
+
width: be32(16),
|
|
9794
|
+
height: be32(20)
|
|
9795
|
+
};
|
|
9796
|
+
if (b.length >= 30 && String.fromCharCode(...b.subarray(0, 4)) === "RIFF" && String.fromCharCode(...b.subarray(8, 12)) === "WEBP") {
|
|
9797
|
+
const kind = String.fromCharCode(...b.subarray(12, 16));
|
|
9798
|
+
if (kind === "VP8 " && b.length >= 30) return {
|
|
9799
|
+
width: le16(26) & 16383,
|
|
9800
|
+
height: le16(28) & 16383
|
|
9801
|
+
};
|
|
9802
|
+
if (kind === "VP8L" && b.length >= 25) {
|
|
9803
|
+
const bits = b[21] | b[22] << 8 | b[23] << 16 | b[24] << 24;
|
|
9804
|
+
return {
|
|
9805
|
+
width: (bits & 16383) + 1,
|
|
9806
|
+
height: (bits >>> 14 & 16383) + 1
|
|
9807
|
+
};
|
|
9808
|
+
}
|
|
9809
|
+
if (kind === "VP8X" && b.length >= 30) return {
|
|
9810
|
+
width: le24(24) + 1,
|
|
9811
|
+
height: le24(27) + 1
|
|
9812
|
+
};
|
|
9813
|
+
return null;
|
|
9814
|
+
}
|
|
9815
|
+
if (b.length >= 4 && b[0] === 255 && b[1] === 216) {
|
|
9816
|
+
let i = 2;
|
|
9817
|
+
while (i + 9 < b.length) {
|
|
9818
|
+
if (b[i] !== 255) return null;
|
|
9819
|
+
const marker = b[i + 1];
|
|
9820
|
+
if (marker === 216 || marker >= 208 && marker <= 215 || marker === 1) {
|
|
9821
|
+
i += 2;
|
|
9822
|
+
continue;
|
|
9823
|
+
}
|
|
9824
|
+
const len = be16(i + 2);
|
|
9825
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return {
|
|
9826
|
+
width: be16(i + 7),
|
|
9827
|
+
height: be16(i + 5)
|
|
9828
|
+
};
|
|
9829
|
+
i += 2 + len;
|
|
9830
|
+
}
|
|
9831
|
+
}
|
|
9832
|
+
return null;
|
|
9833
|
+
}
|
|
9201
9834
|
// agent/commands/render.ts
|
|
9202
9835
|
var SIZE_OPTION = {
|
|
9203
9836
|
name: "size",
|
|
@@ -9216,8 +9849,8 @@ function timeoutMs(options) {
|
|
|
9216
9849
|
var log = (m) => void process.stderr.write(`${m}\n`);
|
|
9217
9850
|
var renderCommand = {
|
|
9218
9851
|
name: "render",
|
|
9219
|
-
usage: "render [--frames 0,1.5,3 | --count 4] [--size 1200x300] [--scale 2] [--quality draft|standard|high|ultra] [--transparent] [--scroll 0.5] [--reduced-motion] [--segment <name>] [--sheet] [--input <json|@file>] [--isolate <objectId>] [--bg checker|<colour>|none] [--out renders/] | --video out.mp4|out.webm [--fps 30] [--duration 6] | --gif out.gif | --webp out.webp [--project <dir>]",
|
|
9220
|
-
summary: "Render the scene headless (installed Chrome, deterministic time) to PNGs — LOOK at them to check framing, colours, motion. Returns { dir, frames: [{ t, path }], sheet?, state, stats, inspect, issues, consoleErrors } (paths relative to the project folder `dir`). Games: --input plays a script of simulated keys / clicks / drags / swipes / HUD button clicks / emitted events and `state` shows the result (e.g. the score). Media: --video (MP4 H.264 / WebM VP9), --gif or --webp (animated) render every frame exactly at any --fps / --duration / --size (with --input, --segment, --scroll and --reduced-motion applied too) and return { path, format, codec, frames, fps, duration, size, bytes }. Scenes whose timeline waits for a click / interaction: --segment <name> plays that segment from the start.",
|
|
9852
|
+
usage: "render [--frames 0,1.5,3 | --count 4] [--size 1200x300] [--scale 2] [--quality draft|standard|high|ultra] [--transparent] [--scroll 0.5] [--reduced-motion] [--segment <name>] [--sheet] [--input <json|@file>] [--isolate <objectId>] [--bg checker|<colour>|none] [--out renders/] | --video out.mp4|out.webm [--preset vertical|square|landscape|story] [--fit cover|contain] [--fps 30] [--duration 6] | --gif out.gif | --webp out.webp [--project <dir>]",
|
|
9853
|
+
summary: "Render the scene headless (installed Chrome, deterministic time) to PNGs — LOOK at them to check framing, colours, motion. Returns { dir, frames: [{ t, path }], sheet?, state, stats, inspect, issues, consoleErrors } (paths relative to the project folder `dir`). Games: --input plays a script of simulated keys / clicks / drags / swipes / HUD button clicks / emitted events and `state` shows the result (e.g. the score). Media: --video (MP4 H.264 / WebM VP9), --gif or --webp (animated) render every frame exactly at any --fps / --duration / --size (with --input, --segment, --scroll and --reduced-motion applied too) and return { path, format, codec, frames, fps, duration, size, bytes }. Social video: --video out.mp4 --preset vertical (1080x1920) | square (1080x1080) | landscape (1920x1080) | story (1080x1920, max 15 s) — 30 fps, one seamless loop of the photo motion, a bitrate social networks keep sharp and a cover fit (3D photos fill the frame, no edges; `notes` say what was cropped / tightened). Scenes whose timeline waits for a click / interaction: --segment <name> plays that segment from the start.",
|
|
9221
9854
|
writes: true,
|
|
9222
9855
|
options: [
|
|
9223
9856
|
PROJECT_OPTION,
|
|
@@ -9335,7 +9968,17 @@ var renderCommand = {
|
|
|
9335
9968
|
{
|
|
9336
9969
|
name: "bitrate",
|
|
9337
9970
|
type: "string",
|
|
9338
|
-
description: "Video bitrate in Mbit/s (default from size, fps and --quality)."
|
|
9971
|
+
description: "Video bitrate in Mbit/s (default from size, fps and --quality; 10 with a 1080p --preset)."
|
|
9972
|
+
},
|
|
9973
|
+
{
|
|
9974
|
+
name: "preset",
|
|
9975
|
+
type: "string",
|
|
9976
|
+
description: "Social video preset: vertical (1080x1920, 9:16), square (1080x1080), landscape (1920x1080) or story (1080x1920, at most 15 s). Sets --size, fps 30, the duration (one seamless loop of the 3D photo motion, else the timeline, unless --duration), the bitrate and a cover fit. Without --video / --gif / --webp: PNG frames of that framing spread over the loop."
|
|
9977
|
+
},
|
|
9978
|
+
{
|
|
9979
|
+
name: "fit",
|
|
9980
|
+
type: "string",
|
|
9981
|
+
description: "cover (default with --preset when the scene has a 3D photo: render at the frame's aspect and tighten the camera until the photos fill it, no edges) or contain (the runtime's own fit: a narrower frame widens the view and may show the background around a photo)."
|
|
9339
9982
|
},
|
|
9340
9983
|
TIMEOUT_OPTION,
|
|
9341
9984
|
{
|
|
@@ -9345,14 +9988,16 @@ var renderCommand = {
|
|
|
9345
9988
|
],
|
|
9346
9989
|
async run({ io, options }) {
|
|
9347
9990
|
const fs = projectFs(options);
|
|
9348
|
-
const { parseQuality } = await import("./chunks/render-
|
|
9991
|
+
const { parseQuality } = await import("./chunks/render-CCKciCgu.mjs");
|
|
9349
9992
|
const quality = parseQuality(strOpt(options, "quality"));
|
|
9350
9993
|
const scroll = numOpt(options, "scroll");
|
|
9351
|
-
const { parseInputScript } = await import("./chunks/render-
|
|
9994
|
+
const { parseInputScript } = await import("./chunks/render-CCKciCgu.mjs");
|
|
9352
9995
|
const rawInput = strOpt(options, "input") !== void 0 ? jsonOpt(options, "input", `--input '[{"t": 0.5, "key": "ArrowRight", "hold": 1}]' or --input @inputs.json`) : void 0;
|
|
9353
9996
|
const input = rawInput === void 0 ? void 0 : parseInputScript(rawInput);
|
|
9354
9997
|
const segment = strOpt(options, "segment");
|
|
9355
9998
|
const reducedMotion = boolOpt(options, "reduced-motion");
|
|
9999
|
+
const preset = presetOpt(strOpt(options, "preset"));
|
|
10000
|
+
const fit = parseFit(strOpt(options, "fit"));
|
|
9356
10001
|
const mediaOpts = [
|
|
9357
10002
|
"video",
|
|
9358
10003
|
"gif",
|
|
@@ -9362,7 +10007,7 @@ var renderCommand = {
|
|
|
9362
10007
|
if (mediaOpts.length) {
|
|
9363
10008
|
const kind = mediaOpts[0];
|
|
9364
10009
|
const out = projectPath(fs.root, strOpt(options, kind));
|
|
9365
|
-
const { renderMedia, mediaFormatFromPath } = await import("./chunks/render-
|
|
10010
|
+
const { renderMedia, mediaFormatFromPath } = await import("./chunks/render-CCKciCgu.mjs");
|
|
9366
10011
|
const format = kind === "video" ? mediaFormatFromPath(out) : kind;
|
|
9367
10012
|
if (kind === "video" && format !== "mp4" && format !== "webm") usage(`--video needs a .mp4 or .webm file name, got "${strOpt(options, kind)}".`, "e.g. --video renders/banner.mp4");
|
|
9368
10013
|
if (existsSync(out) && !confirmOrPlan(io, options, { overwrite: [out] }, () => `Overwrite ${out}`)) return;
|
|
@@ -9385,6 +10030,8 @@ var renderCommand = {
|
|
|
9385
10030
|
segment,
|
|
9386
10031
|
reducedMotion,
|
|
9387
10032
|
scroll,
|
|
10033
|
+
preset,
|
|
10034
|
+
fit,
|
|
9388
10035
|
timeoutMs: timeoutMs(options),
|
|
9389
10036
|
log
|
|
9390
10037
|
});
|
|
@@ -9392,7 +10039,7 @@ var renderCommand = {
|
|
|
9392
10039
|
return printResult(io, {
|
|
9393
10040
|
...result,
|
|
9394
10041
|
path: out
|
|
9395
|
-
}, () => `${r.format.toUpperCase()} ${r.duration}s @ ${r.fps} fps (${r.frames} frames, ${r.size.width}x${r.size.height}, ${r.codec}${r.supersampling > 1 ? `, ${r.supersampling}× supersampled` : ""}, ${Math.round(r.bytes / 1024)} KB, ${Math.round(r.ms / 1e3)} s) → ${out}`);
|
|
10042
|
+
}, () => [`${r.format.toUpperCase()} ${r.duration}s @ ${r.fps} fps (${r.frames} frames, ${r.size.width}x${r.size.height}, ${r.codec}${r.supersampling > 1 ? `, ${r.supersampling}× supersampled` : ""}, ${Math.round(r.bytes / 1024)} KB, ${Math.round(r.ms / 1e3)} s) → ${out}`, ...(r.notes ?? []).map((n) => ` ${n}`)].join("\n"));
|
|
9396
10043
|
}
|
|
9397
10044
|
const capture = strOpt(options, "capture");
|
|
9398
10045
|
if (capture && ![
|
|
@@ -9400,13 +10047,23 @@ var renderCommand = {
|
|
|
9400
10047
|
"canvas",
|
|
9401
10048
|
"page"
|
|
9402
10049
|
].includes(capture)) usage(`--capture must be auto, canvas or page, got "${capture}".`);
|
|
9403
|
-
const { renderProject } = await import("./chunks/render-
|
|
9404
|
-
|
|
10050
|
+
const { renderProject, socialPlan } = await import("./chunks/render-CCKciCgu.mjs");
|
|
10051
|
+
let frames = renderFrames(strOpt(options, "frames"), numOpt(options, "count"), scroll);
|
|
10052
|
+
const social = preset || fit ? socialPlan({
|
|
10053
|
+
preset,
|
|
10054
|
+
fit,
|
|
10055
|
+
size: strOpt(options, "size"),
|
|
10056
|
+
width: numOpt(options, "width"),
|
|
10057
|
+
projectDir: fs.root,
|
|
10058
|
+
duration: numOpt(options, "duration")
|
|
10059
|
+
}) : void 0;
|
|
10060
|
+
if (social?.duration && !frames) frames = loopFrames(social.start, social.duration, numOpt(options, "count"));
|
|
9405
10061
|
const r = await renderProject({
|
|
9406
10062
|
projectDir: fs.root,
|
|
10063
|
+
...social ? { scene: social.scene } : {},
|
|
9407
10064
|
frames,
|
|
9408
10065
|
count: numOpt(options, "count"),
|
|
9409
|
-
size: strOpt(options, "size"),
|
|
10066
|
+
size: social?.size ?? strOpt(options, "size"),
|
|
9410
10067
|
width: numOpt(options, "width"),
|
|
9411
10068
|
scale: numOpt(options, "scale"),
|
|
9412
10069
|
sheet: boolOpt(options, "sheet"),
|
|
@@ -9432,8 +10089,10 @@ var renderCommand = {
|
|
|
9432
10089
|
...r.consoleErrors.length ? [`${r.consoleErrors.length} console error(s): see consoleErrors.`] : [],
|
|
9433
10090
|
...r.inputWarnings ?? []
|
|
9434
10091
|
];
|
|
10092
|
+
if (social?.notes.length) hints.push(...social.notes);
|
|
9435
10093
|
printResult(io, {
|
|
9436
10094
|
...r,
|
|
10095
|
+
...social?.preset ? { preset: social.preset } : {},
|
|
9437
10096
|
...hints.length ? { hints } : {}
|
|
9438
10097
|
}, () => [
|
|
9439
10098
|
...r.frames.map((f) => `${f.scroll !== void 0 ? `scroll=${f.scroll} ` : ""}t=${f.t}s ${resolve(r.dir, f.path)}`),
|
|
@@ -9445,6 +10104,24 @@ var renderCommand = {
|
|
|
9445
10104
|
].join("\n"));
|
|
9446
10105
|
}
|
|
9447
10106
|
};
|
|
10107
|
+
/** --preset: a social video preset id (usage error with did-you-mean otherwise). */
|
|
10108
|
+
function presetOpt(v) {
|
|
10109
|
+
if (v === void 0) return void 0;
|
|
10110
|
+
const p = parseSocialPreset(v);
|
|
10111
|
+
if ("error" in p) usage(p.error, p.hint);
|
|
10112
|
+
return p.id;
|
|
10113
|
+
}
|
|
10114
|
+
/** --fit: cover | contain. */
|
|
10115
|
+
function parseFit(v) {
|
|
10116
|
+
if (v === void 0) return void 0;
|
|
10117
|
+
if (v !== "cover" && v !== "contain") usage(`--fit must be cover or contain, got "${v}".`, "cover fills the frame with the 3D photo (cropping the scene); contain keeps the scene's design width visible.");
|
|
10118
|
+
return v;
|
|
10119
|
+
}
|
|
10120
|
+
/** `count` frame times (default 4) spread over one loop [start, start + duration). */
|
|
10121
|
+
function loopFrames(start, duration, count) {
|
|
10122
|
+
const n = Math.max(1, Math.min(64, Math.round(count ?? 4)));
|
|
10123
|
+
return Array.from({ length: n }, (_, i) => Math.round((start + i * duration / n) * 1e3) / 1e3).join(",");
|
|
10124
|
+
}
|
|
9448
10125
|
/** --frames to render: a --scroll position alone is one frame (t = 0). */
|
|
9449
10126
|
function renderFrames(frames, count, scroll) {
|
|
9450
10127
|
return frames ?? (scroll !== void 0 && count === void 0 ? "0" : void 0);
|
|
@@ -9460,7 +10137,7 @@ function dirNonEmpty(dir) {
|
|
|
9460
10137
|
}
|
|
9461
10138
|
var exportCommand = {
|
|
9462
10139
|
name: "export",
|
|
9463
|
-
usage: "export [--format embed|zip|single-html|poster|video|gif] [--out <path>] [--name <slug>] [--base-url <url>] [--cache-bust] [--no-integrity] [--no-poster] [--no-og] [--prune-runtime] [--runtime auto|full] [--yes] [--project <dir>]",
|
|
10140
|
+
usage: "export [--format embed|zip|single-html|poster|video|gif] [--preset vertical|square|landscape|story] [--out <path>] [--name <slug>] [--base-url <url>] [--cache-bust] [--no-integrity] [--no-poster] [--no-og] [--prune-runtime] [--runtime auto|full] [--yes] [--project <dir>]",
|
|
9464
10141
|
summary: "Export for a website: embed (Web Component + static files + EMBED.md + React/Vue/Svelte wrappers, default), zip (the embed folder as one .zip), single-html (one file), poster (still image), video (MP4 H.264 / WebM VP9) or gif. Reports pageKb / pageKbGzip (what a visitor downloads for this scene: runtime entry + the chunks it loads + scene, assets, scripts, poster) and folderKb (every file written). Overwriting a non-empty --out needs --yes.",
|
|
9465
10142
|
writes: true,
|
|
9466
10143
|
options: [
|
|
@@ -9513,7 +10190,7 @@ var exportCommand = {
|
|
|
9513
10190
|
{
|
|
9514
10191
|
name: "runtime",
|
|
9515
10192
|
type: "string",
|
|
9516
|
-
description: "embed / zip / single-html: auto (default) ships the photo-only lite runtime (agent3d-photo.js, ~
|
|
10193
|
+
description: "embed / zip / single-html: auto (default) ships the photo-only lite runtime (agent3d-photo.js, ~19 KB gzipped, no three.js) when the scene is a single 3D photo with a fixed camera and a plain background; full always ships agent3d-runtime.js. The result's runtime / runtimeReasons say which and why."
|
|
9517
10194
|
},
|
|
9518
10195
|
{
|
|
9519
10196
|
name: "no-og",
|
|
@@ -9538,7 +10215,12 @@ var exportCommand = {
|
|
|
9538
10215
|
{
|
|
9539
10216
|
name: "duration",
|
|
9540
10217
|
type: "string",
|
|
9541
|
-
description: "video / gif: seconds (default the timeline duration, else 5)."
|
|
10218
|
+
description: "video / gif: seconds (default the timeline duration, else 5; with --preset one seamless loop of the 3D photo motion)."
|
|
10219
|
+
},
|
|
10220
|
+
{
|
|
10221
|
+
name: "preset",
|
|
10222
|
+
type: "string",
|
|
10223
|
+
description: "video / gif: social preset — vertical (1080x1920), square (1080x1080), landscape (1920x1080) or story (1080x1920, max 15 s): size, 30 fps, one seamless loop, bitrate and a cover fit (the 3D photo fills the frame). The default --out becomes dist/video-<preset>.mp4."
|
|
9542
10224
|
},
|
|
9543
10225
|
{
|
|
9544
10226
|
name: "fps",
|
|
@@ -9580,7 +10262,7 @@ var exportCommand = {
|
|
|
9580
10262
|
];
|
|
9581
10263
|
if (!FORMATS.includes(format)) usage(`Unknown --format "${format}".`, `Use ${FORMATS.join(", ")}.`);
|
|
9582
10264
|
const outOpt = strOpt(options, "out");
|
|
9583
|
-
const render = () => import("./chunks/render-
|
|
10265
|
+
const render = () => import("./chunks/render-CCKciCgu.mjs");
|
|
9584
10266
|
if (format === "poster" || format === "video" || format === "gif") {
|
|
9585
10267
|
const { parseQuality, mediaFormatFromPath } = await render();
|
|
9586
10268
|
const quality = parseQuality(strOpt(options, "quality"));
|
|
@@ -9590,7 +10272,8 @@ var exportCommand = {
|
|
|
9590
10272
|
"png",
|
|
9591
10273
|
"jpeg"
|
|
9592
10274
|
].includes(image)) usage("--image must be webp, png or jpeg.");
|
|
9593
|
-
const
|
|
10275
|
+
const preset = format === "poster" ? void 0 : presetOpt(strOpt(options, "preset"));
|
|
10276
|
+
const out = projectPath(fs.root, outOpt ?? join(fs.root, "dist", format === "poster" ? `poster.${image === "jpeg" ? "jpg" : image}` : format === "gif" ? preset ? `animation-${preset}.gif` : "animation.gif" : preset ? `video-${preset}.mp4` : "video.webm"));
|
|
9594
10277
|
if (existsSync(out) && !confirmOrPlan(io, options, { overwrite: [out] }, () => `Overwrite ${out}`)) return;
|
|
9595
10278
|
const r = await render();
|
|
9596
10279
|
if (format === "poster") {
|
|
@@ -9626,6 +10309,7 @@ var exportCommand = {
|
|
|
9626
10309
|
fps: numOpt(options, "fps"),
|
|
9627
10310
|
quality,
|
|
9628
10311
|
transparent: boolOpt(options, "transparent"),
|
|
10312
|
+
preset,
|
|
9629
10313
|
timeoutMs: timeoutMs(options),
|
|
9630
10314
|
log
|
|
9631
10315
|
});
|
|
@@ -9638,8 +10322,10 @@ var exportCommand = {
|
|
|
9638
10322
|
duration: m.duration,
|
|
9639
10323
|
size: m.size,
|
|
9640
10324
|
bytes: m.bytes,
|
|
9641
|
-
ms: m.ms
|
|
9642
|
-
|
|
10325
|
+
ms: m.ms,
|
|
10326
|
+
...m.preset ? { preset: m.preset } : {},
|
|
10327
|
+
...m.notes ? { notes: m.notes } : {}
|
|
10328
|
+
}, () => [`${media.toUpperCase()} ${m.duration}s @ ${m.fps} fps (${m.frames} frames, ${m.size.width}x${m.size.height}, ${m.codec}, ${Math.round(m.bytes / 1024)} KB) → ${out}`, ...(m.notes ?? []).map((n) => ` ${n}`)].join("\n"));
|
|
9643
10329
|
}
|
|
9644
10330
|
const out = projectPath(fs.root, outOpt ?? join(fs.root, "dist", format));
|
|
9645
10331
|
const existing = dirNonEmpty(out);
|
|
@@ -9665,17 +10351,17 @@ var exportCommand = {
|
|
|
9665
10351
|
const runtimeChoice = strOpt(options, "runtime") ?? "auto";
|
|
9666
10352
|
if (runtimeChoice !== "auto" && runtimeChoice !== "full") usage(`Unknown --runtime "${runtimeChoice}".`, "Use auto (default: the photo-only lite runtime for single-3D-photo scenes) or full.");
|
|
9667
10353
|
const runtime = { files: readRuntimeFiles(format) };
|
|
9668
|
-
const { buildExport } = await import("./chunks/export-
|
|
9669
|
-
const { version } = (await import("./chunks/package-
|
|
10354
|
+
const { buildExport } = await import("./chunks/export-BSOqVfPT.mjs").then((n) => n.n);
|
|
10355
|
+
const { version } = (await import("./chunks/package-DzXqX5Oe.mjs").then((n) => n.n)).default;
|
|
9670
10356
|
let exportFs = fs;
|
|
9671
10357
|
let exportLibrary = libraryProvider();
|
|
9672
10358
|
let optimizeReport;
|
|
9673
10359
|
let closeCodec;
|
|
9674
10360
|
if (boolOpt(options, "optimize")) {
|
|
9675
|
-
const { optimizedExportSources } = await import("./chunks/assets-
|
|
10361
|
+
const { optimizedExportSources } = await import("./chunks/assets-DdzHgVcn.mjs").then((n) => n.d);
|
|
9676
10362
|
let codec;
|
|
9677
|
-
if ((await import("./chunks/browser-
|
|
9678
|
-
const c = await (await import("./chunks/imageCodec-
|
|
10363
|
+
if ((await import("./chunks/browser-nFaRUETt.mjs")).findBrowser()) {
|
|
10364
|
+
const c = await (await import("./chunks/imageCodec-DXxqkEQA.mjs")).openImageCodec({ log });
|
|
9679
10365
|
codec = c.codec;
|
|
9680
10366
|
closeCodec = c.close;
|
|
9681
10367
|
} else warnings.push("--optimize: no Chrome found, textures were not resized (geometry was compressed).");
|
|
@@ -9767,7 +10453,7 @@ function issuesLine(issues) {
|
|
|
9767
10453
|
return issues.map((i) => ` ${i.severity === "error" ? "✗" : i.severity === "warning" ? "!" : "·"} ${i.path}: ${i.message}${i.hint ? ` (${i.hint})` : ""}`).join("\n");
|
|
9768
10454
|
}
|
|
9769
10455
|
async function runPatch(io, options, fs, ops, human, opts = {}) {
|
|
9770
|
-
const { patchScene, replacedCollections, getScene } = await import("./chunks/scene-
|
|
10456
|
+
const { patchScene, replacedCollections, getScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
9771
10457
|
const dry = await patchScene(fs, ops, { dryRun: true });
|
|
9772
10458
|
if (errorsOf(dry.issues).length) throw validationError(dry.issues, dry.plan);
|
|
9773
10459
|
if (dry.plan.empty) return printResult(io, {
|
|
@@ -9861,7 +10547,7 @@ var sceneCommand = {
|
|
|
9861
10547
|
}
|
|
9862
10548
|
const fs = projectFs(options);
|
|
9863
10549
|
if (action === "get") {
|
|
9864
|
-
const { getScene } = await import("./chunks/scene-
|
|
10550
|
+
const { getScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
9865
10551
|
const scene = await getScene(fs);
|
|
9866
10552
|
const path = strOpt(options, "path");
|
|
9867
10553
|
if (!path) return printResult(io, scene, () => JSON.stringify(scene, null, 2));
|
|
@@ -9874,13 +10560,13 @@ var sceneCommand = {
|
|
|
9874
10560
|
}, () => JSON.stringify(value, null, 2));
|
|
9875
10561
|
}
|
|
9876
10562
|
if (action === "summary") {
|
|
9877
|
-
const [{ getScene, summarizeScene }] = await Promise.all([import("./chunks/scene-
|
|
10563
|
+
const [{ getScene, summarizeScene }] = await Promise.all([import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a)]);
|
|
9878
10564
|
const summary = summarizeScene(await getScene(fs));
|
|
9879
10565
|
return printResult(io, summary, () => JSON.stringify(summary, null, 2));
|
|
9880
10566
|
}
|
|
9881
10567
|
if (action === "apply") {
|
|
9882
10568
|
const next = jsonInput(options, rest, "the scene", "--file scene.json");
|
|
9883
|
-
const { applyScene } = await import("./chunks/scene-
|
|
10569
|
+
const { applyScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
9884
10570
|
const dry = await applyScene(fs, next, { dryRun: true });
|
|
9885
10571
|
if (errorsOf(dry.issues).length) throw validationError(dry.issues, dry.plan);
|
|
9886
10572
|
if (dry.plan.empty) return printResult(io, {
|
|
@@ -10084,7 +10770,7 @@ var objectCommand = {
|
|
|
10084
10770
|
const fs = projectFs(options);
|
|
10085
10771
|
const index = numOpt(options, "index");
|
|
10086
10772
|
if (action === "list" || action === "get") {
|
|
10087
|
-
const { listObjects, getObject } = await import("./chunks/objects-
|
|
10773
|
+
const { listObjects, getObject } = await import("./chunks/objects-DvzrcVmK.mjs").then((n) => n.r);
|
|
10088
10774
|
if (action === "list") {
|
|
10089
10775
|
const rows = await listObjects(fs);
|
|
10090
10776
|
return printResult(io, { objects: rows }, () => table(rows.map((r) => ({
|
|
@@ -10225,7 +10911,7 @@ var timelineCommand = {
|
|
|
10225
10911
|
const [action = "get", ...rest] = positionals;
|
|
10226
10912
|
const fs = projectFs(options);
|
|
10227
10913
|
if (action === "get") {
|
|
10228
|
-
const { getScene } = await import("./chunks/scene-
|
|
10914
|
+
const { getScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
10229
10915
|
const timeline = (await getScene(fs)).timeline ?? null;
|
|
10230
10916
|
return printResult(io, { timeline }, () => timeline ? JSON.stringify(timeline, null, 2) : "No timeline.");
|
|
10231
10917
|
}
|
|
@@ -10236,7 +10922,7 @@ var timelineCommand = {
|
|
|
10236
10922
|
value: jsonInput(options, rest, "the timeline", "--file timeline.json with {\"duration\":4,\"loop\":true,\"tracks\":[]}")
|
|
10237
10923
|
}], "Replace the timeline", { destructive: true });
|
|
10238
10924
|
const ops = [];
|
|
10239
|
-
const { getScene } = await import("./chunks/scene-
|
|
10925
|
+
const { getScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
10240
10926
|
const has = !!(await getScene(fs)).timeline;
|
|
10241
10927
|
const duration = numOpt(options, "duration");
|
|
10242
10928
|
const loop = strOpt(options, "loop");
|
|
@@ -10307,7 +10993,7 @@ function runtimeIssueToIssue(i) {
|
|
|
10307
10993
|
function nodeHost(fs) {
|
|
10308
10994
|
return {
|
|
10309
10995
|
...fs ? { async render(opts) {
|
|
10310
|
-
const { renderProject } = await import("./chunks/render-
|
|
10996
|
+
const { renderProject } = await import("./chunks/render-CCKciCgu.mjs");
|
|
10311
10997
|
const r = await renderProject({
|
|
10312
10998
|
projectDir: fs.root,
|
|
10313
10999
|
frames: opts.frames?.length ? opts.frames.join(",") : void 0,
|
|
@@ -10315,7 +11001,7 @@ function nodeHost(fs) {
|
|
|
10315
11001
|
size: opts.size,
|
|
10316
11002
|
sheet: opts.sheet ?? true,
|
|
10317
11003
|
outDir: opts.out ? fs.resolve(opts.out) : void 0,
|
|
10318
|
-
input: opts.input ? (await import("./chunks/render-
|
|
11004
|
+
input: opts.input ? (await import("./chunks/render-CCKciCgu.mjs")).parseInputScript(opts.input) : void 0,
|
|
10319
11005
|
previewWidth: opts.previewWidth,
|
|
10320
11006
|
isolate: opts.isolate,
|
|
10321
11007
|
bg: opts.bg,
|
|
@@ -10339,7 +11025,7 @@ function nodeHost(fs) {
|
|
|
10339
11025
|
};
|
|
10340
11026
|
} } : {},
|
|
10341
11027
|
...fs ? { async media(opts) {
|
|
10342
|
-
const render = await import("./chunks/render-
|
|
11028
|
+
const render = await import("./chunks/render-CCKciCgu.mjs");
|
|
10343
11029
|
const log = (m) => void process.stderr.write(`${m}\n`);
|
|
10344
11030
|
if (opts.format === "poster") {
|
|
10345
11031
|
const r = await render.renderPoster({
|
|
@@ -10387,6 +11073,7 @@ function nodeHost(fs) {
|
|
|
10387
11073
|
fps: opts.fps,
|
|
10388
11074
|
quality: opts.quality,
|
|
10389
11075
|
transparent: opts.transparent,
|
|
11076
|
+
preset: opts.preset,
|
|
10390
11077
|
write: false,
|
|
10391
11078
|
log
|
|
10392
11079
|
});
|
|
@@ -10399,7 +11086,8 @@ function nodeHost(fs) {
|
|
|
10399
11086
|
size: {
|
|
10400
11087
|
width: r.size.width,
|
|
10401
11088
|
height: r.size.height
|
|
10402
|
-
}
|
|
11089
|
+
},
|
|
11090
|
+
...r.notes ? { notes: r.notes } : {}
|
|
10403
11091
|
};
|
|
10404
11092
|
}
|
|
10405
11093
|
const r = await render.renderVideo({
|
|
@@ -10409,6 +11097,7 @@ function nodeHost(fs) {
|
|
|
10409
11097
|
fps: opts.fps,
|
|
10410
11098
|
format: opts.video,
|
|
10411
11099
|
quality: opts.quality,
|
|
11100
|
+
preset: opts.preset,
|
|
10412
11101
|
log
|
|
10413
11102
|
});
|
|
10414
11103
|
return {
|
|
@@ -10420,7 +11109,8 @@ function nodeHost(fs) {
|
|
|
10420
11109
|
size: {
|
|
10421
11110
|
width: r.size.width,
|
|
10422
11111
|
height: r.size.height
|
|
10423
|
-
}
|
|
11112
|
+
},
|
|
11113
|
+
...r.notes ? { notes: r.notes } : {}
|
|
10424
11114
|
};
|
|
10425
11115
|
} } : {},
|
|
10426
11116
|
runtimeFiles: async (format) => readRuntimeFiles(format),
|
|
@@ -10431,13 +11121,17 @@ function nodeHost(fs) {
|
|
|
10431
11121
|
},
|
|
10432
11122
|
inflate: (data) => new Uint8Array(inflateRawSync(data)),
|
|
10433
11123
|
async withImageCodec(fn) {
|
|
10434
|
-
const { withImageCodec } = await import("./chunks/imageCodec-
|
|
11124
|
+
const { withImageCodec } = await import("./chunks/imageCodec-DXxqkEQA.mjs");
|
|
10435
11125
|
return withImageCodec(fn, { log: (m) => void process.stderr.write(`${m}\n`) });
|
|
10436
11126
|
},
|
|
10437
11127
|
async withDepthEstimator(fn) {
|
|
10438
|
-
const { withDepthEstimator } = await import("./chunks/depth-
|
|
11128
|
+
const { withDepthEstimator } = await import("./chunks/depth-Bf7cHwod.mjs");
|
|
10439
11129
|
return withDepthEstimator(fn, { log: (m) => void process.stderr.write(`${m}\n`) });
|
|
10440
11130
|
},
|
|
11131
|
+
async withPixelCodec(fn) {
|
|
11132
|
+
const { withPixelCodec } = await import("./chunks/imageCodec-DXxqkEQA.mjs");
|
|
11133
|
+
return withPixelCodec(fn, { log: (m) => void process.stderr.write(`${m}\n`) });
|
|
11134
|
+
},
|
|
10441
11135
|
deflate: (data) => new Uint8Array(deflateSync(data)),
|
|
10442
11136
|
readLocalFile: async (path) => new Uint8Array(readFileSync(resolve(path)))
|
|
10443
11137
|
};
|
|
@@ -10450,7 +11144,7 @@ function toolContext(fs) {
|
|
|
10450
11144
|
};
|
|
10451
11145
|
}
|
|
10452
11146
|
async function listTools(opts = {}) {
|
|
10453
|
-
const { listAiTools } = await import("./chunks/tools-
|
|
11147
|
+
const { listAiTools } = await import("./chunks/tools-Vs74Xopx.mjs");
|
|
10454
11148
|
const host = nodeHost(null);
|
|
10455
11149
|
return listAiTools(opts.render === false ? host : {
|
|
10456
11150
|
...host,
|
|
@@ -10463,7 +11157,7 @@ async function listTools(opts = {}) {
|
|
|
10463
11157
|
}));
|
|
10464
11158
|
}
|
|
10465
11159
|
async function callTool(fs, name, input) {
|
|
10466
|
-
const { callAiTool } = await import("./chunks/tools-
|
|
11160
|
+
const { callAiTool } = await import("./chunks/tools-Vs74Xopx.mjs");
|
|
10467
11161
|
return callAiTool(toolContext(fs), name, input);
|
|
10468
11162
|
}
|
|
10469
11163
|
function previewImages(name, result, root = ".") {
|
|
@@ -11258,7 +11952,7 @@ var mcpCommand = {
|
|
|
11258
11952
|
const dir = projectDir(options);
|
|
11259
11953
|
const fs = new NodeFs(dir);
|
|
11260
11954
|
const log = (msg) => void process.stderr.write(`${msg}\n`);
|
|
11261
|
-
const { createMcpServer, serveStdio } = await import("./chunks/server-
|
|
11955
|
+
const { createMcpServer, serveStdio } = await import("./chunks/server-CLvLORgA.mjs");
|
|
11262
11956
|
const server = createMcpServer(mcpOptions(fs, readOnly, await listTools()));
|
|
11263
11957
|
log(`[agent3d mcp] project ${dir}${readOnly ? " (read-only)" : ""} on stdio — ${server.toolNames().length} tools`);
|
|
11264
11958
|
await serveStdio(server, process.stdin, (line) => process.stdout.write(line + "\n"), log);
|
|
@@ -11290,7 +11984,7 @@ function mcpOptions(fs, readOnly, tools) {
|
|
|
11290
11984
|
description: "Compact outline of the scene: objects, lights, camera, timeline, scripts.",
|
|
11291
11985
|
mimeType: "application/json",
|
|
11292
11986
|
read: async () => {
|
|
11293
|
-
const { getScene, summarizeScene } = await import("./chunks/scene-
|
|
11987
|
+
const { getScene, summarizeScene } = await import("./chunks/scene-DSjsun-3.mjs").then((n) => n.a);
|
|
11294
11988
|
return summarizeScene(await getScene(fs));
|
|
11295
11989
|
}
|
|
11296
11990
|
},
|
|
@@ -11443,4 +12137,4 @@ main(process.argv.slice(2)).then(exitWhenFlushed, (err) => {
|
|
|
11443
12137
|
console.error(err);
|
|
11444
12138
|
exitWhenFlushed(1);
|
|
11445
12139
|
});
|
|
11446
|
-
export {
|
|
12140
|
+
export { GENERATORS as A, validationError$1 as B, validateScene as C, isLibraryRef as D, findLibraryAsset as E, KB as F, ortDir as G, normalizePath as H, OpsError as I, CliError as J, runtimeBuilt as K, hasErrors as L, parseAspect$1 as M, isValidId as N, libraryId as O, slugify as P, nowIso as R, TARGET_KINDS$1 as S, postfxCost as T, ORT_FILES as U, writeJson as V, libraryDir as W, toCliError as Y, readSceneFile as _, SOCIAL_PRESET_IDS as a, DEFAULT_BUDGET_KB as b, parseSocialPreset as c, listTemplates as d, ASSET_MANIFEST_FILE as f, loadProject as g, createProject as h, SOCIAL_PRESETS as i, catalogEntry as j, CATALOG as k, socialDuration as l, SCENE_FILE as m, sendText as n, coverScene as o, MANIFEST_FILE as p, runtimeDir as q, startLocalServer as r, imageHeaderSize as s, mimeOf as t, findTemplate as u, saveScene as v, expandPostFx as w, MATERIAL_TEXTURE_SLOTS as x, DEFAULT_ASPECT as y, readJsonOr as z };
|