fix: 优化空格播放和截图角色标签对不上

This commit is contained in:
2026-09-17 19:39:24 +08:00
parent 8d67f17a84
commit e66e3374bf
19 changed files with 633 additions and 58 deletions

View File

@@ -1,6 +1,11 @@
import { create } from "zustand";
import { MANNEQUIN_POSE_PRESETS } from "../presets/mannequinPosePresets";
import { GEOMETRY_PRIMITIVE_OPTIONS, normalizeTrajectoryRotation, normalizeTransformRotation } from "../schema/directorProject";
import {
DEFAULT_GROUND_COLOR,
GEOMETRY_PRIMITIVE_OPTIONS,
normalizeTrajectoryRotation,
normalizeTransformRotation,
} from "../schema/directorProject";
import type {
DirectorAssetRef,
DirectorAssetSource,
@@ -245,8 +250,10 @@ const DEFAULT_SCENE: SceneSettings = {
panoramaYaw: 0,
panoramaRadius: 60,
showLabels: true,
captureShowGrid: false,
snapToGrid: false,
showGround: true,
groundColor: DEFAULT_GROUND_COLOR,
groundOpacity: 0.4,
groundHeight: 0,
};
@@ -477,8 +484,31 @@ function withTimeline(project: DirectorProject): DirectorProject {
};
}
/**
* 旧工程里还没有「地面颜色」这一项(当时是写死的深灰):补上默认值,
* 否则加载后地面会落到材质默认色(白),和天空色一起看非常刺眼。
*/
function withSceneDefaults(project: DirectorProject): DirectorProject {
const scene = project.scene;
if (!scene) return project;
const nextScene = { ...scene };
if (!(typeof scene.groundColor === "string" && scene.groundColor)) {
nextScene.groundColor = DEFAULT_GROUND_COLOR;
}
// 旧工程没有「导出时是否带网格」这一项:补默认值(false = 导出时藏起网格)
if (typeof nextScene.captureShowGrid !== "boolean") {
nextScene.captureShowGrid = false;
}
if (nextScene.groundColor === scene.groundColor && nextScene.captureShowGrid === scene.captureShowGrid) {
return project;
}
return { ...project, scene: nextScene };
}
function migrateDirectorProject(project: DirectorProject): DirectorProject {
const withTimelineProject = withTimeline(project);
const withTimelineProject = withSceneDefaults(withTimeline(project));
return {
...withTimelineProject,
objects: withTimelineProject.objects.map((object) => {