ue-mcp-tripo 0.2.2 → 0.2.4
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 +58 -8
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/images.d.ts +80 -0
- package/dist/shared/images.js +322 -0
- package/dist/shared/images.js.map +1 -0
- package/dist/shared/loadouts.d.ts +56 -0
- package/dist/shared/loadouts.js +158 -0
- package/dist/shared/loadouts.js.map +1 -0
- package/dist/tasks/Generate.d.ts +45 -3
- package/dist/tasks/Generate.js +396 -51
- package/dist/tasks/Generate.js.map +1 -1
- package/dist/tasks/Loadouts.d.ts +12 -0
- package/dist/tasks/Loadouts.js +26 -0
- package/dist/tasks/Loadouts.js.map +1 -0
- package/dist/tasks/PrepareImages.d.ts +14 -0
- package/dist/tasks/PrepareImages.js +36 -0
- package/dist/tasks/PrepareImages.js.map +1 -0
- package/dist/ui/settings.html +1 -1
- package/knowledge/tripo.md +30 -1
- package/package.json +5 -3
- package/skills/cli/SKILL.md +30 -1
- package/ue-mcp.plugin.yml +147 -21
package/README.md
CHANGED
|
@@ -33,31 +33,81 @@ tripo(action="cli", args=["doctor"])
|
|
|
33
33
|
|
|
34
34
|
## Generate
|
|
35
35
|
|
|
36
|
+
Generating spends Tripo credits, so run the call with `dryRun=true` first. It returns the exact settings and the credit estimate and spends nothing; the same call without `dryRun` then generates.
|
|
37
|
+
|
|
36
38
|
```
|
|
39
|
+
tripo(action="generate", prompt="a stylized knight in plate armor", animation="idle", dryRun=true)
|
|
37
40
|
tripo(action="generate", prompt="a stylized knight in plate armor", animation="idle")
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
This runs a single `tripo make
|
|
43
|
+
This runs a single `tripo make`, writes its output to `<project>/Saved/Tripo/<name>`, and imports the model with ue-mcp's `asset(action="import_model")`. For the call above, the command is:
|
|
41
44
|
|
|
42
45
|
```
|
|
43
46
|
tripo make "a stylized knight in plate armor" --for anim
|
|
44
|
-
--then "rig-check,rig:rig_type=biped,spec=unreal,retarget:animation=preset:idle,
|
|
45
|
-
-p pbr=
|
|
47
|
+
--then "rig-check,rig:rig_type=biped,spec=unreal,out_format=glb,retarget:animation=preset:idle,out_format=glb"
|
|
48
|
+
-p pbr=false --model H3.1 -o <project>/Saved/Tripo/AStylizedKnightInPlateArmor --json --yes --no-open
|
|
46
49
|
```
|
|
47
50
|
|
|
48
|
-
The
|
|
51
|
+
Defaults are the cheapest the CLI can price: model H3.1, GLB output and no PBR (`pbr=true` turns it on), the same as Tripo's own guidance. The plugin deliberately does not follow the Tripo skill's rule of defaulting to P2. A premium model, `texture_quality=detailed` or `geometry_quality=detailed` is used only when you pass it through `model` or `params`. GLB is the default because the FBX conversion produced tiny scale and cracked meshes that the same task as GLB did not have.
|
|
52
|
+
|
|
53
|
+
The result lists the settings used and the credit estimate (generation only; rig, retarget, texture and convert steps are billed on top), the Tripo task ids and the credits spent. The raw GLB and `preview.png` are saved to the job folder with `tripo task get --download`, and the result gives their paths and when Tripo's download links expire. If the import cannot run, for example when ue-mcp does not give the plugin access to `asset(import_model)`, the call still succeeds with `status=generated` and the ready `asset(action="import_model", ...)` call to make next.
|
|
49
54
|
|
|
50
55
|
| Option | Effect |
|
|
51
56
|
|---|---|
|
|
52
|
-
| `prompt`, `images` or `task` | The input: text, one image or 2 to 4 views (absolute paths or URLs), or an existing task id to continue from. |
|
|
53
|
-
| `rig=false` |
|
|
57
|
+
| `prompt`, `images`, `views` or `task` | The input: text, one image or 2 to 4 views (absolute paths or URLs), a map of named turnaround views, or an existing task id to continue from. |
|
|
58
|
+
| `rig=false` | Skips rigging and imports a static mesh. |
|
|
54
59
|
| `rigType` | `biped` (default, with `spec=unreal`), another body type, or `auto` to let rig-check decide. |
|
|
55
60
|
| `animation` | One preset animation, such as `walk`. |
|
|
56
|
-
| `format=
|
|
61
|
+
| `format=fbx` | Adds `convert:fbx` as the last step. The default is `glb`. |
|
|
57
62
|
| `params`, `model`, `then` | Extra `-p key=value` pairs, a generation model, or a replacement `--then` chain. |
|
|
58
|
-
| `dryRun=true` | Returns the
|
|
63
|
+
| `dryRun=true` | Returns the settings and the credit estimate without spending anything. |
|
|
64
|
+
| `prepareImages=false` | Sends multiview images as they are instead of preparing them. |
|
|
59
65
|
| `place`, `location`, `destination`, `name`, ... | Passed to `asset(import_model)`. |
|
|
60
66
|
|
|
67
|
+
### Loadouts
|
|
68
|
+
|
|
69
|
+
A loadout is a named bundle of generate settings, chosen by subject. `tripo(action="generate", loadout="humanoid", prompt="...")` applies it, and any option in the call overrides the loadout field by field. All built-ins use model H3.1 and standard texture quality.
|
|
70
|
+
|
|
71
|
+
| Loadout | Settings |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `humanoid` | `smart_low_poly`, face limit 8000, no PBR, `delight`, `texture_alignment=original_image`, `orientation=align_image`, biped rig with `spec=unreal`, GLB, skeletal import with a physics asset. The CLI selects the texture version `delight` needs; the plan shows it, and about 30 credits for generation. |
|
|
74
|
+
| `creature` | Quadruped rig, GLB, face limit 20000, no PBR, skeletal import with a physics asset. |
|
|
75
|
+
| `prop` | No rig, face limit 5000, no PBR, static import. |
|
|
76
|
+
| `hero-prop` | No rig, face limit 30000, PBR, static import. |
|
|
77
|
+
| `environment` | No rig, face limit 50000, PBR, static import with Nanite on. |
|
|
78
|
+
|
|
79
|
+
`tripo(action="loadouts")` is free and lists every loadout with its resolved settings. The dry run and every result list the resolved settings and where each came from: a loadout, or the call's own option.
|
|
80
|
+
|
|
81
|
+
A project adds or changes loadouts under `ue-mcp.pluginConfig.tripo.loadouts` in the project's config (`tripo` is the plugin's name without the `ue-mcp-` prefix), and every agent on the project gets them. An override replaces only the fields it names, a new name adds a loadout, `null` removes one, and `extends` starts from another loadout:
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
ue-mcp:
|
|
85
|
+
pluginConfig:
|
|
86
|
+
tripo:
|
|
87
|
+
loadouts:
|
|
88
|
+
SLS character:
|
|
89
|
+
extends: humanoid
|
|
90
|
+
faceLimit: 15000
|
|
91
|
+
animation: idle
|
|
92
|
+
environment: null
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Fields: `model`, `rig`, `rigType`, `spec`, `animation`, `pbr`, `format`, `segmentHint`, `faceLimit`, `textureQuality`, `params`, `then`, and the import options `kind`, `destination`, `importMaterials`, `importTextures`, `importAnimations`, `createPhysicsAsset`, `nanite`, `place`, `onConflict` and `save`, plus `description` and `guidance` text. Loadouts need ue-mcp 1.4.16-beta.12 or later.
|
|
96
|
+
|
|
97
|
+
### Separating garments
|
|
98
|
+
|
|
99
|
+
`segmentHint="poncho, body"` (also a loadout field) separates parts that generation fused. make's `--then` chain has no smartsegment step, so after generating, the plugin runs `tripo mesh smartsegment` on the raw GLB with the hint, then rigs the segmented model with the usual chain. Plain `mesh segment` fused a poncho that smartsegment separated. It costs 55 credits at list price on top of the estimate (the dry run says so), is off by default, and cannot be combined with `task` or `then`. The result's `segmentation` block has the hint, task id and credits. Tripo rescales a file it re-imports for rigging; the result warns with the factor when it is not 1. If a stage fails, the call still succeeds with the model it has and a warning.
|
|
100
|
+
|
|
101
|
+
### Turnaround images
|
|
102
|
+
|
|
103
|
+
For a character turnaround, pass `views={front: ..., left: ..., back: ..., right: ...}` (front plus at least one other) or `images` with files named by view. Generate prepares the views before upload and writes them to `<jobDir>/views` as `front.png`, `left.png` and so on, which is how the CLI reads each view. Your originals are not changed. Preparation:
|
|
104
|
+
|
|
105
|
+
- flattens each view onto white and puts all of them on one 1600 px square canvas;
|
|
106
|
+
- applies one shared scale and one shared baseline, so heads and feet line up across views, with the largest subject filling 75% of the frame in its limiting dimension;
|
|
107
|
+
- refuses a view under 256 px or over 20 MB, and warns below 1024 px and when a subject touches the image edge.
|
|
108
|
+
|
|
109
|
+
`tripo(action="prepare_images", views={...})` runs the same step on its own, for free, so you can look at the files before spending credits. The plugin's knowledge file has a short guide to making the source images.
|
|
110
|
+
|
|
61
111
|
A full run takes a few minutes. The call waits up to `waitSec` (default 300); `wait=false` returns at once. If `make` is still running, the result is `status=pending` with a `jobDir`, and `tripo(action="generate", resume="<jobDir>")` waits for it and imports the model. The CLI keeps running on its own in the meantime.
|
|
62
112
|
|
|
63
113
|
A model file already on disk does not need Tripo at all: import it with `asset(action="import_model", filePath="...", kind="skeletal")`.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,9 @@
|
|
|
5
5
|
* not on the load path. It gives consumers a typed import surface.
|
|
6
6
|
*/
|
|
7
7
|
export { default as Generate, makeArgs, chainFor } from "./tasks/Generate.js";
|
|
8
|
+
export { default as PrepareImages } from "./tasks/PrepareImages.js";
|
|
9
|
+
export { default as Loadouts } from "./tasks/Loadouts.js";
|
|
10
|
+
export { resolveOptions, loadoutsFrom } from "./shared/loadouts.js";
|
|
11
|
+
export { prepareViews } from "./shared/images.js";
|
|
8
12
|
export { default as Cli } from "./tasks/Cli.js";
|
|
9
13
|
export { cliPath, cliVersion, runCli, withAddedFlags, ADDED_FLAGS } from "./shared/cli.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* not on the load path. It gives consumers a typed import surface.
|
|
6
6
|
*/
|
|
7
7
|
export { default as Generate, makeArgs, chainFor } from "./tasks/Generate.js";
|
|
8
|
+
export { default as PrepareImages } from "./tasks/PrepareImages.js";
|
|
9
|
+
export { default as Loadouts } from "./tasks/Loadouts.js";
|
|
10
|
+
export { resolveOptions, loadoutsFrom } from "./shared/loadouts.js";
|
|
11
|
+
export { prepareViews } from "./shared/images.js";
|
|
8
12
|
export { default as Cli } from "./tasks/Cli.js";
|
|
9
13
|
export { cliPath, cliVersion, runCli, withAddedFlags, ADDED_FLAGS } from "./shared/cli.js";
|
|
10
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const VIEW_KEYS: readonly ["front", "left", "back", "right"];
|
|
2
|
+
export type ViewKey = (typeof VIEW_KEYS)[number];
|
|
3
|
+
export type ViewMap = Partial<Record<ViewKey, string>>;
|
|
4
|
+
export declare const MIN_EDGE_PX = 256;
|
|
5
|
+
export declare const WARN_EDGE_PX = 1024;
|
|
6
|
+
export declare const MAX_BYTES: number;
|
|
7
|
+
export declare const DEFAULT_CANVAS_PX = 1600;
|
|
8
|
+
export declare const DEFAULT_FILL = 0.75;
|
|
9
|
+
export interface PrepareOptions {
|
|
10
|
+
views: ViewMap;
|
|
11
|
+
outDir: string;
|
|
12
|
+
/** Square canvas edge in pixels (default 1600). */
|
|
13
|
+
canvas?: number;
|
|
14
|
+
/** Fraction of the canvas the subject fills in its limiting dimension (default 0.75). */
|
|
15
|
+
fill?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface PreparedView {
|
|
18
|
+
view: ViewKey;
|
|
19
|
+
source: string;
|
|
20
|
+
output: string;
|
|
21
|
+
sourceSize: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
/** Subject box in the source, in pixels. */
|
|
26
|
+
subject: {
|
|
27
|
+
left: number;
|
|
28
|
+
top: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
/** Subject box on the output canvas. */
|
|
33
|
+
placed: {
|
|
34
|
+
left: number;
|
|
35
|
+
top: number;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
/** Share of the canvas width and height the subject covers. */
|
|
40
|
+
fillWidth: number;
|
|
41
|
+
fillHeight: number;
|
|
42
|
+
}
|
|
43
|
+
export interface PrepareResult {
|
|
44
|
+
outDir: string;
|
|
45
|
+
files: ViewMap;
|
|
46
|
+
canvas: number;
|
|
47
|
+
scale: number;
|
|
48
|
+
/** Canvas row where every view's feet sit. */
|
|
49
|
+
baselineY: number;
|
|
50
|
+
views: PreparedView[];
|
|
51
|
+
warnings: string[];
|
|
52
|
+
}
|
|
53
|
+
/** Whether a name is one of the four view keys. */
|
|
54
|
+
export declare function isViewKey(s: string): s is ViewKey;
|
|
55
|
+
/** The view a file name says it is (front.png, hero_Left.jpg), or null. */
|
|
56
|
+
export declare function viewFromName(path: string): ViewKey | null;
|
|
57
|
+
/**
|
|
58
|
+
* Name a list of image files by view: a file name that says its view keeps it,
|
|
59
|
+
* the rest take the free slots in front, left, back, right order (the order
|
|
60
|
+
* tripo-cli uses for unnamed inputs).
|
|
61
|
+
*/
|
|
62
|
+
export declare function viewsFromFiles(files: string[]): ViewMap;
|
|
63
|
+
/** The views as given, checked for names and the front-plus-one rule. */
|
|
64
|
+
export declare function normalizeViews(views: Record<string, unknown>): ViewMap;
|
|
65
|
+
/**
|
|
66
|
+
* The views a call names, as a map or as files: null when none are given, and
|
|
67
|
+
* `remote` when a file is a URL (those cannot be prepared locally).
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveViews(views: Record<string, unknown> | undefined, images: string[] | string | undefined): {
|
|
70
|
+
views: ViewMap;
|
|
71
|
+
remote: boolean;
|
|
72
|
+
} | null;
|
|
73
|
+
/** Checks that need no pixels: the file exists, is within limits, and is an image. */
|
|
74
|
+
export declare function inspectSource(view: ViewKey, file: string): Promise<{
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
warnings: string[];
|
|
78
|
+
}>;
|
|
79
|
+
/** Prepare the views into outDir. Nothing is written when validation fails. */
|
|
80
|
+
export declare function prepareViews(opts: PrepareOptions): Promise<PrepareResult>;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turnaround image preparation for multiview generation.
|
|
3
|
+
*
|
|
4
|
+
* Reads the views a caller names, checks them against Tripo's input limits and
|
|
5
|
+
* writes a matching set into a job folder: one white canvas size, one shared
|
|
6
|
+
* scale and one shared baseline, so head and feet sit at the same heights in
|
|
7
|
+
* every view. Originals are never modified. The outputs are named front.png,
|
|
8
|
+
* left.png, back.png and right.png, which is how tripo-cli reads the view of
|
|
9
|
+
* each input.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, statSync } from "node:fs";
|
|
12
|
+
import { basename, extname, join, resolve } from "node:path";
|
|
13
|
+
import sharp from "sharp";
|
|
14
|
+
export const VIEW_KEYS = ["front", "left", "back", "right"];
|
|
15
|
+
export const MIN_EDGE_PX = 256;
|
|
16
|
+
export const WARN_EDGE_PX = 1024;
|
|
17
|
+
export const MAX_BYTES = 20 * 1024 * 1024;
|
|
18
|
+
export const DEFAULT_CANVAS_PX = 1600;
|
|
19
|
+
export const DEFAULT_FILL = 0.75;
|
|
20
|
+
/** Pixels this far from the background (max channel difference) count as subject. */
|
|
21
|
+
const SUBJECT_DIFF = 28;
|
|
22
|
+
/** Alpha at or above this counts as subject when the source has transparency. */
|
|
23
|
+
const SUBJECT_ALPHA = 32;
|
|
24
|
+
/** A row or column needs this many subject pixels to count, which ignores specks. */
|
|
25
|
+
const MIN_RUN = 2;
|
|
26
|
+
/** Head tops further apart than this fraction of the canvas are reported. */
|
|
27
|
+
const HEAD_DRIFT = 0.02;
|
|
28
|
+
/** Whether a name is one of the four view keys. */
|
|
29
|
+
export function isViewKey(s) {
|
|
30
|
+
return VIEW_KEYS.includes(s);
|
|
31
|
+
}
|
|
32
|
+
/** The view a file name says it is (front.png, hero_Left.jpg), or null. */
|
|
33
|
+
export function viewFromName(path) {
|
|
34
|
+
const stem = basename(path, extname(path)).toLowerCase();
|
|
35
|
+
const hits = VIEW_KEYS.filter((k) => new RegExp(`(^|[^a-z])${k}([^a-z]|$)`).test(stem));
|
|
36
|
+
return hits.length === 1 ? hits[0] : null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Name a list of image files by view: a file name that says its view keeps it,
|
|
40
|
+
* the rest take the free slots in front, left, back, right order (the order
|
|
41
|
+
* tripo-cli uses for unnamed inputs).
|
|
42
|
+
*/
|
|
43
|
+
export function viewsFromFiles(files) {
|
|
44
|
+
const out = {};
|
|
45
|
+
const unnamed = [];
|
|
46
|
+
for (const f of files) {
|
|
47
|
+
const v = viewFromName(f);
|
|
48
|
+
if (v && !out[v])
|
|
49
|
+
out[v] = f;
|
|
50
|
+
else
|
|
51
|
+
unnamed.push(f);
|
|
52
|
+
}
|
|
53
|
+
for (const f of unnamed) {
|
|
54
|
+
const slot = VIEW_KEYS.find((k) => !out[k]);
|
|
55
|
+
if (!slot)
|
|
56
|
+
throw new Error("A turnaround takes at most 4 views: front, left, back, right.");
|
|
57
|
+
out[slot] = f;
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** The views as given, checked for names and the front-plus-one rule. */
|
|
62
|
+
export function normalizeViews(views) {
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [k, v] of Object.entries(views)) {
|
|
65
|
+
const key = k.toLowerCase();
|
|
66
|
+
if (!isViewKey(key))
|
|
67
|
+
throw new Error(`Unknown view "${k}". Name views front, left, back or right.`);
|
|
68
|
+
if (typeof v !== "string" || !v)
|
|
69
|
+
throw new Error(`View "${k}" needs an image file path.`);
|
|
70
|
+
out[key] = v;
|
|
71
|
+
}
|
|
72
|
+
if (!out.front)
|
|
73
|
+
throw new Error("A turnaround needs a front view.");
|
|
74
|
+
if (Object.keys(out).length < 2)
|
|
75
|
+
throw new Error("A turnaround needs the front view plus at least one other (left, back or right).");
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
const isUrl = (s) => /^[a-z][a-z0-9+.-]*:\/\//i.test(s);
|
|
79
|
+
/**
|
|
80
|
+
* The views a call names, as a map or as files: null when none are given, and
|
|
81
|
+
* `remote` when a file is a URL (those cannot be prepared locally).
|
|
82
|
+
*/
|
|
83
|
+
export function resolveViews(views, images) {
|
|
84
|
+
if (views && Object.keys(views).length)
|
|
85
|
+
return { views: normalizeViews(views), remote: Object.values(views).some((v) => isUrl(String(v))) };
|
|
86
|
+
const list = images == null ? [] : (Array.isArray(images) ? images : [images]).filter((s) => s !== "");
|
|
87
|
+
if (list.length < 2)
|
|
88
|
+
return null;
|
|
89
|
+
const map = viewsFromFiles(list);
|
|
90
|
+
if (!map.front)
|
|
91
|
+
throw new Error("A turnaround needs a front view. Name the front file front.png, or pass views={front: ...}.");
|
|
92
|
+
return { views: map, remote: list.some(isUrl) };
|
|
93
|
+
}
|
|
94
|
+
/** Composite the source onto white and find the subject's bounding box. */
|
|
95
|
+
async function analyze(view, file) {
|
|
96
|
+
const { data, info } = await sharp(file).rotate().ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
97
|
+
const { width, height } = info;
|
|
98
|
+
const warnings = [];
|
|
99
|
+
const n = width * height;
|
|
100
|
+
const mask = new Uint8Array(n);
|
|
101
|
+
const rgb = Buffer.alloc(n * 3);
|
|
102
|
+
let hasAlpha = false;
|
|
103
|
+
for (let i = 0; i < n; i++) {
|
|
104
|
+
if (data[i * 4 + 3] < 250) {
|
|
105
|
+
hasAlpha = true;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (hasAlpha) {
|
|
110
|
+
for (let i = 0; i < n; i++) {
|
|
111
|
+
const a = data[i * 4 + 3] / 255;
|
|
112
|
+
for (let c = 0; c < 3; c++)
|
|
113
|
+
rgb[i * 3 + c] = Math.round(data[i * 4 + c] * a + 255 * (1 - a));
|
|
114
|
+
mask[i] = data[i * 4 + 3] >= SUBJECT_ALPHA ? 1 : 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Opaque source: the background is the mean colour of the border.
|
|
119
|
+
const sum = [0, 0, 0];
|
|
120
|
+
let count = 0;
|
|
121
|
+
const border = (x, y) => {
|
|
122
|
+
const o = (y * width + x) * 4;
|
|
123
|
+
for (let c = 0; c < 3; c++)
|
|
124
|
+
sum[c] += data[o + c];
|
|
125
|
+
count++;
|
|
126
|
+
};
|
|
127
|
+
for (let x = 0; x < width; x++) {
|
|
128
|
+
border(x, 0);
|
|
129
|
+
border(x, height - 1);
|
|
130
|
+
}
|
|
131
|
+
for (let y = 1; y < height - 1; y++) {
|
|
132
|
+
border(0, y);
|
|
133
|
+
border(width - 1, y);
|
|
134
|
+
}
|
|
135
|
+
const bg = sum.map((s) => s / count);
|
|
136
|
+
let offBg = 0;
|
|
137
|
+
const diff = new Uint8Array(n);
|
|
138
|
+
for (let i = 0; i < n; i++) {
|
|
139
|
+
let d = 0;
|
|
140
|
+
for (let c = 0; c < 3; c++)
|
|
141
|
+
d = Math.max(d, Math.abs(data[i * 4 + c] - bg[c]));
|
|
142
|
+
diff[i] = d;
|
|
143
|
+
}
|
|
144
|
+
const borderIdx = (i) => {
|
|
145
|
+
const x = i % width;
|
|
146
|
+
const y = (i - x) / width;
|
|
147
|
+
return x === 0 || y === 0 || x === width - 1 || y === height - 1;
|
|
148
|
+
};
|
|
149
|
+
for (let i = 0; i < n; i++)
|
|
150
|
+
if (borderIdx(i) && diff[i] > SUBJECT_DIFF)
|
|
151
|
+
offBg++;
|
|
152
|
+
const uniform = offBg <= count * 0.02;
|
|
153
|
+
const nearWhite = bg.every((v) => v >= 245);
|
|
154
|
+
if (!nearWhite && !uniform) {
|
|
155
|
+
warnings.push(`${view}: the background is not a plain colour, so it is kept as is. Remove it or use a plain white or light gray one.`);
|
|
156
|
+
}
|
|
157
|
+
for (let i = 0; i < n; i++) {
|
|
158
|
+
mask[i] = diff[i] > SUBJECT_DIFF ? 1 : 0;
|
|
159
|
+
if (nearWhite || !uniform) {
|
|
160
|
+
for (let c = 0; c < 3; c++)
|
|
161
|
+
rgb[i * 3 + c] = data[i * 4 + c];
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// Plain non-white background: blend it out to white by distance.
|
|
165
|
+
const t = Math.min(1, Math.max(0, (diff[i] - 6) / 22));
|
|
166
|
+
for (let c = 0; c < 3; c++)
|
|
167
|
+
rgb[i * 3 + c] = Math.round(data[i * 4 + c] * t + 255 * (1 - t));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const rows = new Uint32Array(height);
|
|
172
|
+
const cols = new Uint32Array(width);
|
|
173
|
+
for (let y = 0; y < height; y++) {
|
|
174
|
+
for (let x = 0; x < width; x++) {
|
|
175
|
+
if (mask[y * width + x]) {
|
|
176
|
+
rows[y]++;
|
|
177
|
+
cols[x]++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const first = (arr) => arr.findIndex((v) => v >= MIN_RUN);
|
|
182
|
+
const last = (arr) => {
|
|
183
|
+
for (let i = arr.length - 1; i >= 0; i--)
|
|
184
|
+
if (arr[i] >= MIN_RUN)
|
|
185
|
+
return i;
|
|
186
|
+
return -1;
|
|
187
|
+
};
|
|
188
|
+
const top = first(rows);
|
|
189
|
+
const bottom = last(rows);
|
|
190
|
+
const left = first(cols);
|
|
191
|
+
const right = last(cols);
|
|
192
|
+
if (top < 0 || left < 0)
|
|
193
|
+
throw new Error(`${view}: no subject found. The image is empty or matches its background.`);
|
|
194
|
+
return {
|
|
195
|
+
rgb,
|
|
196
|
+
width,
|
|
197
|
+
height,
|
|
198
|
+
bbox: { left, top, width: right - left + 1, height: bottom - top + 1 },
|
|
199
|
+
touchesEdge: top === 0 || left === 0 || bottom === height - 1 || right === width - 1,
|
|
200
|
+
warnings,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** Checks that need no pixels: the file exists, is within limits, and is an image. */
|
|
204
|
+
export async function inspectSource(view, file) {
|
|
205
|
+
if (!existsSync(file))
|
|
206
|
+
throw new Error(`${view}: ${file} does not exist.`);
|
|
207
|
+
const bytes = statSync(file).size;
|
|
208
|
+
if (bytes > MAX_BYTES) {
|
|
209
|
+
throw new Error(`${view}: ${file} is ${(bytes / 1048576).toFixed(1)} MB; Tripo accepts at most 20 MB per image.`);
|
|
210
|
+
}
|
|
211
|
+
let meta;
|
|
212
|
+
try {
|
|
213
|
+
meta = await sharp(file).metadata();
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
throw new Error(`${view}: ${file} is not a readable image (${e.message}).`);
|
|
217
|
+
}
|
|
218
|
+
const rotated = (meta.orientation ?? 1) >= 5;
|
|
219
|
+
const width = (rotated ? meta.height : meta.width) ?? 0;
|
|
220
|
+
const height = (rotated ? meta.width : meta.height) ?? 0;
|
|
221
|
+
if (Math.min(width, height) < MIN_EDGE_PX) {
|
|
222
|
+
throw new Error(`${view}: ${file} is ${width}x${height}; Tripo needs at least ${MIN_EDGE_PX} px on every side.`);
|
|
223
|
+
}
|
|
224
|
+
const warnings = [];
|
|
225
|
+
if (Math.max(width, height) < WARN_EDGE_PX) {
|
|
226
|
+
warnings.push(`${view}: ${width}x${height} is below ${WARN_EDGE_PX} px; detail will be soft. Tripo recommends at least ${WARN_EDGE_PX} px.`);
|
|
227
|
+
}
|
|
228
|
+
return { width, height, warnings };
|
|
229
|
+
}
|
|
230
|
+
/** Prepare the views into outDir. Nothing is written when validation fails. */
|
|
231
|
+
export async function prepareViews(opts) {
|
|
232
|
+
const views = normalizeViews(opts.views);
|
|
233
|
+
const canvas = Math.round(opts.canvas ?? DEFAULT_CANVAS_PX);
|
|
234
|
+
const fill = opts.fill ?? DEFAULT_FILL;
|
|
235
|
+
if (canvas < MIN_EDGE_PX)
|
|
236
|
+
throw new Error(`canvas must be at least ${MIN_EDGE_PX} px.`);
|
|
237
|
+
if (!(fill > 0 && fill <= 0.95))
|
|
238
|
+
throw new Error("fill must be between 0 and 0.95.");
|
|
239
|
+
const outDir = resolve(opts.outDir);
|
|
240
|
+
const warnings = [];
|
|
241
|
+
const entries = Object.entries(views);
|
|
242
|
+
const sources = new Map();
|
|
243
|
+
for (const [view, file] of entries) {
|
|
244
|
+
const abs = resolve(file);
|
|
245
|
+
if (join(outDir, `${view}.png`).toLowerCase() === abs.toLowerCase()) {
|
|
246
|
+
throw new Error(`${view}: the output folder holds the source file ${abs}. Pick another outDir; originals are never overwritten.`);
|
|
247
|
+
}
|
|
248
|
+
sources.set(view, abs);
|
|
249
|
+
}
|
|
250
|
+
const analyses = new Map();
|
|
251
|
+
const sizes = new Map();
|
|
252
|
+
for (const view of VIEW_KEYS) {
|
|
253
|
+
const file = sources.get(view);
|
|
254
|
+
if (!file)
|
|
255
|
+
continue;
|
|
256
|
+
const info = await inspectSource(view, file);
|
|
257
|
+
warnings.push(...info.warnings);
|
|
258
|
+
sizes.set(view, info);
|
|
259
|
+
const a = await analyze(view, file);
|
|
260
|
+
warnings.push(...a.warnings);
|
|
261
|
+
if (a.touchesEdge) {
|
|
262
|
+
warnings.push(`${view}: the subject touches the image edge, so it may be cropped. Re-export with margin on every side.`);
|
|
263
|
+
}
|
|
264
|
+
analyses.set(view, a);
|
|
265
|
+
}
|
|
266
|
+
const distinct = new Set([...sizes.values()].map((s) => `${s.width}x${s.height}`));
|
|
267
|
+
if (distinct.size > 1) {
|
|
268
|
+
warnings.push(`The views have different source sizes (${[...distinct].join(", ")}). One shared scale assumes they were drawn at the same scale; ` +
|
|
269
|
+
`export every view from the same canvas for matching heights.`);
|
|
270
|
+
}
|
|
271
|
+
// One scale for every view: the largest subject lands at `fill` of the canvas
|
|
272
|
+
// in its limiting dimension, and every other view keeps its size relative to it.
|
|
273
|
+
const box = canvas * fill;
|
|
274
|
+
let scale = Infinity;
|
|
275
|
+
for (const a of analyses.values())
|
|
276
|
+
scale = Math.min(scale, box / a.bbox.width, box / a.bbox.height);
|
|
277
|
+
// One baseline: the tallest figure is centred vertically and every view's
|
|
278
|
+
// feet sit on the same row.
|
|
279
|
+
const tallest = Math.max(...[...analyses.values()].map((a) => a.bbox.height * scale));
|
|
280
|
+
const baselineY = Math.round((canvas + tallest) / 2);
|
|
281
|
+
mkdirSync(outDir, { recursive: true });
|
|
282
|
+
const prepared = [];
|
|
283
|
+
const files = {};
|
|
284
|
+
for (const view of VIEW_KEYS) {
|
|
285
|
+
const a = analyses.get(view);
|
|
286
|
+
if (!a)
|
|
287
|
+
continue;
|
|
288
|
+
const w = Math.max(1, Math.round(a.bbox.width * scale));
|
|
289
|
+
const h = Math.max(1, Math.round(a.bbox.height * scale));
|
|
290
|
+
const crop = await sharp(a.rgb, { raw: { width: a.width, height: a.height, channels: 3 } })
|
|
291
|
+
.extract({ left: a.bbox.left, top: a.bbox.top, width: a.bbox.width, height: a.bbox.height })
|
|
292
|
+
.resize(w, h, { kernel: "lanczos3", fit: "fill" })
|
|
293
|
+
.png()
|
|
294
|
+
.toBuffer();
|
|
295
|
+
const left = Math.min(canvas - w, Math.max(0, Math.round((canvas - w) / 2)));
|
|
296
|
+
const top = Math.max(0, baselineY - h);
|
|
297
|
+
const output = join(outDir, `${view}.png`);
|
|
298
|
+
await sharp({ create: { width: canvas, height: canvas, channels: 3, background: "#ffffff" } })
|
|
299
|
+
.composite([{ input: crop, left, top }])
|
|
300
|
+
.removeAlpha()
|
|
301
|
+
.png({ compressionLevel: 9 })
|
|
302
|
+
.toFile(output);
|
|
303
|
+
files[view] = output;
|
|
304
|
+
prepared.push({
|
|
305
|
+
view,
|
|
306
|
+
source: sources.get(view),
|
|
307
|
+
output,
|
|
308
|
+
sourceSize: sizes.get(view),
|
|
309
|
+
subject: a.bbox,
|
|
310
|
+
placed: { left, top, width: w, height: h },
|
|
311
|
+
fillWidth: w / canvas,
|
|
312
|
+
fillHeight: h / canvas,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
const tops = prepared.map((p) => p.placed.top);
|
|
316
|
+
if (Math.max(...tops) - Math.min(...tops) > canvas * HEAD_DRIFT) {
|
|
317
|
+
warnings.push(`Head tops differ between views by ${Math.max(...tops) - Math.min(...tops)} px. Feet share a baseline, but the figures are not the same height; ` +
|
|
318
|
+
`check that every view shows the same pose and scale.`);
|
|
319
|
+
}
|
|
320
|
+
return { outDir, files, canvas, scale, baselineY, views: prepared, warnings };
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../src/shared/images.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,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QAAQ,CAAC,IAAI,CACX,qCAAqC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,uEAAuE;YAC/I,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loadouts: named bundles of generate settings.
|
|
3
|
+
*
|
|
4
|
+
* ue-mcp merges them for the plugin and hands the result over as
|
|
5
|
+
* `this.config.loadouts`: the built-ins from `config.loadouts` in
|
|
6
|
+
* ue-mcp.plugin.yml, deep-merged with the project's
|
|
7
|
+
* `ue-mcp.pluginConfig.tripo.loadouts` in the project's config. Nothing here reads a file.
|
|
8
|
+
*
|
|
9
|
+
* A call resolves in this order, later winning per field: the loadout (after
|
|
10
|
+
* the loadouts it `extends`), then the explicit options of the call. Every
|
|
11
|
+
* resolved field remembers where it came from.
|
|
12
|
+
*/
|
|
13
|
+
/** The generate options a loadout may set. */
|
|
14
|
+
export declare const LOADOUT_FIELDS: readonly ["model", "rig", "rigType", "spec", "animation", "pbr", "format", "segmentHint", "faceLimit", "textureQuality", "params", "then", "kind", "destination", "importMaterials", "importTextures", "importAnimations", "createPhysicsAsset", "nanite", "place", "onConflict", "save"];
|
|
15
|
+
export type LoadoutField = (typeof LOADOUT_FIELDS)[number];
|
|
16
|
+
export interface Loadout {
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Another loadout this one starts from. */
|
|
19
|
+
extends?: string;
|
|
20
|
+
/** Advice for the agent that picks it, returned with results. */
|
|
21
|
+
guidance?: string;
|
|
22
|
+
[field: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
export type LoadoutMap = Record<string, Loadout>;
|
|
25
|
+
/** Setting to the place it came from: "loadout:humanoid", "option" or "param:face_limit". */
|
|
26
|
+
export type Sources = Record<string, string>;
|
|
27
|
+
export interface Resolved {
|
|
28
|
+
options: Record<string, unknown>;
|
|
29
|
+
sources: Sources;
|
|
30
|
+
loadout?: string;
|
|
31
|
+
guidance?: string;
|
|
32
|
+
warnings: string[];
|
|
33
|
+
}
|
|
34
|
+
/** The plugin's merged config as ue-mcp hands it to a task (`this.config`), or undefined on an older server. */
|
|
35
|
+
export declare function configOf(task: object): unknown;
|
|
36
|
+
/** The loadouts in a plugin config, without removed (null) entries. */
|
|
37
|
+
export declare function loadoutsFrom(config: unknown): LoadoutMap;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a call's options: loadout fields first, explicit options over them.
|
|
40
|
+
* faceLimit, textureQuality and params all end up as one `params` list of
|
|
41
|
+
* key=value pairs where the last word on a key wins.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveOptions(explicit: Record<string, unknown>, all: LoadoutMap): Resolved;
|
|
44
|
+
/** What a loadout resolves to on its own, for the loadouts action. */
|
|
45
|
+
export declare function describeLoadout(name: string, all: LoadoutMap): {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string | undefined;
|
|
48
|
+
extends: string | undefined;
|
|
49
|
+
guidance: string | undefined;
|
|
50
|
+
settings: Record<string, unknown>;
|
|
51
|
+
params: {
|
|
52
|
+
[k: string]: string;
|
|
53
|
+
};
|
|
54
|
+
sources: Sources;
|
|
55
|
+
warnings: string[];
|
|
56
|
+
};
|