@fleox/agent3d 0.4.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -14
- package/changelog.json +24 -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-Bn7PKfXn.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-DICv7P37.js +2 -0
- package/dist/studio/assets/camera-HsMeC1mn.js +2 -0
- package/dist/studio/assets/catalog-DDg904x2.js +1 -0
- package/dist/studio/assets/{editor-DzyukvQl.js → editor-BZLIZJC8.js} +1 -1
- package/dist/studio/assets/{extrude-9bG8hr2C.js → extrude-BpJda0hq.js} +1 -1
- package/dist/studio/assets/game-DnnuBk26.js +19 -0
- package/dist/studio/assets/{generators-BuVeRXnC.js → generators-C4n9MsXd.js} +1 -1
- package/dist/studio/assets/index-D-TPNQMQ.css +1 -0
- package/dist/studio/assets/index-cDbmaVDl.js +479 -0
- package/dist/studio/assets/model-CkPfLOl0.js +2 -0
- package/dist/studio/assets/params-BZqUA__U.js +1 -0
- package/dist/studio/assets/photo-CPGGCRa-.js +526 -0
- package/dist/studio/assets/{physicsHost-z9qn_mpg.js → physicsHost-EkPuIy04.js} +1 -1
- package/dist/studio/assets/{postfx-B3jDEaEK.js → postfx-Dp7mgfGJ.js} +2 -2
- package/dist/studio/assets/rolldown-runtime-4tVxZq34.js +1 -0
- package/dist/studio/assets/runtime-ByR4qfyV.js +572 -0
- package/dist/studio/assets/{shaders-bFhELLmD.js → shaders-DoRMwJE_.js} +1 -1
- package/dist/studio/assets/svg-n3rkKAm5.js +2 -0
- package/dist/studio/assets/text-BkPPDghK.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
|
@@ -5,9 +5,9 @@ __a3dRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
7
|
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { F as KB, H as normalizePath, I as OpsError, P as slugify, R as nowIso, V as writeJson, _ as readSceneFile, f as ASSET_MANIFEST_FILE, v as saveScene, z as readJsonOr } from "../agent3d.mjs";
|
|
9
9
|
import { t as closest } from "./suggest-Cpcgv1RP.mjs";
|
|
10
|
-
import { a as collectAssetRefs, i as planTextureSizes, l as visitAssetRefs, n as imageHeader, s as kindFromPath } from "./optimizeSizing-
|
|
10
|
+
import { a as collectAssetRefs, i as planTextureSizes, l as visitAssetRefs, n as imageHeader, s as kindFromPath } from "./optimizeSizing-Dd8vaSnE.mjs";
|
|
11
11
|
import { i as modelInfo, r as modelFileBounds } from "./gltf-f_f0-OiV.mjs";
|
|
12
12
|
// src/ops/zip.ts
|
|
13
13
|
var ZipError = class extends Error {
|
|
@@ -4,7 +4,7 @@ import { dirname as __a3dDirname, delimiter, join } from "node:path";
|
|
|
4
4
|
__a3dRequire(import.meta.url);
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
|
-
import {
|
|
7
|
+
import { J as CliError } from "../agent3d.mjs";
|
|
8
8
|
import { existsSync, mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
9
9
|
import { homedir, tmpdir } from "node:os";
|
|
10
10
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -4,7 +4,7 @@ import { dirname as __a3dDirname } from "node:path";
|
|
|
4
4
|
__a3dRequire(import.meta.url);
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
|
-
import {
|
|
7
|
+
import { J as CliError } from "../agent3d.mjs";
|
|
8
8
|
// agent/render/cdp.ts
|
|
9
9
|
var DEFAULT_TIMEOUT_MS = Number(process.env.AGENT3D_CDP_TIMEOUT_MS) || 6e4;
|
|
10
10
|
var CdpError = class extends Error {
|
|
@@ -5,11 +5,12 @@ __a3dRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
7
|
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { A as GENERATORS, C as validateScene, D as isLibraryRef, E as findLibraryAsset, F as KB, O as libraryId, T as postfxCost, _ as readSceneFile, b as DEFAULT_BUDGET_KB, f as ASSET_MANIFEST_FILE, j as catalogEntry, k as CATALOG, m as SCENE_FILE, w as expandPostFx, z as readJsonOr } from "../agent3d.mjs";
|
|
9
9
|
import { t as closest } from "./suggest-Cpcgv1RP.mjs";
|
|
10
10
|
import { o as walkObjects } from "./tree-CqSj-o8T.mjs";
|
|
11
11
|
import { i as modelInfo } from "./gltf-f_f0-OiV.mjs";
|
|
12
|
-
import { a as collectAssetRefs, n as imageHeader, o as gltfDependencies, r as optimizeSuggestions } from "./optimizeSizing-
|
|
12
|
+
import { a as collectAssetRefs, n as imageHeader, o as gltfDependencies, r as optimizeSuggestions } from "./optimizeSizing-Dd8vaSnE.mjs";
|
|
13
|
+
import { t as photoDepthIssues } from "./photoPlacement-D-k3mD0T.mjs";
|
|
13
14
|
// src/ops/budget.ts
|
|
14
15
|
function evalCost(formula, vars) {
|
|
15
16
|
const src = formula.replace(/~/g, "");
|
|
@@ -855,6 +856,16 @@ async function photoIssues(fs, scene) {
|
|
|
855
856
|
hint: `Regenerate it from this image: \`agent3d assets depth ${String(o.src)}\` (or crop both the same way).`
|
|
856
857
|
});
|
|
857
858
|
}
|
|
859
|
+
for (const k of ["plate", "plateDepth"]) {
|
|
860
|
+
const f = await header(o[k]).catch(() => null);
|
|
861
|
+
if (src?.h && f?.h && src.h.height > 0 && f.h.height > 0 && Math.abs(src.h.width / src.h.height - f.h.width / f.h.height) / (src.h.width / src.h.height) > .02) out.push({
|
|
862
|
+
severity: "warning",
|
|
863
|
+
code: "photo-plate-aspect",
|
|
864
|
+
path: `${at}.${k}`,
|
|
865
|
+
message: `${k === "plate" ? "Plate" : "Plate depth"} "${String(o[k])}" is ${f.h.width}x${f.h.height} but the photo is ${src.h.width}x${src.h.height}: the plate will not line up with the picture.`,
|
|
866
|
+
hint: `Rebuild it from this image: \`agent3d assets plate ${String(o.src)}\`.`
|
|
867
|
+
});
|
|
868
|
+
}
|
|
858
869
|
if (depth?.h && depth.h.mimeType === "image/jpeg") out.push({
|
|
859
870
|
severity: "info",
|
|
860
871
|
code: "photo-depth-lossy",
|
|
@@ -863,6 +874,7 @@ async function photoIssues(fs, scene) {
|
|
|
863
874
|
hint: `Use a PNG depth map (\`agent3d assets depth ${String(o.src)}\` writes one).`
|
|
864
875
|
});
|
|
865
876
|
}
|
|
877
|
+
out.push(...photoDepthIssues(scene));
|
|
866
878
|
return out;
|
|
867
879
|
}
|
|
868
880
|
function textureFiles(scene) {
|
|
@@ -4,10 +4,10 @@ import { dirname as __a3dDirname, dirname, join, resolve } from "node:path";
|
|
|
4
4
|
__a3dRequire(import.meta.url);
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
|
-
import { i as ensureDepthModel, t as DEPTH_MODEL } from "./depth-
|
|
8
|
-
import {
|
|
9
|
-
import { launchBrowser, requireBrowser } from "./browser-
|
|
10
|
-
import { t as CdpClient } from "./cdp-
|
|
7
|
+
import { i as ensureDepthModel, t as DEPTH_MODEL } from "./depth-DEaogEAi.mjs";
|
|
8
|
+
import { G as ortDir, J as CliError, U as ORT_FILES, r as startLocalServer, t as mimeOf } from "../agent3d.mjs";
|
|
9
|
+
import { launchBrowser, requireBrowser } from "./browser-nFaRUETt.mjs";
|
|
10
|
+
import { t as CdpClient } from "./cdp-6vF_gP-H.mjs";
|
|
11
11
|
import { createReadStream, existsSync, mkdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { homedir } from "node:os";
|
|
13
13
|
// agent/render/depth.ts
|
|
@@ -5,120 +5,10 @@ __a3dRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
7
|
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { c as readAssetManifest,
|
|
10
|
-
import { n as imageHeader } from "./optimizeSizing-
|
|
11
|
-
|
|
12
|
-
async function deflateZlib(data, deflate) {
|
|
13
|
-
if (deflate) return deflate(data);
|
|
14
|
-
const CS = globalThis.CompressionStream;
|
|
15
|
-
if (!CS) throw new Error("No deflate available: pass `deflate` (CompressionStream is missing).");
|
|
16
|
-
const stream = new Blob([data]).stream().pipeThrough(new CS("deflate"));
|
|
17
|
-
return new Uint8Array(await new Response(stream).arrayBuffer());
|
|
18
|
-
}
|
|
19
|
-
async function encodePng(rgba, width, height, opts = {}) {
|
|
20
|
-
if (rgba.length !== width * height * 4) throw new Error(`encodePng: expected ${width * height * 4} bytes, got ${rgba.length}`);
|
|
21
|
-
let channels = opts.channels ?? "auto";
|
|
22
|
-
if (channels === "auto") {
|
|
23
|
-
let grey = true;
|
|
24
|
-
let opaque = true;
|
|
25
|
-
for (let i = 0; i < rgba.length && (grey || opaque); i += 4) {
|
|
26
|
-
if (rgba[i] !== rgba[i + 1] || rgba[i] !== rgba[i + 2]) grey = false;
|
|
27
|
-
if (rgba[i + 3] !== 255) opaque = false;
|
|
28
|
-
}
|
|
29
|
-
channels = grey ? opaque ? 1 : 2 : opaque ? 3 : 4;
|
|
30
|
-
}
|
|
31
|
-
const colorType = {
|
|
32
|
-
1: 0,
|
|
33
|
-
2: 4,
|
|
34
|
-
3: 2,
|
|
35
|
-
4: 6
|
|
36
|
-
}[channels];
|
|
37
|
-
const stride = width * channels;
|
|
38
|
-
const raw = new Uint8Array((stride + 1) * height);
|
|
39
|
-
const row = new Uint8Array(stride);
|
|
40
|
-
const prev = new Uint8Array(stride);
|
|
41
|
-
const cand = new Uint8Array(stride);
|
|
42
|
-
for (let y = 0; y < height; y++) {
|
|
43
|
-
for (let x = 0; x < width; x++) {
|
|
44
|
-
const s = (y * width + x) * 4;
|
|
45
|
-
const d = x * channels;
|
|
46
|
-
if (channels === 1) row[d] = rgba[s];
|
|
47
|
-
else if (channels === 2) row[d] = rgba[s], row[d + 1] = rgba[s + 3];
|
|
48
|
-
else for (let c = 0; c < channels; c++) row[d + c] = rgba[s + c];
|
|
49
|
-
}
|
|
50
|
-
let best = 0;
|
|
51
|
-
let bestScore = Infinity;
|
|
52
|
-
const out = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
|
|
53
|
-
for (let f = 0; f < 5; f++) {
|
|
54
|
-
let score = 0;
|
|
55
|
-
for (let i = 0; i < stride; i++) {
|
|
56
|
-
const a = i >= channels ? row[i - channels] : 0;
|
|
57
|
-
const b = prev[i];
|
|
58
|
-
const c = i >= channels ? prev[i - channels] : 0;
|
|
59
|
-
let p;
|
|
60
|
-
if (f === 0) p = 0;
|
|
61
|
-
else if (f === 1) p = a;
|
|
62
|
-
else if (f === 2) p = b;
|
|
63
|
-
else if (f === 3) p = a + b >> 1;
|
|
64
|
-
else {
|
|
65
|
-
const pa = Math.abs(b - c);
|
|
66
|
-
const pb = Math.abs(a - c);
|
|
67
|
-
const pc = Math.abs(a + b - 2 * c);
|
|
68
|
-
p = pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
|
|
69
|
-
}
|
|
70
|
-
const v = row[i] - p & 255;
|
|
71
|
-
cand[i] = v;
|
|
72
|
-
score += v < 128 ? v : 256 - v;
|
|
73
|
-
if (score >= bestScore) break;
|
|
74
|
-
}
|
|
75
|
-
if (score < bestScore) {
|
|
76
|
-
bestScore = score;
|
|
77
|
-
best = f;
|
|
78
|
-
out.set(cand);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
raw[y * (stride + 1)] = best;
|
|
82
|
-
prev.set(row);
|
|
83
|
-
}
|
|
84
|
-
const idat = await deflateZlib(raw, opts.deflate);
|
|
85
|
-
const ihdr = /* @__PURE__ */ new Uint8Array(13);
|
|
86
|
-
const dv = new DataView(ihdr.buffer);
|
|
87
|
-
dv.setUint32(0, width);
|
|
88
|
-
dv.setUint32(4, height);
|
|
89
|
-
ihdr[8] = 8;
|
|
90
|
-
ihdr[9] = colorType;
|
|
91
|
-
const chunks = [
|
|
92
|
-
chunk("IHDR", ihdr),
|
|
93
|
-
chunk("IDAT", idat),
|
|
94
|
-
chunk("IEND", /* @__PURE__ */ new Uint8Array(0))
|
|
95
|
-
];
|
|
96
|
-
const sig = [
|
|
97
|
-
137,
|
|
98
|
-
80,
|
|
99
|
-
78,
|
|
100
|
-
71,
|
|
101
|
-
13,
|
|
102
|
-
10,
|
|
103
|
-
26,
|
|
104
|
-
10
|
|
105
|
-
];
|
|
106
|
-
const total = 8 + chunks.reduce((n, c) => n + c.length, 0);
|
|
107
|
-
const png = new Uint8Array(total);
|
|
108
|
-
png.set(sig, 0);
|
|
109
|
-
let o = 8;
|
|
110
|
-
for (const c of chunks) png.set(c, o), o += c.length;
|
|
111
|
-
return png;
|
|
112
|
-
}
|
|
113
|
-
function chunk(type, data) {
|
|
114
|
-
const out = new Uint8Array(12 + data.length);
|
|
115
|
-
const dv = new DataView(out.buffer);
|
|
116
|
-
dv.setUint32(0, data.length);
|
|
117
|
-
for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);
|
|
118
|
-
out.set(data, 8);
|
|
119
|
-
dv.setUint32(8 + data.length, crc32(out.subarray(4, 8 + data.length)));
|
|
120
|
-
return out;
|
|
121
|
-
}
|
|
8
|
+
import { D as isLibraryRef, E as findLibraryAsset, H as normalizePath, I as OpsError, O as libraryId } from "../agent3d.mjs";
|
|
9
|
+
import { c as readAssetManifest, t as addAsset } from "./assets-DdzHgVcn.mjs";
|
|
10
|
+
import { n as imageHeader } from "./optimizeSizing-Dd8vaSnE.mjs";
|
|
11
|
+
import { t as encodePng } from "./pngEncode-BMc3U9QC.mjs";
|
|
122
12
|
// src/ops/depth.ts
|
|
123
13
|
var depth_exports = /* @__PURE__ */ __exportAll({
|
|
124
14
|
checkDepthRequest: () => checkDepthRequest,
|
|
@@ -5,11 +5,11 @@ __a3dRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
7
|
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { B as validationError, C as validateScene, D as isLibraryRef, E as findLibraryAsset, F as KB, I as OpsError, L as hasErrors, M as parseAspect, O as libraryId, P as slugify, _ as readSceneFile, b as DEFAULT_BUDGET_KB, p as MANIFEST_FILE, z as readJsonOr } from "../agent3d.mjs";
|
|
9
9
|
import { n as clone } from "./jsonPath-DUCe1JpS.mjs";
|
|
10
|
-
import { t as attributionText } from "./check-
|
|
11
|
-
import { c as mimeFromPath, l as visitAssetRefs, o as gltfDependencies } from "./optimizeSizing-
|
|
12
|
-
import { c as readAssetManifest, m as crc32 } from "./assets-
|
|
10
|
+
import { t as attributionText } from "./check-E7GdPxTt.mjs";
|
|
11
|
+
import { c as mimeFromPath, l as visitAssetRefs, o as gltfDependencies } from "./optimizeSizing-Dd8vaSnE.mjs";
|
|
12
|
+
import { c as readAssetManifest, m as crc32 } from "./assets-DdzHgVcn.mjs";
|
|
13
13
|
// src/core/data.ts
|
|
14
14
|
var DATA_PLACEHOLDER = /\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;
|
|
15
15
|
function lookup(data, path) {
|
|
@@ -104,6 +104,10 @@ function liteRuntimeEligibility(scene) {
|
|
|
104
104
|
no(sc !== void 0 && (typeof sc === "number" ? !(sc > 0) : !Array.isArray(sc) || !(sc[0] > 0 && sc[1] > 0)), "photo scale is not positive");
|
|
105
105
|
no(p.material?.color !== void 0 && !(typeof p.material.color === "string" && HEX.test(p.material.color)), "photo material.color is not a #hex colour");
|
|
106
106
|
no(typeof p.src !== "string" || !p.src, "photo has no src");
|
|
107
|
+
for (const [id, fx] of Object.entries(p.effects ?? {})) {
|
|
108
|
+
const c = fx?.color;
|
|
109
|
+
no(c !== void 0 && !(typeof c === "string" && HEX.test(c)), `photo effects.${id}.color is not a #hex colour`);
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
return reasons.length ? {
|
|
109
113
|
ok: false,
|
|
@@ -4,9 +4,9 @@ import { dirname as __a3dDirname } from "node:path";
|
|
|
4
4
|
__a3dRequire(import.meta.url);
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
|
-
import {
|
|
8
|
-
import { launchBrowser, requireBrowser } from "./browser-
|
|
9
|
-
import { t as CdpClient } from "./cdp-
|
|
7
|
+
import { J as CliError } from "../agent3d.mjs";
|
|
8
|
+
import { launchBrowser, requireBrowser } from "./browser-nFaRUETt.mjs";
|
|
9
|
+
import { t as CdpClient } from "./cdp-6vF_gP-H.mjs";
|
|
10
10
|
// agent/render/imageCodec.ts
|
|
11
11
|
var PAGE_FN = `async function (b64, mime, maxSize, quality, format, allowJpeg) {
|
|
12
12
|
const bin = atob(b64);
|
|
@@ -36,6 +36,23 @@ var PAGE_FN = `async function (b64, mime, maxSize, quality, format, allowJpeg) {
|
|
|
36
36
|
for (let i = 0; i < buf.length; i += 0x8000) out += String.fromCharCode.apply(null, buf.subarray(i, i + 0x8000));
|
|
37
37
|
return { b64: btoa(out), mimeType: blob.type, width: w, height: h, srcWidth: bmp.width, srcHeight: bmp.height, hasAlpha };
|
|
38
38
|
}`;
|
|
39
|
+
var DECODE_FN = `async function (b64, mime, maxSize) {
|
|
40
|
+
const bin = atob(b64);
|
|
41
|
+
const bytes = new Uint8Array(bin.length);
|
|
42
|
+
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
|
|
43
|
+
const bmp = await createImageBitmap(new Blob([bytes], { type: mime }), { colorSpaceConversion: "none", premultiplyAlpha: "none" });
|
|
44
|
+
const s = Math.min(1, maxSize / Math.max(bmp.width, bmp.height));
|
|
45
|
+
const w = Math.max(1, Math.round(bmp.width * s)), h = Math.max(1, Math.round(bmp.height * s));
|
|
46
|
+
const canvas = new OffscreenCanvas(w, h);
|
|
47
|
+
const g = canvas.getContext("2d", { willReadFrequently: true });
|
|
48
|
+
g.imageSmoothingEnabled = true;
|
|
49
|
+
g.imageSmoothingQuality = "high";
|
|
50
|
+
g.drawImage(bmp, 0, 0, w, h);
|
|
51
|
+
const buf = new Uint8Array(g.getImageData(0, 0, w, h).data.buffer);
|
|
52
|
+
let out = "";
|
|
53
|
+
for (let i = 0; i < buf.length; i += 0x8000) out += String.fromCharCode.apply(null, buf.subarray(i, i + 0x8000));
|
|
54
|
+
return { b64: btoa(out), width: w, height: h };
|
|
55
|
+
}`;
|
|
39
56
|
async function openImageCodec(opts = {}) {
|
|
40
57
|
const info = requireBrowser();
|
|
41
58
|
let browser = null;
|
|
@@ -85,11 +102,43 @@ async function openImageCodec(opts = {}) {
|
|
|
85
102
|
hasAlpha: v.hasAlpha
|
|
86
103
|
};
|
|
87
104
|
};
|
|
105
|
+
const decode = async (input) => {
|
|
106
|
+
const r = await page.send("Runtime.callFunctionOn", {
|
|
107
|
+
functionDeclaration: DECODE_FN,
|
|
108
|
+
objectId: windowId,
|
|
109
|
+
arguments: [
|
|
110
|
+
{ value: Buffer.from(input.bytes).toString("base64") },
|
|
111
|
+
{ value: input.mimeType },
|
|
112
|
+
{ value: input.maxSize }
|
|
113
|
+
],
|
|
114
|
+
awaitPromise: true,
|
|
115
|
+
returnByValue: true
|
|
116
|
+
}, 12e4);
|
|
117
|
+
if (r.exceptionDetails || !r.result.value) throw new CliError("image-decode", `Could not decode this ${input.mimeType} image: ${(r.exceptionDetails?.exception?.description ?? r.exceptionDetails?.text ?? "no result").split("\n")[0]}`, "The file may be corrupt or in an unsupported format (use .jpg, .png or .webp).");
|
|
118
|
+
const v = r.result.value;
|
|
119
|
+
return {
|
|
120
|
+
data: new Uint8Array(Buffer.from(v.b64, "base64")),
|
|
121
|
+
width: v.width,
|
|
122
|
+
height: v.height
|
|
123
|
+
};
|
|
124
|
+
};
|
|
88
125
|
return {
|
|
89
126
|
codec,
|
|
127
|
+
decode,
|
|
90
128
|
close
|
|
91
129
|
};
|
|
92
130
|
}
|
|
131
|
+
async function withPixelCodec(fn, opts = {}) {
|
|
132
|
+
const c = await openImageCodec(opts);
|
|
133
|
+
try {
|
|
134
|
+
return await fn({
|
|
135
|
+
decode: c.decode,
|
|
136
|
+
codec: c.codec
|
|
137
|
+
});
|
|
138
|
+
} finally {
|
|
139
|
+
await c.close();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
93
142
|
async function withImageCodec(fn, opts = {}) {
|
|
94
143
|
const c = await openImageCodec(opts);
|
|
95
144
|
try {
|
|
@@ -98,4 +147,4 @@ async function withImageCodec(fn, opts = {}) {
|
|
|
98
147
|
await c.close();
|
|
99
148
|
}
|
|
100
149
|
}
|
|
101
|
-
export { openImageCodec, withImageCodec };
|
|
150
|
+
export { openImageCodec, withImageCodec, withPixelCodec };
|
|
@@ -6,8 +6,8 @@ const __filename = __a3dPath(import.meta.url);
|
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
7
|
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
8
|
import { t as closest } from "./suggest-Cpcgv1RP.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { i as patchScene } from "./scene-
|
|
9
|
+
import { I as OpsError, _ as readSceneFile } from "../agent3d.mjs";
|
|
10
|
+
import { i as patchScene } from "./scene-DSjsun-3.mjs";
|
|
11
11
|
import { n as findObject, r as flattenObjects, t as allObjectIds } from "./tree-CqSj-o8T.mjs";
|
|
12
12
|
// src/ops/objects.ts
|
|
13
13
|
var objects_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -4,7 +4,7 @@ import { dirname as __a3dDirname } from "node:path";
|
|
|
4
4
|
__a3dRequire(import.meta.url);
|
|
5
5
|
const __filename = __a3dPath(import.meta.url);
|
|
6
6
|
__a3dDirname(__filename);
|
|
7
|
-
import {
|
|
7
|
+
import { D as isLibraryRef, E as findLibraryAsset, O as libraryId, k as CATALOG, x as MATERIAL_TEXTURE_SLOTS, y as DEFAULT_ASPECT } from "../agent3d.mjs";
|
|
8
8
|
import { o as walkObjects } from "./tree-CqSj-o8T.mjs";
|
|
9
9
|
import { r as modelFileBounds, t as glbJson } from "./gltf-f_f0-OiV.mjs";
|
|
10
10
|
// src/ops/refs.ts
|
|
@@ -49,6 +49,11 @@ function visitAssetRefs(scene, visit) {
|
|
|
49
49
|
const r = visit(o.depth, `${at}.depth`, "texture");
|
|
50
50
|
if (typeof r === "string") o.depth = r;
|
|
51
51
|
}
|
|
52
|
+
for (const k of ["plate", "plateDepth"]) {
|
|
53
|
+
if (typeof o[k] !== "string") continue;
|
|
54
|
+
const r = visit(o[k], `${at}.${k}`, "texture");
|
|
55
|
+
if (typeof r === "string") o[k] = r;
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
if (o.kind === "text") {
|
|
54
59
|
const font = typeof o.font === "string" && o.font ? o.font : "sans-bold";
|
|
@@ -444,6 +449,24 @@ async function planTextureSizes(fs, scene, ctx = {}) {
|
|
|
444
449
|
why: `depth map of photo "${o.id}" (smooth data, kept lossless) ≈ ${round(pixels)} px`
|
|
445
450
|
}, TEXTURE_TIERS, DEPTH_MIN_TIER, Math.min(DEPTH_MAX_TIER, max));
|
|
446
451
|
}
|
|
452
|
+
if (typeof o.plate === "string" && (ctx.includeLibrary || !isLibraryRef(o.plate))) {
|
|
453
|
+
const pixels = projected * MARGIN * PHOTO_ZOOM_MARGIN;
|
|
454
|
+
addUse(files, o.plate, {
|
|
455
|
+
at: `objects#${o.id}.plate`,
|
|
456
|
+
role: "color",
|
|
457
|
+
pixels: round(pixels),
|
|
458
|
+
why: `background plate of photo "${o.id}", sized like the photo ≈ ${round(projected)} px`
|
|
459
|
+
}, TEXTURE_TIERS, Math.min(PHOTO_MIN_TIER, max), max);
|
|
460
|
+
}
|
|
461
|
+
if (typeof o.plateDepth === "string" && (ctx.includeLibrary || !isLibraryRef(o.plateDepth))) {
|
|
462
|
+
const pixels = projected * ROLE_FACTOR.depth * MARGIN;
|
|
463
|
+
addUse(files, o.plateDepth, {
|
|
464
|
+
at: `objects#${o.id}.plateDepth`,
|
|
465
|
+
role: "depth",
|
|
466
|
+
pixels: round(pixels),
|
|
467
|
+
why: `plate depth of photo "${o.id}" (smooth data, kept lossless) ≈ ${round(pixels)} px`
|
|
468
|
+
}, TEXTURE_TIERS, DEPTH_MIN_TIER, Math.min(DEPTH_MAX_TIER, max));
|
|
469
|
+
}
|
|
447
470
|
}
|
|
448
471
|
const mat = o.material;
|
|
449
472
|
if (mat && typeof mat === "object") {
|
|
@@ -8,7 +8,7 @@ import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_exports = /* @__PURE__ */ __exportAll({ default: () => package_default });
|
|
10
10
|
var name = "@fleox/agent3d";
|
|
11
|
-
var version = "0.
|
|
11
|
+
var version = "0.5.2";
|
|
12
12
|
var package_default = {
|
|
13
13
|
name,
|
|
14
14
|
version,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createRequire as __a3dRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __a3dPath } from "node:url";
|
|
3
|
+
import { dirname as __a3dDirname } from "node:path";
|
|
4
|
+
__a3dRequire(import.meta.url);
|
|
5
|
+
const __filename = __a3dPath(import.meta.url);
|
|
6
|
+
__a3dDirname(__filename);
|
|
7
|
+
// src/core/photoDepth.ts
|
|
8
|
+
var clamp01 = (v, d) => typeof v === "number" && Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : d;
|
|
9
|
+
function photoDepthRange(strength, width) {
|
|
10
|
+
return Math.min(1, Math.max(0, strength)) * width * .25;
|
|
11
|
+
}
|
|
12
|
+
function resolved(p) {
|
|
13
|
+
const strength = clamp01(p.strength, .5);
|
|
14
|
+
const width = typeof p.width === "number" && p.width > 0 ? p.width : 4;
|
|
15
|
+
const focus = clamp01(p.focus, .5);
|
|
16
|
+
const D = p.mode !== "mesh" && typeof p.cameraDistance === "number" && p.cameraDistance > 0 && Number.isFinite(p.cameraDistance) ? p.cameraDistance : Infinity;
|
|
17
|
+
return {
|
|
18
|
+
range: photoDepthRange(strength, width),
|
|
19
|
+
focus,
|
|
20
|
+
D
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function photoDepthToZ(d, p) {
|
|
24
|
+
const { range, focus, D } = resolved(p);
|
|
25
|
+
const lin = (d - focus) * range;
|
|
26
|
+
if (!Number.isFinite(D)) return lin;
|
|
27
|
+
const u = lin / D;
|
|
28
|
+
return D * u / (1 + u);
|
|
29
|
+
}
|
|
30
|
+
// src/ops/photoPlacement.ts
|
|
31
|
+
var r2 = (v) => Math.round(v * 100) / 100;
|
|
32
|
+
function placedObjects(objects, base = [
|
|
33
|
+
0,
|
|
34
|
+
0,
|
|
35
|
+
0
|
|
36
|
+
], out = []) {
|
|
37
|
+
for (const o of objects ?? []) {
|
|
38
|
+
if (!o || typeof o !== "object") continue;
|
|
39
|
+
const p = Array.isArray(o.position) ? o.position : [
|
|
40
|
+
0,
|
|
41
|
+
0,
|
|
42
|
+
0
|
|
43
|
+
];
|
|
44
|
+
const world = [
|
|
45
|
+
base[0] + (Number(p[0]) || 0),
|
|
46
|
+
base[1] + (Number(p[1]) || 0),
|
|
47
|
+
base[2] + (Number(p[2]) || 0)
|
|
48
|
+
];
|
|
49
|
+
out.push({
|
|
50
|
+
def: o,
|
|
51
|
+
world
|
|
52
|
+
});
|
|
53
|
+
if (Array.isArray(o.children)) placedObjects(o.children, world, out);
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
function scaleZ(o) {
|
|
58
|
+
const s = o.scale;
|
|
59
|
+
if (typeof s === "number" && s > 0) return s;
|
|
60
|
+
if (Array.isArray(s) && typeof s[2] === "number" && s[2] > 0) return s[2];
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
function photoPlacement(scene, photo, world) {
|
|
64
|
+
if (!photo.depth) return null;
|
|
65
|
+
const sz = scaleZ(photo);
|
|
66
|
+
const cam = scene.camera;
|
|
67
|
+
let distance;
|
|
68
|
+
if (cam?.type !== "orthographic" && Array.isArray(cam?.position)) {
|
|
69
|
+
const t = Array.isArray(cam.target) ? cam.target : [
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
0
|
|
73
|
+
];
|
|
74
|
+
const f = [
|
|
75
|
+
t[0] - cam.position[0],
|
|
76
|
+
t[1] - cam.position[1],
|
|
77
|
+
t[2] - cam.position[2]
|
|
78
|
+
];
|
|
79
|
+
const len = Math.hypot(f[0], f[1], f[2]) || 1;
|
|
80
|
+
const d = ((world[0] - cam.position[0]) * f[0] + (world[1] - cam.position[1]) * f[1] + (world[2] - cam.position[2]) * f[2]) / len;
|
|
81
|
+
if (d > 0) distance = d / sz;
|
|
82
|
+
}
|
|
83
|
+
const params = {
|
|
84
|
+
mode: photo.mode ?? "parallax",
|
|
85
|
+
strength: photo.strength,
|
|
86
|
+
width: photo.width,
|
|
87
|
+
focus: photo.focus,
|
|
88
|
+
cameraDistance: distance
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
id: photo.id,
|
|
92
|
+
occlude: photo.occlude === true,
|
|
93
|
+
zFar: r2(world[2] + photoDepthToZ(0, params) * sz),
|
|
94
|
+
zFocus: r2(world[2]),
|
|
95
|
+
zNear: r2(world[2] + photoDepthToZ(1, params) * sz),
|
|
96
|
+
position: world
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function photoDepthIssues(scene) {
|
|
100
|
+
const out = [];
|
|
101
|
+
const content = placedObjects(scene.objects).filter(({ def }) => def.kind !== "photo" && def.kind !== "group" && def.visible !== false && !def.attach);
|
|
102
|
+
for (const pl of photoPlacements(scene)) {
|
|
103
|
+
const at = `objects#${pl.id}.occlude`;
|
|
104
|
+
const range = `world z ${pl.zFar} (depth 0, far) … ${pl.zFocus} (focus, still) … ${pl.zNear} (depth 1, near)`;
|
|
105
|
+
const inside = content.filter(({ world }) => world[2] > pl.zFar && world[2] < pl.zNear).map(({ def }) => def.id);
|
|
106
|
+
if (!pl.occlude && inside.length) out.push({
|
|
107
|
+
severity: "info",
|
|
108
|
+
code: "photo-occlude",
|
|
109
|
+
path: at,
|
|
110
|
+
message: `${inside.slice(0, 4).map((id) => `"${id}"`).join(", ")}${inside.length > 4 ? "…" : ""} sit${inside.length === 1 ? "s" : ""} within the depth of photo "${pl.id}" (${range}) but always draw${inside.length === 1 ? "s" : ""} over it.`,
|
|
111
|
+
hint: `To put them inside the photo (hidden by its nearer parts, moving with its planes), set ${at}: true. Keep it off for a title meant to float over the picture.`
|
|
112
|
+
});
|
|
113
|
+
else if (pl.occlude) out.push(content.length ? {
|
|
114
|
+
severity: "info",
|
|
115
|
+
code: "photo-depth-range",
|
|
116
|
+
path: at,
|
|
117
|
+
message: `Photo "${pl.id}" occludes: its pixels span ${range}.`,
|
|
118
|
+
hint: "An object at world z is hidden where the photo is nearer: put a title between the far and the near z (e.g. just behind the nearest building's depth); objects in front of the near z are never hidden."
|
|
119
|
+
} : {
|
|
120
|
+
severity: "info",
|
|
121
|
+
code: "ignored",
|
|
122
|
+
path: at,
|
|
123
|
+
message: `occlude does nothing on photo "${pl.id}": the scene has no other objects to hide.`,
|
|
124
|
+
hint: "Add 3D objects between its depth planes, or remove occlude."
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
function photoPlacements(scene) {
|
|
130
|
+
const out = [];
|
|
131
|
+
for (const { def, world } of placedObjects(scene.objects)) {
|
|
132
|
+
if (def.kind !== "photo") continue;
|
|
133
|
+
const p = photoPlacement(scene, def, world);
|
|
134
|
+
if (p) out.push(p);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
export { photoPlacement as n, photoDepthIssues as t };
|