修改图生3D,支持多图上传
This commit is contained in:
parent
a8b9f658a0
commit
7f8e28a4af
@ -62,13 +62,44 @@ export class AI3DService {
|
|||||||
|
|
||||||
// 3. 提交到 AI 服务
|
// 3. 提交到 AI 服务
|
||||||
try {
|
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(
|
const externalTaskId = await this.ai3dProvider.submitTask(
|
||||||
dto.inputType,
|
dto.inputType,
|
||||||
dto.inputContent,
|
dto.inputContent,
|
||||||
{
|
options,
|
||||||
generateType: dto.generateType,
|
|
||||||
faceCount: dto.faceCount,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// 4. 更新状态为处理中
|
// 4. 更新状态为处理中
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
IsInt,
|
IsInt,
|
||||||
Min,
|
Min,
|
||||||
Max,
|
Max,
|
||||||
|
IsObject,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,6 +19,21 @@ import {
|
|||||||
*/
|
*/
|
||||||
export type GenerateType = 'Normal' | 'LowPoly' | 'Geometry' | 'Sketch';
|
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 {
|
export class CreateTaskDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsIn(['text', 'image'], { message: '输入类型必须是 text 或 image' })
|
@IsIn(['text', 'image'], { message: '输入类型必须是 text 或 image' })
|
||||||
@ -40,4 +56,8 @@ export class CreateTaskDto {
|
|||||||
@Min(10000, { message: '模型面数最小为10000' })
|
@Min(10000, { message: '模型面数最小为10000' })
|
||||||
@Max(1500000, { message: '模型面数最大为1500000' })
|
@Max(1500000, { message: '模型面数最大为1500000' })
|
||||||
faceCount?: number;
|
faceCount?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsObject({ message: '多视图图片必须是对象' })
|
||||||
|
multiViewImages?: MultiViewImages;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,14 @@ export interface AI3DGenerateResult {
|
|||||||
errorMessage?: string; // 错误信息
|
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';
|
generateType?: 'Normal' | 'LowPoly' | 'Geometry' | 'Sketch';
|
||||||
/** 模型面数:10000-1500000,默认500000 */
|
/** 模型面数:10000-1500000,默认500000 */
|
||||||
faceCount?: number;
|
faceCount?: number;
|
||||||
|
/** 多视图图片(图生3D支持) */
|
||||||
|
multiViewImages?: MultiViewImage[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -85,10 +85,22 @@ export class HunyuanAI3DProvider implements AI3DProvider {
|
|||||||
payload.GenerateType = options.generateType;
|
payload.GenerateType = options.generateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.log(
|
// 多视图图片支持
|
||||||
`提交图生3D任务: ${inputContent.substring(0, 50)}... ` +
|
if (options?.multiViewImages && options.multiViewImages.length > 0) {
|
||||||
`[类型: ${options?.generateType || 'Normal'}]`,
|
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