From 7f8e28a4af1979180f84d81641cb346a7261c06d Mon Sep 17 00:00:00 2001 From: zhangxiaohua <827885272@qq.com> Date: Mon, 19 Jan 2026 14:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9B=BE=E7=94=9F3D,?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=9B=BE=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/ai-3d/ai-3d.service.ts | 39 +- backend/src/ai-3d/dto/create-task.dto.ts | 20 + .../providers/ai-3d-provider.interface.ts | 10 + .../src/ai-3d/providers/hunyuan.provider.ts | 20 +- frontend/src/views/workbench/ai-3d/Index.vue | 924 +++++++++++++++++- 5 files changed, 972 insertions(+), 41 deletions(-) diff --git a/backend/src/ai-3d/ai-3d.service.ts b/backend/src/ai-3d/ai-3d.service.ts index f130323..73071f2 100644 --- a/backend/src/ai-3d/ai-3d.service.ts +++ b/backend/src/ai-3d/ai-3d.service.ts @@ -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 = { + 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. 更新状态为处理中 diff --git a/backend/src/ai-3d/dto/create-task.dto.ts b/backend/src/ai-3d/dto/create-task.dto.ts index 6b64628..b5fbc42 100644 --- a/backend/src/ai-3d/dto/create-task.dto.ts +++ b/backend/src/ai-3d/dto/create-task.dto.ts @@ -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; } diff --git a/backend/src/ai-3d/providers/ai-3d-provider.interface.ts b/backend/src/ai-3d/providers/ai-3d-provider.interface.ts index 4eb80b9..5c4a97a 100644 --- a/backend/src/ai-3d/providers/ai-3d-provider.interface.ts +++ b/backend/src/ai-3d/providers/ai-3d-provider.interface.ts @@ -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[]; } /** diff --git a/backend/src/ai-3d/providers/hunyuan.provider.ts b/backend/src/ai-3d/providers/hunyuan.provider.ts index 193de72..145116d 100644 --- a/backend/src/ai-3d/providers/hunyuan.provider.ts +++ b/backend/src/ai-3d/providers/hunyuan.provider.ts @@ -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'}]`, + ); + } } // 生成签名和请求头 diff --git a/frontend/src/views/workbench/ai-3d/Index.vue b/frontend/src/views/workbench/ai-3d/Index.vue index b5ad3cc..c6465bf 100644 --- a/frontend/src/views/workbench/ai-3d/Index.vue +++ b/frontend/src/views/workbench/ai-3d/Index.vue @@ -111,33 +111,124 @@
-
- - 参考图片 + +
+ 单张图片 + 多张图片 + + + + + + + + 图片上传建议 + +
-
- 上传参考图片,AI 将智能识别并生成 3D 模型 -
- - - - + + + + + +
@@ -154,6 +245,196 @@
+ + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 预览 +
+ + 3D 预览 +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + +