修改图生3D,支持多图上传
This commit is contained in:
parent
a8b9f658a0
commit
7f8e28a4af
@ -62,13 +62,44 @@ export class AI3DService {
|
||||
|
||||
// 3. 提交到 AI 服务
|
||||
try {
|
||||
// 构建生成选项
|
||||
const options: any = {
|
||||
generateType: dto.generateType,
|
||||
faceCount: dto.faceCount,
|
||||
};
|
||||
|
||||
// 处理多视图图片(图生3D支持)
|
||||
if (dto.inputType === 'image' && dto.multiViewImages) {
|
||||
const viewKeyMap: Record<string, string> = {
|
||||
left: 'left',
|
||||
right: 'right',
|
||||
back: 'back',
|
||||
top: 'top',
|
||||
bottom: 'bottom',
|
||||
left45: 'left_front',
|
||||
right45: 'right_front',
|
||||
};
|
||||
|
||||
const multiViewImages: { viewType: string; imageUrl: string }[] = [];
|
||||
for (const [key, url] of Object.entries(dto.multiViewImages)) {
|
||||
if (url && key !== 'front' && viewKeyMap[key]) {
|
||||
multiViewImages.push({
|
||||
viewType: viewKeyMap[key],
|
||||
imageUrl: url,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (multiViewImages.length > 0) {
|
||||
options.multiViewImages = multiViewImages;
|
||||
this.logger.log(`多视图模式: ${multiViewImages.length} 张额外视图`);
|
||||
}
|
||||
}
|
||||
|
||||
const externalTaskId = await this.ai3dProvider.submitTask(
|
||||
dto.inputType,
|
||||
dto.inputContent,
|
||||
{
|
||||
generateType: dto.generateType,
|
||||
faceCount: dto.faceCount,
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
// 4. 更新状态为处理中
|
||||
|
||||
@ -7,6 +7,7 @@ import {
|
||||
IsInt,
|
||||
Min,
|
||||
Max,
|
||||
IsObject,
|
||||
} from 'class-validator';
|
||||
|
||||
/**
|
||||
@ -18,6 +19,21 @@ import {
|
||||
*/
|
||||
export type GenerateType = 'Normal' | 'LowPoly' | 'Geometry' | 'Sketch';
|
||||
|
||||
/**
|
||||
* 多视图图片类型
|
||||
* 支持的视角:left, right, back, top, bottom, left_front (左前45°), right_front (右前45°)
|
||||
*/
|
||||
export type MultiViewImages = {
|
||||
front?: string; // 正图(作为主图)
|
||||
left?: string; // 左视图
|
||||
right?: string; // 右视图
|
||||
back?: string; // 后视图
|
||||
top?: string; // 顶视图
|
||||
bottom?: string; // 底视图
|
||||
left45?: string; // 左前45°视图 -> left_front
|
||||
right45?: string; // 右前45°视图 -> right_front
|
||||
};
|
||||
|
||||
export class CreateTaskDto {
|
||||
@IsString()
|
||||
@IsIn(['text', 'image'], { message: '输入类型必须是 text 或 image' })
|
||||
@ -40,4 +56,8 @@ export class CreateTaskDto {
|
||||
@Min(10000, { message: '模型面数最小为10000' })
|
||||
@Max(1500000, { message: '模型面数最大为1500000' })
|
||||
faceCount?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject({ message: '多视图图片必须是对象' })
|
||||
multiViewImages?: MultiViewImages;
|
||||
}
|
||||
|
||||
@ -11,6 +11,14 @@ export interface AI3DGenerateResult {
|
||||
errorMessage?: string; // 错误信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 多视图图片
|
||||
*/
|
||||
export interface MultiViewImage {
|
||||
viewType: string; // left, right, back, top, bottom, left_front, right_front
|
||||
imageUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型生成配置选项
|
||||
*/
|
||||
@ -19,6 +27,8 @@ export interface AI3DGenerateOptions {
|
||||
generateType?: 'Normal' | 'LowPoly' | 'Geometry' | 'Sketch';
|
||||
/** 模型面数:10000-1500000,默认500000 */
|
||||
faceCount?: number;
|
||||
/** 多视图图片(图生3D支持) */
|
||||
multiViewImages?: MultiViewImage[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -85,10 +85,22 @@ export class HunyuanAI3DProvider implements AI3DProvider {
|
||||
payload.GenerateType = options.generateType;
|
||||
}
|
||||
|
||||
this.logger.log(
|
||||
`提交图生3D任务: ${inputContent.substring(0, 50)}... ` +
|
||||
`[类型: ${options?.generateType || 'Normal'}]`,
|
||||
);
|
||||
// 多视图图片支持
|
||||
if (options?.multiViewImages && options.multiViewImages.length > 0) {
|
||||
payload.MultiViewImages = options.multiViewImages.map((img) => ({
|
||||
ViewType: img.viewType,
|
||||
ViewImageUrl: img.imageUrl,
|
||||
}));
|
||||
this.logger.log(
|
||||
`提交图生3D任务(多视图): ${options.multiViewImages.length} 张图片 ` +
|
||||
`[类型: ${options?.generateType || 'Normal'}]`,
|
||||
);
|
||||
} else {
|
||||
this.logger.log(
|
||||
`提交图生3D任务: ${inputContent.substring(0, 50)}... ` +
|
||||
`[类型: ${options?.generateType || 'Normal'}]`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 生成签名和请求头
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user