跳到主要内容

类型参考

本页记录了 Planova 中的所有共享数据类型:来自 src/types/scene.ts 的 TypeScript 接口和来自 src-tauri/src/models.rs 的 Rust 结构体。


HomeSceneJSON

连接户型图解析、AI 规划、3D 生成、渲染和导出的统一数据协议。定义在 src/types/scene.ts 中。

interface HomeSceneJSON {
schema_version: string
project: HomeSceneProject
global: HomeSceneGlobal
rooms: Room[]
walls: Wall[]
openings: Opening[]
objects: SceneObject[]
materials: SceneMaterial[]
lights: SceneLight[]
cameras: CameraPreset[]
parse_quality?: ParseQuality
}

HomeSceneProject

字段类型说明
idstring项目 UUID
namestring项目名称
unit'meter'计量单位(始终为 "meter"

HomeSceneGlobal

字段类型说明
stylestring室内设计风格键
ceiling_heightnumber层高(米)
wall_thicknessnumber墙体厚度(米)
texture_overrides.floorstring?地面纹理覆盖路径
texture_overrides.wallstring?墙面纹理覆盖路径
texture_overrides.ceilingstring?天花板纹理覆盖路径

Room

字段类型说明
idstring房间 UUID
typeRoomType房间分类
namestring显示名称
polygonVec2[]地面多边形顶点(米)
areanumber?面积(平方米)
floor_materialstring?地面材质 ID
wall_materialstring?墙面材质 ID
ceiling_materialstring?天花板材质 ID

Wall

字段类型说明
idstring墙体 UUID
startVec2起点(米)
endVec2终点(米)
heightnumber墙高(米)
thicknessnumber墙体厚度(米)
materialstring?材质 ID
room_refsstring[]相邻房间的 ID

Opening

字段类型说明
idstring开口 UUID
typeOpeningType"door""window"
wall_refstring所属墙体 ID
positionVec2墙上的中心位置(米)
widthnumber开口宽度(米)
heightnumber开口高度(米)
sill_heightnumber窗台距地面高度(米)
swingDoorSwing?门的开合方向(仅限门)

SceneObject

字段类型说明
idstring物体 UUID
type'furniture' | 'decoration'物体类别
categorystring具体类别(如 "sofa""lamp"
asset_idstring?3D 资源引用
room_refstring?该物体所属的房间 ID
positionVec3世界坐标位置(米)
rotationVec3欧拉旋转(弧度)
scaleVec3各轴缩放因子
sizeVec3包围盒尺寸(米)
material_overridesRecord<string, string>?按槽位覆盖材质

SceneMaterial

字段类型说明
idstring材质 UUID
type'pbr'材质模型(始终为 PBR)
namestring显示名称
base_colorstring十六进制颜色(如 "#f5f5f5"
roughnessnumber表面粗糙度(0-1)
metalnessnumber金属度(0-1)
transparentboolean?材质是否透明
opacitynumber?不透明度(0-1)
texture_urls.base_colorstring?基础颜色贴图 URL
texture_urls.normalstring?法线贴图 URL
texture_urls.roughnessstring?粗糙度贴图 URL

SceneLight

字段类型说明
idstring灯光 UUID
typeLightType灯光类型
namestring显示名称
positionVec3世界坐标位置(米)
rotationVec3欧拉旋转(弧度)
intensitynumber灯光强度
colorstring十六进制颜色
sizeVec2?面光源尺寸(米)

CameraPreset

字段类型说明
idstring相机 UUID
namestring预设名称
typeCameraType相机投影类型
positionVec3相机位置(米)
targetVec3观察目标点(米)
fovnumber视场角(度)

ParseQuality

字段类型说明
overall_scorenumber综合质量分数(0-1)
geometry_scorenumber几何有效性分数
semantic_scorenumber语义正确性分数
scale_scorenumber比例尺精度分数
image_alignment_scorenumber与源图像的对齐分数
needs_user_reviewboolean是否建议人工审核
image_alignmentImageAlignmentReport?详细的对齐指标

ImageAlignmentReport

字段类型说明
wall_iounumber墙体掩码交并比
wall_precisionnumber墙体检测精确率
wall_recallnumber墙体检测召回率
overallnumber综合对齐分数

DiagnosisReport

字段类型说明
missing_wall_regionsArray<{ bbox: number[], description: string }>预期有墙体但未检测到的区域
extra_wall_regionsArray<{ bbox: number[], description: string }>检测到墙体但不应存在的区域
scale_suspiciousboolean比例尺估计是否可疑
scale_reasonstring?比例尺可疑的原因说明
room_coveragenumber房间覆盖的图像面积比例

枚举类型

RoomType

type RoomType =
| 'living_room'
| 'bedroom'
| 'kitchen'
| 'bathroom'
| 'dining_room'
| 'balcony'
| 'corridor'
| 'study'

OpeningType

type OpeningType = 'door' | 'window'

DoorSwing

type DoorSwing =
| 'left_inward'
| 'left_outward'
| 'right_inward'
| 'right_outward'

LightType

type LightType = 'area' | 'point' | 'spot' | 'directional'

CameraType

type CameraType = 'perspective' | 'orthographic'

基本类型别名

type Vec2 = [number, number]
type Vec3 = [number, number, number]

Rust 模型结构体

定义在 src-tauri/src/models.rs 中。所有结构体派生了 DebugCloneSerializeDeserialize

Project

字段说明Rust 类型
idUUIDString
name名称String
description描述String
style风格键String
status状态String
created_atISO 8601String
updated_atISO 8601String

UploadedFile

字段说明Rust 类型
idUUIDString
project_id外键String
original_filename文件名String
file_typeMIME 类型String
file_size字节数i64
storage_path绝对路径String
preview_path绝对路径String
parse_status状态String
created_atISO 8601String

GenerationTask

字段说明Rust 类型
idUUIDString
project_id外键String
task_type类型String
status状态String
progress0-100i64
input_dataJSONOption<serde_json::Value>
output_dataJSONOption<serde_json::Value>
error_message错误信息String
created_atISO 8601String
updated_atISO 8601String

API 响应类型

这些是 Tauri IPC 命令返回的类型。它们与数据库模型对应,但排除了 storage_path 等内部字段。

ProjectResponse

Project 字段相同:idnamedescriptionstylestatuscreated_atupdated_at

FileResponse

字段类型说明
idstring文件 UUID
project_idstring父项目 UUID
original_filenamestring原始文件名
file_typestringMIME 类型
file_sizenumber文件大小(字节)
preview_urlstringBase64 编码的预览 data URL
parse_statusstring"""parsing""completed""failed"
created_atstringISO 8601 时间戳

TaskResponse

GenerationTask 字段相同:idproject_idtask_typestatusprogressinput_dataoutput_dataerror_messagecreated_atupdated_at

SceneResponse

字段类型说明
idstring场景 UUID
project_idstring父项目 UUID
file_idstring源文件 UUID
namestring场景名称
schema_versionstringSchema 版本(如 "0.1.0"
scene_jsonHomeSceneJSON?解析后的场景 JSON(解析失败时为 null)
created_atstringISO 8601 时间戳
updated_atstringISO 8601 时间戳

类型映射:TypeScript 到 Rust

TypeScriptRust说明
stringString始终堆分配
numberi64 / f64i64 用于计数和进度,f64 用于坐标
booleanbool
T | nullOption<T>序列化为 null 或省略
T[]Vec<T>JSON 数组
objectserde_json::Value任意 JSON(scene_json、input/output data)
Record<string, string>HashMap<String, String>键值映射
Vec2 = [number, number][f64; 2]固定长度数组
Vec3 = [number, number, number][f64; 3]固定长度数组