@joplo-app/plugin-3d 0.0.0-stage → 0.4.1
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/LICENSE +97 -0
- package/README.md +19 -2
- package/dist/guide.d.ts +3 -0
- package/dist/guide.js +96 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +39 -0
- package/dist/label.d.ts +2 -0
- package/dist/label.js +5 -0
- package/dist/local.d.ts +35 -0
- package/dist/local.js +199 -0
- package/dist/model.d.ts +5 -0
- package/dist/model.js +48 -0
- package/dist/request.d.ts +33 -0
- package/dist/request.js +33 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +863 -0
- package/dist/version.json +3 -0
- package/package.json +50 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Author-only input. Only this allowlist can be serialized or sent to Tripo. */
|
|
2
|
+
export type ModelOptions = {
|
|
3
|
+
prompt: string;
|
|
4
|
+
image?: string;
|
|
5
|
+
model?: 'v3.1-20260211';
|
|
6
|
+
texture?: boolean;
|
|
7
|
+
pbr?: boolean;
|
|
8
|
+
texture_quality?: 'standard' | 'detailed';
|
|
9
|
+
smart_low_poly?: boolean;
|
|
10
|
+
face_limit?: number;
|
|
11
|
+
compress?: 'geometry';
|
|
12
|
+
model_seed?: number;
|
|
13
|
+
texture_seed?: number;
|
|
14
|
+
image_seed?: number;
|
|
15
|
+
negative_prompt?: string;
|
|
16
|
+
};
|
|
17
|
+
export type ModelRequest = ReturnType<typeof normalize>;
|
|
18
|
+
export declare function normalize(input: ModelOptions): {
|
|
19
|
+
image?: string | undefined;
|
|
20
|
+
negative_prompt?: string | undefined;
|
|
21
|
+
model_seed?: number | undefined;
|
|
22
|
+
texture_seed?: number | undefined;
|
|
23
|
+
image_seed?: number | undefined;
|
|
24
|
+
compress?: "geometry" | undefined;
|
|
25
|
+
prompt: string;
|
|
26
|
+
model: "v3.1-20260211";
|
|
27
|
+
texture: boolean;
|
|
28
|
+
pbr: boolean;
|
|
29
|
+
texture_quality: "standard" | "detailed";
|
|
30
|
+
smart_low_poly: boolean;
|
|
31
|
+
face_limit: number;
|
|
32
|
+
};
|
|
33
|
+
export declare const estimate: (r: ModelRequest) => number;
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function normalize(input) {
|
|
2
|
+
const fail = (message) => { throw Object.assign(new Error(message), { code: 'LOCAL_RESOURCE_TRIPO_INPUT' }); };
|
|
3
|
+
if (!input || typeof input.prompt !== 'string' || !input.prompt.trim() || input.prompt.length > 1024)
|
|
4
|
+
fail('A nonempty description of at most 1024 characters is required.');
|
|
5
|
+
if (input.model !== undefined && input.model !== 'v3.1-20260211')
|
|
6
|
+
fail('Supported model: v3.1-20260211; pricing must be verified before adding another version.');
|
|
7
|
+
for (const k of ['texture', 'pbr', 'smart_low_poly'])
|
|
8
|
+
if (input[k] !== undefined && typeof input[k] !== 'boolean')
|
|
9
|
+
fail(`Invalid ${k}`);
|
|
10
|
+
const texture = input.texture ?? true, pbr = input.pbr ?? texture, smart = input.smart_low_poly ?? true;
|
|
11
|
+
if (pbr && !texture)
|
|
12
|
+
fail('pbr requires texture');
|
|
13
|
+
const face_limit = input.face_limit ?? 10000;
|
|
14
|
+
if (!Number.isInteger(face_limit) || face_limit < 500 || face_limit > (smart ? 20000 : 50000))
|
|
15
|
+
fail('face_limit must be 500–20000 with smart_low_poly, or 500–50000 without it.');
|
|
16
|
+
if (input.texture_quality !== undefined && !['standard', 'detailed'].includes(input.texture_quality))
|
|
17
|
+
fail('texture_quality must be standard or detailed');
|
|
18
|
+
if (input.compress !== undefined && input.compress !== 'geometry')
|
|
19
|
+
fail('compress must be geometry');
|
|
20
|
+
if (input.negative_prompt !== undefined && (typeof input.negative_prompt !== 'string' || input.negative_prompt.length > 255))
|
|
21
|
+
fail('negative_prompt must be at most 255 characters');
|
|
22
|
+
const seeds = {};
|
|
23
|
+
for (const k of ['model_seed', 'texture_seed', 'image_seed'])
|
|
24
|
+
if (input[k] !== undefined) {
|
|
25
|
+
if (!Number.isSafeInteger(input[k]) || input[k] < 0)
|
|
26
|
+
fail(`Invalid ${k}`);
|
|
27
|
+
seeds[k] = input[k];
|
|
28
|
+
}
|
|
29
|
+
if (input.image !== undefined && (typeof input.image !== 'string' || !/^data:image\/(png|jpeg);base64,[A-Za-z0-9+/]+=*$/.test(input.image) || input.image.length > 28 * 1024 * 1024))
|
|
30
|
+
fail('Reference image must be asset() PNG/JPEG, at most 20 MB.');
|
|
31
|
+
return { prompt: input.prompt.trim(), model: 'v3.1-20260211', texture, pbr, texture_quality: input.texture_quality ?? 'standard', smart_low_poly: smart, face_limit, ...(input.compress ? { compress: input.compress } : {}), ...seeds, ...(input.negative_prompt ? { negative_prompt: input.negative_prompt } : {}), ...(input.image ? { image: input.image } : {}) };
|
|
32
|
+
}
|
|
33
|
+
export const estimate = (r) => (r.image ? 20 : 10) + (r.texture ? 10 : 0) + (r.texture && r.texture_quality === 'detailed' ? 10 : 0) + (r.smart_low_poly ? 10 : 0);
|