@fleox/agent3d 0.3.1 → 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 +25 -0
- package/dist/agent/agent3d.mjs +802 -90
- 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-bJwh2SqG.mjs → export-BSOqVfPT.mjs} +87 -7
- 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-fMbw9UGh.mjs → package-DzXqX5Oe.mjs} +2 -2
- 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-Cm4BqDkO.mjs → tools-Vs74Xopx.mjs} +153 -14
- package/dist/runtime/agent3d-photo.js +72 -0
- package/dist/runtime/agent3d-runtime.js +41 -41
- package/dist/runtime/agent3d-runtime.single.js +526 -250
- package/dist/runtime/chunks/assets-kC2Z1Xy_.js +1 -0
- package/dist/runtime/chunks/game-CbQaEB4q.js +20 -0
- package/dist/runtime/chunks/materials-jwhXlLYl.js +107 -0
- package/dist/runtime/chunks/model-CG5T_jcB.js +1 -0
- package/dist/runtime/chunks/num-CQNAlL82.js +1 -0
- package/dist/runtime/chunks/photo-Dq-AKlfw.js +526 -0
- package/dist/runtime/chunks/physicsHost-BU-2V-CZ.js +1 -0
- package/dist/runtime/chunks/{postfx-Cbf_vvOr.js → postfx-DnIeKXAh.js} +1 -1
- package/dist/runtime/chunks/postfx-ylpcQcVK.js +1 -0
- package/dist/runtime/chunks/svg-fYjsY-rV.js +1 -0
- package/dist/runtime/chunks/{text-rSo_2Luk.js → text-CySfj5sH.js} +1 -1
- package/dist/runtime/chunks/util-BEflQURG.js +1 -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-NkBUKsDB.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-BjIs-kHx.js → generators-lG93qWTO.js} +5 -5
- 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/num-CQNAlL82.js +1 -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-EkPuIy04.js +1 -0
- package/dist/studio/assets/{postfx-BGu30OJK.js → postfx-Bcnem9ci.js} +13 -13
- package/dist/studio/assets/rolldown-runtime-4tVxZq34.js +1 -0
- package/dist/studio/assets/runtime-5Ti8UJJR.js +572 -0
- package/dist/studio/assets/{shaders-Dt6FGXH_.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 +2 -2
- 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 +32 -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/assets-qnxDnVkj.js +0 -1
- package/dist/runtime/chunks/game-BoEiyZrL.js +0 -20
- package/dist/runtime/chunks/materials-dC4vDNHh.js +0 -107
- package/dist/runtime/chunks/model-BCAl_NRl.js +0 -1
- package/dist/runtime/chunks/photo-DNf14X7B.js +0 -250
- package/dist/runtime/chunks/physicsHost-ChPgysMQ.js +0 -1
- package/dist/runtime/chunks/postfx-CFucYRev.js +0 -1
- package/dist/runtime/chunks/svg-CLUxY6Zy.js +0 -1
- package/dist/runtime/chunks/util-CyaW1fcW.js +0 -1
- package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +0 -1
- package/dist/studio/assets/assets-BW5lQkYR.js +0 -1
- package/dist/studio/assets/camera-BgzPVnn-.js +0 -2
- package/dist/studio/assets/game-DARpu0ah.js +0 -19
- package/dist/studio/assets/index-BQT0otii.css +0 -1
- package/dist/studio/assets/index-L-N-e2KM.js +0 -479
- package/dist/studio/assets/model-CqI8j03Z.js +0 -2
- package/dist/studio/assets/params-DhsDKSDs.js +0 -1
- package/dist/studio/assets/photo-DAHd1yNF.js +0 -250
- package/dist/studio/assets/physicsHost-tEUto2-_.js +0 -1
- package/dist/studio/assets/runtime-C_qkIpAK.js +0 -572
- package/dist/studio/assets/svg-ZZt5MdNf.js +0 -2
- package/dist/studio/assets/text-B-HM422i.js +0 -3
- package/dist/studio/assets/three.module-CnI50X0U.js +0 -4225
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import { createRequire as __a3dRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __a3dPath } from "node:url";
|
|
3
|
+
import { dirname as __a3dDirname } from "node:path";
|
|
4
|
+
__a3dRequire(import.meta.url);
|
|
5
|
+
const __filename = __a3dPath(import.meta.url);
|
|
6
|
+
__a3dDirname(__filename);
|
|
7
|
+
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
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";
|
|
12
|
+
import { o as walkObjects } from "./tree-CqSj-o8T.mjs";
|
|
13
|
+
// src/ops/pngDecode.ts
|
|
14
|
+
var SIG = [
|
|
15
|
+
137,
|
|
16
|
+
80,
|
|
17
|
+
78,
|
|
18
|
+
71,
|
|
19
|
+
13,
|
|
20
|
+
10,
|
|
21
|
+
26,
|
|
22
|
+
10
|
|
23
|
+
];
|
|
24
|
+
function isPng(bytes) {
|
|
25
|
+
return bytes.length > 8 && SIG.every((b, i) => bytes[i] === b);
|
|
26
|
+
}
|
|
27
|
+
async function inflateRaw(data, inflate) {
|
|
28
|
+
if (inflate) return inflate(data);
|
|
29
|
+
const DS = globalThis.DecompressionStream;
|
|
30
|
+
if (!DS) throw new OpsError("io", "No inflate available to decode PNG files.", "Pass an `inflate` (raw deflate) implementation.");
|
|
31
|
+
const stream = new Blob([data]).stream().pipeThrough(new DS("deflate-raw"));
|
|
32
|
+
return new Uint8Array(await new Response(stream).arrayBuffer());
|
|
33
|
+
}
|
|
34
|
+
async function decodePng(bytes, opts = {}) {
|
|
35
|
+
if (!isPng(bytes)) throw new OpsError("invalid", "Not a PNG file.");
|
|
36
|
+
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
37
|
+
let pos = 8;
|
|
38
|
+
let width = 0, height = 0, depth = 0, type = 0, interlace = 0;
|
|
39
|
+
let palette = null;
|
|
40
|
+
let trns = null;
|
|
41
|
+
const idat = [];
|
|
42
|
+
while (pos + 8 <= bytes.length) {
|
|
43
|
+
const len = dv.getUint32(pos);
|
|
44
|
+
const name = String.fromCharCode(bytes[pos + 4], bytes[pos + 5], bytes[pos + 6], bytes[pos + 7]);
|
|
45
|
+
const body = bytes.subarray(pos + 8, pos + 8 + len);
|
|
46
|
+
if (name === "IHDR") {
|
|
47
|
+
width = dv.getUint32(pos + 8);
|
|
48
|
+
height = dv.getUint32(pos + 12);
|
|
49
|
+
depth = bytes[pos + 16];
|
|
50
|
+
type = bytes[pos + 17];
|
|
51
|
+
interlace = bytes[pos + 20];
|
|
52
|
+
} else if (name === "PLTE") palette = body;
|
|
53
|
+
else if (name === "tRNS") trns = body;
|
|
54
|
+
else if (name === "IDAT") idat.push(body);
|
|
55
|
+
else if (name === "IEND") break;
|
|
56
|
+
pos += 12 + len;
|
|
57
|
+
}
|
|
58
|
+
const channels = {
|
|
59
|
+
0: 1,
|
|
60
|
+
2: 3,
|
|
61
|
+
3: 1,
|
|
62
|
+
4: 2,
|
|
63
|
+
6: 4
|
|
64
|
+
}[type];
|
|
65
|
+
if (!width || !height || !channels || interlace || !(depth === 8 || depth === 16 && type !== 3)) throw new OpsError("invalid", `Unsupported PNG (${width}x${height}, colour type ${type}, ${depth}-bit${interlace ? ", interlaced" : ""}).`, "Use an 8-bit, non-interlaced PNG (grey, RGB or RGBA).");
|
|
66
|
+
const total = idat.reduce((s, c) => s + c.length, 0);
|
|
67
|
+
const z = new Uint8Array(total);
|
|
68
|
+
let o = 0;
|
|
69
|
+
for (const c of idat) z.set(c, (o += c.length) - c.length);
|
|
70
|
+
const raw = await inflateRaw(z.subarray(2, z.length - 4), opts.inflate);
|
|
71
|
+
const bpp = Math.max(1, channels * depth / 8);
|
|
72
|
+
const stride = width * bpp;
|
|
73
|
+
if (raw.length < (stride + 1) * height) throw new OpsError("invalid", "Truncated PNG data.");
|
|
74
|
+
const cur = new Uint8Array(stride);
|
|
75
|
+
const prev = new Uint8Array(stride);
|
|
76
|
+
const out = new Uint8Array(width * height * 4);
|
|
77
|
+
const hi = depth === 16 ? 2 : 1;
|
|
78
|
+
for (let y = 0; y < height; y++) {
|
|
79
|
+
const f = raw[y * (stride + 1)];
|
|
80
|
+
const row = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
|
|
81
|
+
for (let i = 0; i < stride; i++) {
|
|
82
|
+
const a = i >= bpp ? cur[i - bpp] : 0;
|
|
83
|
+
const b = prev[i];
|
|
84
|
+
const c = i >= bpp ? prev[i - bpp] : 0;
|
|
85
|
+
let v = row[i];
|
|
86
|
+
if (f === 1) v += a;
|
|
87
|
+
else if (f === 2) v += b;
|
|
88
|
+
else if (f === 3) v += a + b >> 1;
|
|
89
|
+
else if (f === 4) {
|
|
90
|
+
const p = a + b - c;
|
|
91
|
+
const pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c);
|
|
92
|
+
v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
|
|
93
|
+
}
|
|
94
|
+
cur[i] = v & 255;
|
|
95
|
+
}
|
|
96
|
+
for (let x = 0; x < width; x++) {
|
|
97
|
+
const s = x * bpp;
|
|
98
|
+
const d = (y * width + x) * 4;
|
|
99
|
+
const ch = (k) => cur[s + k * hi];
|
|
100
|
+
if (type === 0) {
|
|
101
|
+
out[d] = out[d + 1] = out[d + 2] = ch(0);
|
|
102
|
+
out[d + 3] = trns && trns.length >= 2 && (trns[0] << 8 | trns[1]) >> (depth === 16 ? 8 : 0) === ch(0) ? 0 : 255;
|
|
103
|
+
} else if (type === 4) {
|
|
104
|
+
out[d] = out[d + 1] = out[d + 2] = ch(0);
|
|
105
|
+
out[d + 3] = ch(1);
|
|
106
|
+
} else if (type === 2) {
|
|
107
|
+
out[d] = ch(0);
|
|
108
|
+
out[d + 1] = ch(1);
|
|
109
|
+
out[d + 2] = ch(2);
|
|
110
|
+
out[d + 3] = 255;
|
|
111
|
+
} else if (type === 6) {
|
|
112
|
+
out[d] = ch(0);
|
|
113
|
+
out[d + 1] = ch(1);
|
|
114
|
+
out[d + 2] = ch(2);
|
|
115
|
+
out[d + 3] = ch(3);
|
|
116
|
+
} else {
|
|
117
|
+
const idx = cur[x];
|
|
118
|
+
out[d] = palette?.[idx * 3] ?? 0;
|
|
119
|
+
out[d + 1] = palette?.[idx * 3 + 1] ?? 0;
|
|
120
|
+
out[d + 2] = palette?.[idx * 3 + 2] ?? 0;
|
|
121
|
+
out[d + 3] = trns && idx < trns.length ? trns[idx] : 255;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
prev.set(cur);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
data: out,
|
|
128
|
+
width,
|
|
129
|
+
height
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// src/ops/plate.ts
|
|
133
|
+
var plate_exports = /* @__PURE__ */ __exportAll({
|
|
134
|
+
checkPlateRequest: () => checkPlateRequest,
|
|
135
|
+
generatePlate: () => generatePlate
|
|
136
|
+
});
|
|
137
|
+
var EDGE_STEP = .045;
|
|
138
|
+
var EDGE_REACH = 6;
|
|
139
|
+
var FAR_MARGIN = 2;
|
|
140
|
+
var MIRROR_STEPS = [
|
|
141
|
+
1,
|
|
142
|
+
.75,
|
|
143
|
+
.5,
|
|
144
|
+
.25
|
|
145
|
+
];
|
|
146
|
+
function plateHoleWidth(width, height, strength = 1) {
|
|
147
|
+
return Math.max(2, Math.ceil(Math.min(width, height) * Math.min(1, Math.max(0, strength)) * .06 * Math.SQRT2 * 1.15));
|
|
148
|
+
}
|
|
149
|
+
function resample(img, w, h) {
|
|
150
|
+
if (img.width === w && img.height === h) return img;
|
|
151
|
+
const out = new Uint8Array(w * h * 4);
|
|
152
|
+
const sx = img.width / w, sy = img.height / h;
|
|
153
|
+
const W = img.width, H = img.height, src = img.data;
|
|
154
|
+
for (let y = 0; y < h; y++) {
|
|
155
|
+
const fy = Math.min(H - 1, Math.max(0, (y + .5) * sy - .5));
|
|
156
|
+
const y0 = Math.floor(fy), y1 = Math.min(H - 1, y0 + 1), ty = fy - y0;
|
|
157
|
+
for (let x = 0; x < w; x++) {
|
|
158
|
+
const fx = Math.min(W - 1, Math.max(0, (x + .5) * sx - .5));
|
|
159
|
+
const x0 = Math.floor(fx), x1 = Math.min(W - 1, x0 + 1), tx = fx - x0;
|
|
160
|
+
const a = (y0 * W + x0) * 4, b = (y0 * W + x1) * 4, c = (y1 * W + x0) * 4, d = (y1 * W + x1) * 4;
|
|
161
|
+
const o = (y * w + x) * 4;
|
|
162
|
+
for (let k = 0; k < 4; k++) out[o + k] = Math.round((src[a + k] * (1 - tx) + src[b + k] * tx) * (1 - ty) + (src[c + k] * (1 - tx) + src[d + k] * tx) * ty);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
data: out,
|
|
167
|
+
width: w,
|
|
168
|
+
height: h
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function windowFilter(src, w, h, r, max) {
|
|
172
|
+
const pick = max ? Math.max : Math.min;
|
|
173
|
+
const pass = (inp, len, count, step, lineStep) => {
|
|
174
|
+
const out = new Float32Array(inp.length);
|
|
175
|
+
const k = 2 * r + 1;
|
|
176
|
+
const g = new Float32Array(len + k), hh = new Float32Array(len + k);
|
|
177
|
+
const line = new Float32Array(len + 2 * r);
|
|
178
|
+
for (let l = 0; l < count; l++) {
|
|
179
|
+
const base = l * lineStep;
|
|
180
|
+
for (let i = 0; i < len + 2 * r; i++) line[i] = inp[base + Math.min(len - 1, Math.max(0, i - r)) * step];
|
|
181
|
+
const n = len + 2 * r;
|
|
182
|
+
for (let i = 0; i < n; i++) g[i] = i % k === 0 ? line[i] : pick(g[i - 1], line[i]);
|
|
183
|
+
for (let i = n - 1; i >= 0; i--) hh[i] = i === n - 1 || (i + 1) % k === 0 ? line[i] : pick(hh[i + 1], line[i]);
|
|
184
|
+
for (let i = 0; i < len; i++) out[base + i * step] = pick(hh[i], g[i + 2 * r]);
|
|
185
|
+
}
|
|
186
|
+
return out;
|
|
187
|
+
};
|
|
188
|
+
return pass(pass(src, w, h, 1, w), h, w, w, 1);
|
|
189
|
+
}
|
|
190
|
+
function buildPlate(photo, depthMap, opts = {}) {
|
|
191
|
+
const w = photo.width, h = photo.height, n = w * h;
|
|
192
|
+
if (photo.data.length !== n * 4) throw new OpsError("invalid", `Plate: photo has ${photo.data.length} bytes, expected ${n * 4}.`);
|
|
193
|
+
const dm = resample(depthMap, w, h);
|
|
194
|
+
const R = Math.max(2, Math.round(opts.width ?? plateHoleWidth(w, h, opts.strength ?? 1)));
|
|
195
|
+
const d = new Float32Array(n);
|
|
196
|
+
const known = new Uint8Array(n);
|
|
197
|
+
for (let i = 0; i < n; i++) {
|
|
198
|
+
d[i] = dm.data[i * 4] / 255;
|
|
199
|
+
known[i] = dm.data[i * 4 + 3] >= 128 ? 1 : 0;
|
|
200
|
+
}
|
|
201
|
+
const forMin = new Float32Array(n);
|
|
202
|
+
const forMax = new Float32Array(n);
|
|
203
|
+
for (let i = 0; i < n; i++) {
|
|
204
|
+
forMin[i] = known[i] ? d[i] : 2;
|
|
205
|
+
forMax[i] = known[i] ? d[i] : -1;
|
|
206
|
+
}
|
|
207
|
+
const nearSmall = windowFilter(forMax, w, h, EDGE_REACH, true);
|
|
208
|
+
const farSmall = windowFilter(forMin, w, h, EDGE_REACH, false);
|
|
209
|
+
const INF = 1 << 29;
|
|
210
|
+
const dist = new Int32Array(n).fill(INF);
|
|
211
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
212
|
+
const i = y * w + x;
|
|
213
|
+
let edge = !known[i];
|
|
214
|
+
if (!edge) {
|
|
215
|
+
const c = d[i];
|
|
216
|
+
if (x >= 2 && known[i - 2] && Math.abs(d[i - 2] - c) > EDGE_STEP) edge = true;
|
|
217
|
+
else if (x < w - 2 && known[i + 2] && Math.abs(d[i + 2] - c) > EDGE_STEP) edge = true;
|
|
218
|
+
else if (y >= 2 && known[i - 2 * w] && Math.abs(d[i - 2 * w] - c) > EDGE_STEP) edge = true;
|
|
219
|
+
else if (y < h - 2 && known[i + 2 * w] && Math.abs(d[i + 2 * w] - c) > EDGE_STEP) edge = true;
|
|
220
|
+
}
|
|
221
|
+
if (edge) dist[i] = 0;
|
|
222
|
+
}
|
|
223
|
+
const edgeFar = new Float32Array(n);
|
|
224
|
+
for (let i = 0; i < n; i++) if (dist[i] === 0) edgeFar[i] = farSmall[i];
|
|
225
|
+
const relax = (i, q, cost) => {
|
|
226
|
+
if (dist[q] + cost < dist[i]) {
|
|
227
|
+
dist[i] = dist[q] + cost;
|
|
228
|
+
edgeFar[i] = edgeFar[q];
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
232
|
+
const i = y * w + x;
|
|
233
|
+
if (x > 0) relax(i, i - 1, 3);
|
|
234
|
+
if (y > 0) {
|
|
235
|
+
relax(i, i - w, 3);
|
|
236
|
+
if (x > 0) relax(i, i - w - 1, 4);
|
|
237
|
+
if (x < w - 1) relax(i, i - w + 1, 4);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (let y = h - 1; y >= 0; y--) for (let x = w - 1; x >= 0; x--) {
|
|
241
|
+
const i = y * w + x;
|
|
242
|
+
if (x < w - 1) relax(i, i + 1, 3);
|
|
243
|
+
if (y < h - 1) {
|
|
244
|
+
relax(i, i + w, 3);
|
|
245
|
+
if (x < w - 1) relax(i, i + w + 1, 4);
|
|
246
|
+
if (x > 0) relax(i, i + w - 1, 4);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const hole = new Uint8Array(n);
|
|
250
|
+
const occ = new Float32Array(n);
|
|
251
|
+
const need = new Float32Array(n);
|
|
252
|
+
for (let i = 0; i < n; i++) {
|
|
253
|
+
if (!known[i]) {
|
|
254
|
+
const j = nearSmall[i] - farSmall[i];
|
|
255
|
+
if (j > .05) {
|
|
256
|
+
hole[i] = 1;
|
|
257
|
+
occ[i] = nearSmall[i];
|
|
258
|
+
need[i] = nearSmall[i] - .5 * j;
|
|
259
|
+
}
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const j = Math.min(1, d[i] - edgeFar[i]);
|
|
263
|
+
if (dist[i] < INF && j > .05 && dist[i] <= 3 * (2 + R * j)) {
|
|
264
|
+
hole[i] = 1;
|
|
265
|
+
occ[i] = d[i];
|
|
266
|
+
need[i] = d[i] - .5 * j;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
{
|
|
270
|
+
let ring = hole.slice();
|
|
271
|
+
for (let pass = 0; pass < FAR_MARGIN; pass++) {
|
|
272
|
+
const next = ring.slice();
|
|
273
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
274
|
+
const i = y * w + x;
|
|
275
|
+
if (ring[i]) continue;
|
|
276
|
+
if (!(x > 0 && ring[i - 1] || x < w - 1 && ring[i + 1] || y > 0 && ring[i - w] || y < h - 1 && ring[i + w])) continue;
|
|
277
|
+
let o = -1;
|
|
278
|
+
if (x > 0 && ring[i - 1]) o = Math.max(o, occ[i - 1]);
|
|
279
|
+
if (x < w - 1 && ring[i + 1]) o = Math.max(o, occ[i + 1]);
|
|
280
|
+
if (y > 0 && ring[i - w]) o = Math.max(o, occ[i - w]);
|
|
281
|
+
if (y < h - 1 && ring[i + w]) o = Math.max(o, occ[i + w]);
|
|
282
|
+
if (o - d[i] <= .05) continue;
|
|
283
|
+
next[i] = 1;
|
|
284
|
+
occ[i] = o;
|
|
285
|
+
need[i] = d[i] + .25 * (o - d[i]);
|
|
286
|
+
}
|
|
287
|
+
for (let i = 0; i < n; i++) if (next[i] && !hole[i]) hole[i] = 2;
|
|
288
|
+
ring = next;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const src = new Int32Array(n).fill(-1);
|
|
292
|
+
const sd2 = new Float64Array(n).fill(Infinity);
|
|
293
|
+
for (let i = 0; i < n; i++) if (!hole[i] && known[i]) {
|
|
294
|
+
src[i] = i;
|
|
295
|
+
sd2[i] = 0;
|
|
296
|
+
}
|
|
297
|
+
const tryFrom = (i, x, y, q) => {
|
|
298
|
+
const s = src[q];
|
|
299
|
+
if (s < 0) return;
|
|
300
|
+
if (d[s] >= need[i]) return;
|
|
301
|
+
const dx = s % w - x, dy = (s / w | 0) - y;
|
|
302
|
+
const v = dx * dx + dy * dy;
|
|
303
|
+
if (v < sd2[i]) {
|
|
304
|
+
sd2[i] = v;
|
|
305
|
+
src[i] = s;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
for (let iter = 0; iter < 2; iter++) {
|
|
309
|
+
for (let y = 0; y < h; y++) {
|
|
310
|
+
for (let x = 0; x < w; x++) {
|
|
311
|
+
const i = y * w + x;
|
|
312
|
+
if (!hole[i]) continue;
|
|
313
|
+
if (x > 0) tryFrom(i, x, y, i - 1);
|
|
314
|
+
if (y > 0) {
|
|
315
|
+
tryFrom(i, x, y, i - w);
|
|
316
|
+
if (x > 0) tryFrom(i, x, y, i - w - 1);
|
|
317
|
+
if (x < w - 1) tryFrom(i, x, y, i - w + 1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
for (let x = w - 1; x >= 0; x--) {
|
|
321
|
+
const i = y * w + x;
|
|
322
|
+
if (hole[i] && x < w - 1) tryFrom(i, x, y, i + 1);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
for (let y = h - 1; y >= 0; y--) {
|
|
326
|
+
for (let x = w - 1; x >= 0; x--) {
|
|
327
|
+
const i = y * w + x;
|
|
328
|
+
if (!hole[i]) continue;
|
|
329
|
+
if (x < w - 1) tryFrom(i, x, y, i + 1);
|
|
330
|
+
if (y < h - 1) {
|
|
331
|
+
tryFrom(i, x, y, i + w);
|
|
332
|
+
if (x < w - 1) tryFrom(i, x, y, i + w + 1);
|
|
333
|
+
if (x > 0) tryFrom(i, x, y, i + w - 1);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
for (let x = 0; x < w; x++) {
|
|
337
|
+
const i = y * w + x;
|
|
338
|
+
if (hole[i] && x > 0) tryFrom(i, x, y, i - 1);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const color = new Uint8Array(n * 4);
|
|
343
|
+
const pd = new Float32Array(n);
|
|
344
|
+
const P = photo.data;
|
|
345
|
+
let holePixels = 0, unfilled = 0;
|
|
346
|
+
const okSource = (q, i, ref) => q >= 0 && !hole[q] && known[q] && d[q] < need[i] && Math.abs(d[q] - ref) < .5 * (occ[i] - ref) + .02;
|
|
347
|
+
for (let i = 0; i < n; i++) {
|
|
348
|
+
const o = i * 4;
|
|
349
|
+
if (!hole[i] || src[i] < 0) {
|
|
350
|
+
color[o] = P[o];
|
|
351
|
+
color[o + 1] = P[o + 1];
|
|
352
|
+
color[o + 2] = P[o + 2];
|
|
353
|
+
color[o + 3] = 255;
|
|
354
|
+
pd[i] = known[i] ? d[i] : nearSmall[i] >= 0 ? nearSmall[i] : 0;
|
|
355
|
+
if (hole[i]) {
|
|
356
|
+
unfilled++;
|
|
357
|
+
hole[i] = 3;
|
|
358
|
+
}
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
holePixels++;
|
|
362
|
+
const s = src[i];
|
|
363
|
+
const x = i % w, y = i / w | 0;
|
|
364
|
+
const sx = s % w, sy = s / w | 0;
|
|
365
|
+
const ref = d[s];
|
|
366
|
+
let pick = s;
|
|
367
|
+
for (const t of MIRROR_STEPS) {
|
|
368
|
+
const mx = Math.round(sx + t * (sx - x)), my = Math.round(sy + t * (sy - y));
|
|
369
|
+
if (mx < 0 || my < 0 || mx >= w || my >= h) continue;
|
|
370
|
+
const q = my * w + mx;
|
|
371
|
+
if (okSource(q, i, ref)) {
|
|
372
|
+
pick = q;
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const po = pick * 4;
|
|
377
|
+
color[o] = P[po];
|
|
378
|
+
color[o + 1] = P[po + 1];
|
|
379
|
+
color[o + 2] = P[po + 2];
|
|
380
|
+
color[o + 3] = 255;
|
|
381
|
+
pd[i] = ref;
|
|
382
|
+
}
|
|
383
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
384
|
+
const tmp = pd.slice();
|
|
385
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
386
|
+
const i = y * w + x;
|
|
387
|
+
if (!hole[i] || src[i] < 0) continue;
|
|
388
|
+
let sum = 0, cnt = 0;
|
|
389
|
+
for (let dy = -2; dy <= 2; dy++) {
|
|
390
|
+
const yy = y + dy;
|
|
391
|
+
if (yy < 0 || yy >= h) continue;
|
|
392
|
+
for (let dx = -2; dx <= 2; dx++) {
|
|
393
|
+
const xx = x + dx;
|
|
394
|
+
if (xx < 0 || xx >= w) continue;
|
|
395
|
+
const q = yy * w + xx;
|
|
396
|
+
if (hole[q] && src[q] >= 0) {
|
|
397
|
+
sum += tmp[q];
|
|
398
|
+
cnt++;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
pd[i] = sum / cnt;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const depthOut = new Uint8Array(n * 4);
|
|
406
|
+
for (let i = 0; i < n; i++) {
|
|
407
|
+
const g = Math.round(Math.min(1, Math.max(0, pd[i])) * 255);
|
|
408
|
+
const o = i * 4;
|
|
409
|
+
depthOut[o] = depthOut[o + 1] = depthOut[o + 2] = g;
|
|
410
|
+
depthOut[o + 3] = 255;
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
color: {
|
|
414
|
+
data: color,
|
|
415
|
+
width: w,
|
|
416
|
+
height: h
|
|
417
|
+
},
|
|
418
|
+
depth: {
|
|
419
|
+
data: depthOut,
|
|
420
|
+
width: w,
|
|
421
|
+
height: h
|
|
422
|
+
},
|
|
423
|
+
holePixels,
|
|
424
|
+
unfilled,
|
|
425
|
+
width: R,
|
|
426
|
+
mask: hole
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function baseName(image) {
|
|
430
|
+
return image.replace(/^library:/, "").split("/").pop().replace(/\.[^.]+$/, "").replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "image";
|
|
431
|
+
}
|
|
432
|
+
function projectPath(p, what, example) {
|
|
433
|
+
let out;
|
|
434
|
+
try {
|
|
435
|
+
out = normalizePath(p.replace(/^\.\//, ""));
|
|
436
|
+
} catch {
|
|
437
|
+
throw new OpsError("invalid", `Invalid ${what} path "${p}".`, `Use e.g. "${example}".`);
|
|
438
|
+
}
|
|
439
|
+
if (!out.startsWith("assets/")) throw new OpsError("invalid", `The ${what} must be under assets/ (got "${out}").`, `Use e.g. "${example}".`);
|
|
440
|
+
return out;
|
|
441
|
+
}
|
|
442
|
+
async function readImage(fs, image, library) {
|
|
443
|
+
if (isLibraryRef(image)) {
|
|
444
|
+
const id = libraryId(image);
|
|
445
|
+
if (!library) throw new OpsError("invalid", `Library assets are not available in this host (${image}).`, "Copy the image into the project (assets add) and pass its project path.");
|
|
446
|
+
const asset = findLibraryAsset(library.index, id);
|
|
447
|
+
if (!asset) throw new OpsError("notFound", `No library asset "${id}".`, "List images with library_list { kind: \"texture\" } (CLI: agent3d assets library --kind texture).");
|
|
448
|
+
return {
|
|
449
|
+
bytes: await library.read(id),
|
|
450
|
+
entry: {
|
|
451
|
+
license: asset.license,
|
|
452
|
+
author: asset.author,
|
|
453
|
+
attribution: asset.attribution,
|
|
454
|
+
sourceUrl: asset.sourceUrl
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
const path = projectPath(image, "image", "assets/textures/photo.jpg");
|
|
459
|
+
if (!await fs.exists(path)) {
|
|
460
|
+
const images = (await fs.list("assets/")).filter((f) => /\.(png|jpe?g|webp)$/i.test(f) && !/(-depth|-plate)\.\w+$/i.test(f));
|
|
461
|
+
throw new OpsError("notFound", `Image "${image}" not found in the project.`, images.length ? `Images in the project: ${images.slice(0, 8).join(", ")}${images.length > 8 ? ", …" : ""}.` : "Add the photo first: assets_add { file } (CLI: agent3d assets add <photo.jpg> --license …).");
|
|
462
|
+
}
|
|
463
|
+
const manifest = await readAssetManifest(fs);
|
|
464
|
+
return {
|
|
465
|
+
bytes: await fs.readBytes(path),
|
|
466
|
+
entry: manifest.assets.find((a) => a.path === path)
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
async function sceneDepthFor(fs, image) {
|
|
470
|
+
if (!await fs.exists("scene.json")) return void 0;
|
|
471
|
+
let scene;
|
|
472
|
+
try {
|
|
473
|
+
scene = JSON.parse(await fs.readText("scene.json"));
|
|
474
|
+
} catch {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
let found;
|
|
478
|
+
walkObjects(scene.objects ?? [], (o) => {
|
|
479
|
+
const p = o;
|
|
480
|
+
if (!found && p.kind === "photo" && p.src === image && typeof p.depth === "string") found = p.depth;
|
|
481
|
+
});
|
|
482
|
+
return found;
|
|
483
|
+
}
|
|
484
|
+
async function checkPlateRequest(fs, req, opts = {}) {
|
|
485
|
+
if (!req.image?.trim()) throw new OpsError("invalid", "A plate needs an image.", "Pass image: a project path (\"assets/textures/photo.jpg\") or \"library:<id>\".");
|
|
486
|
+
const image = req.image.replace(/^\.\//, "");
|
|
487
|
+
const name = baseName(image);
|
|
488
|
+
const { bytes } = await readImage(fs, image, req.library);
|
|
489
|
+
const header = imageHeader(bytes);
|
|
490
|
+
if (!header) throw new OpsError("invalid", `"${image}" is not a PNG, JPEG or WebP image.`, "Plates are built from .png, .jpg and .webp photos.");
|
|
491
|
+
const fallback = `assets/depth/${name}-depth.png`;
|
|
492
|
+
let depth = req.depth ? projectPath(req.depth, "depth map", fallback) : await sceneDepthFor(fs, image);
|
|
493
|
+
if (!depth && await fs.exists(fallback)) depth = fallback;
|
|
494
|
+
if (!depth || isLibraryRef(depth) || !await fs.exists(depth)) throw new OpsError("notFound", depth ? `Depth map "${depth}" not found in the project.` : `No depth map for "${image}".`, `Estimate it first: \`agent3d assets depth ${image} --plate\` (depth map + plate in one go; AI tool: image_depth { image, plate: true }), or pass --depth <png>.`);
|
|
495
|
+
if (!/\.png$/i.test(depth)) throw new OpsError("invalid", `The depth map must be a PNG (got "${depth}").`, `Regenerate it: \`agent3d assets depth ${image}\`.`);
|
|
496
|
+
const ext = req.format === "png" || opts.webp === false ? "png" : "webp";
|
|
497
|
+
const out = projectPath(req.out ?? `assets/depth/${name}-plate.${ext}`, "plate", `assets/depth/${name}-plate.${ext}`);
|
|
498
|
+
if (!/\.(png|webp)$/i.test(out)) throw new OpsError("invalid", `The plate must be a .webp or .png (got "${out}").`, `Use e.g. "assets/depth/${name}-plate.webp".`);
|
|
499
|
+
const outDepth = projectPath(req.outDepth ?? `assets/depth/${name}-plate-depth.png`, "plate depth", `assets/depth/${name}-plate-depth.png`);
|
|
500
|
+
if (!/\.png$/i.test(outDepth)) throw new OpsError("invalid", `The plate depth must be a .png (got "${outDepth}").`, `Use e.g. "assets/depth/${name}-plate-depth.png".`);
|
|
501
|
+
if (outDepth === out || out === depth || outDepth === depth) throw new OpsError("invalid", "The plate, its depth and the depth map need three different paths.");
|
|
502
|
+
if (req.width !== void 0 && !(req.width >= 2 && req.width <= 512)) throw new OpsError("invalid", `width must be between 2 and 512 px (got ${req.width}).`, "Omit it: the default follows the strongest parallax (strength 1).");
|
|
503
|
+
if (req.strength !== void 0 && !(req.strength > 0 && req.strength <= 1)) throw new OpsError("invalid", `strength must be in (0, 1] (got ${req.strength}).`);
|
|
504
|
+
if (req.maxSize !== void 0 && !(req.maxSize >= 64 && req.maxSize <= 4096)) throw new OpsError("invalid", `maxSize must be between 64 and 4096 (got ${req.maxSize}).`);
|
|
505
|
+
return {
|
|
506
|
+
image,
|
|
507
|
+
depth,
|
|
508
|
+
out,
|
|
509
|
+
outDepth,
|
|
510
|
+
width: header.width,
|
|
511
|
+
height: header.height
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
async function generatePlate(fs, req, codec) {
|
|
515
|
+
const plan = await checkPlateRequest(fs, req, { webp: !!codec.codec });
|
|
516
|
+
const { bytes, entry } = await readImage(fs, plan.image, req.library);
|
|
517
|
+
const header = imageHeader(bytes);
|
|
518
|
+
const maxSize = Math.min(req.maxSize ?? 1024, Math.max(header.width, header.height));
|
|
519
|
+
const photo = isPng(bytes) && maxSize >= Math.max(header.width, header.height) ? await decodePng(bytes, { inflate: req.inflate }) : await codec.decode({
|
|
520
|
+
bytes,
|
|
521
|
+
mimeType: header.mimeType,
|
|
522
|
+
maxSize
|
|
523
|
+
});
|
|
524
|
+
const depthBytes = await fs.readBytes(plan.depth);
|
|
525
|
+
let depth;
|
|
526
|
+
try {
|
|
527
|
+
depth = await decodePng(depthBytes, { inflate: req.inflate });
|
|
528
|
+
} catch {
|
|
529
|
+
depth = await codec.decode({
|
|
530
|
+
bytes: depthBytes,
|
|
531
|
+
mimeType: "image/png",
|
|
532
|
+
maxSize: 8192
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
const t0 = Date.now();
|
|
536
|
+
const plate = buildPlate(photo, depth, {
|
|
537
|
+
width: req.width,
|
|
538
|
+
strength: req.strength
|
|
539
|
+
});
|
|
540
|
+
const ms = Date.now() - t0;
|
|
541
|
+
let colorBytes = await encodePng(plate.color.data, plate.color.width, plate.color.height, {
|
|
542
|
+
channels: 3,
|
|
543
|
+
deflate: req.deflate
|
|
544
|
+
});
|
|
545
|
+
if (/\.webp$/i.test(plan.out)) {
|
|
546
|
+
if (!codec.codec) throw new OpsError("invalid", "This host cannot encode WebP.", "Pass format: \"png\" (or an out path ending in .png).");
|
|
547
|
+
colorBytes = (await codec.codec({
|
|
548
|
+
bytes: colorBytes,
|
|
549
|
+
mimeType: "image/png",
|
|
550
|
+
maxSize: 16384,
|
|
551
|
+
quality: req.quality ?? 85,
|
|
552
|
+
format: "webp"
|
|
553
|
+
})).bytes;
|
|
554
|
+
}
|
|
555
|
+
const depthPng = await encodePng(plate.depth.data, plate.depth.width, plate.depth.height, {
|
|
556
|
+
channels: 1,
|
|
557
|
+
deflate: req.deflate
|
|
558
|
+
});
|
|
559
|
+
const license = entry?.license ?? "derived";
|
|
560
|
+
const what = plan.image.split("/").pop();
|
|
561
|
+
const credit = entry?.attribution ?? (entry?.author ? `"${what}" by ${entry.author}${entry.sourceUrl ? ` (${entry.sourceUrl})` : ""}, licensed under ${license}.` : "");
|
|
562
|
+
const attribution = `Background plate of ${plan.image} (foreground removed at depth edges) built by Agent3D.${credit ? ` Image: ${credit}` : ""}`;
|
|
563
|
+
const a = await addAsset(fs, {
|
|
564
|
+
path: plan.out,
|
|
565
|
+
bytes: colorBytes,
|
|
566
|
+
kind: "texture",
|
|
567
|
+
source: "agent3d-plate",
|
|
568
|
+
license,
|
|
569
|
+
author: entry?.author,
|
|
570
|
+
sourceUrl: entry?.sourceUrl,
|
|
571
|
+
attribution
|
|
572
|
+
});
|
|
573
|
+
const b = await addAsset(fs, {
|
|
574
|
+
path: plan.outDepth,
|
|
575
|
+
bytes: depthPng,
|
|
576
|
+
kind: "texture",
|
|
577
|
+
source: "agent3d-plate",
|
|
578
|
+
license,
|
|
579
|
+
author: entry?.author,
|
|
580
|
+
sourceUrl: entry?.sourceUrl,
|
|
581
|
+
attribution: `Depth of the background plate of ${plan.image}.${credit ? ` Image: ${credit}` : ""}`
|
|
582
|
+
});
|
|
583
|
+
const kb = (n) => Math.round(n / 102.4) / 10;
|
|
584
|
+
return {
|
|
585
|
+
path: a.path,
|
|
586
|
+
depthPath: b.path,
|
|
587
|
+
image: plan.image,
|
|
588
|
+
depth: plan.depth,
|
|
589
|
+
width: plate.color.width,
|
|
590
|
+
height: plate.color.height,
|
|
591
|
+
holeWidth: plate.width,
|
|
592
|
+
holePixels: plate.holePixels,
|
|
593
|
+
holePercent: Math.round(plate.holePixels / (plate.color.width * plate.color.height) * 1e3) / 10,
|
|
594
|
+
unfilled: plate.unfilled,
|
|
595
|
+
ms,
|
|
596
|
+
kb: kb(colorBytes.byteLength),
|
|
597
|
+
depthKb: kb(depthPng.byteLength),
|
|
598
|
+
suggestion: {
|
|
599
|
+
plate: a.path,
|
|
600
|
+
plateDepth: b.path
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
export { generatePlate as n, plate_exports as r, checkPlateRequest as t };
|