feat: 旋转单位改为度并支持轨迹点拖拽

统一数据模型中的旋转为度数并在渲染时转弧度,新增 InspectorAngleField 角度控件,为场景与轨迹点提供滑块和重置按钮;选中轨迹点时角色预览到该点并支持拖拽 gizmo 调整位置;机位点击统一走 selectObject 以正确切换右侧属性卡片。
This commit is contained in:
tongtong committed 2026-09-17 11:18:58 +08:00
1 parent e74cf6d28b
commit 0794486857
21 files changed
+659 -99

No files matched your search

+18 -6
View File
@@ -1,6 +1,6 @@
import { create } from "zustand";
import { MANNEQUIN_POSE_PRESETS } from "../presets/mannequinPosePresets";
import { GEOMETRY_PRIMITIVE_OPTIONS } from "../schema/directorProject";
import { GEOMETRY_PRIMITIVE_OPTIONS, normalizeTrajectoryRotation, normalizeTransformRotation } from "../schema/directorProject";
import type {
DirectorAssetRef,
DirectorAssetSource,
@@ -940,7 +940,8 @@ function applyCrowdTransformPatch(
}
const nextPosition = patch.position ?? anchor.position;
const nextRotation = patch.rotation ?? anchor.rotation;
// 旋转一律存度数,且按 0–360° 一整圈收敛(避免转很多圈)
const nextRotation = patch.rotation ? normalizeTransformRotation(patch.rotation) : anchor.rotation;
const nextScale = patch.scale ?? anchor.scale;
const deltaRotation: [number, number, number] = [
nextRotation[0] - anchor.rotation[0],
@@ -1598,9 +1599,16 @@ export const useDirectorStore = create<DirectorStore>((set, get) => {
point.id === pointId
? {
...point,
// 直接采用传入的精确值(含小数),不再收敛
// 位置直接采用传入的精确值(含小数),不再收敛
position: patch.position ? patch.position : point.position,
rotation: patch.rotation ? patch.rotation : point.rotation,
// 朝向角归一化:俯仰角夹到 [-90,90],水平角/横滚角按整圈取模收敛
rotation: patch.rotation
? ([
normalizeTrajectoryRotation(0, patch.rotation[0]),
normalizeTrajectoryRotation(1, patch.rotation[1]),
normalizeTrajectoryRotation(2, patch.rotation[2]),
] as [number, number, number])
: point.rotation,
}
: point
),
@@ -1644,6 +1652,8 @@ export const useDirectorStore = create<DirectorStore>((set, get) => {
scene: {
...state.project.scene,
...patch,
// 场景旋转一律存度数,且按 0–360° 一整圈收敛(避免转很多圈)
...(patch.rotation ? { rotation: normalizeTransformRotation(patch.rotation) } : {}),
},
},
})),
@@ -1703,10 +1713,12 @@ export const useDirectorStore = create<DirectorStore>((set, get) => {
updateObjectTransform: (id, patch) =>
commitMutation((state) => {
const currentObject = state.project.objects.find((item) => item.id === id);
// 旋转一律存度数,且按 0–360° 一整圈收敛(避免转很多圈)
const nextRotation = patch.rotation ? normalizeTransformRotation(patch.rotation) : currentObject?.transform.rotation;
const nextTransform = currentObject
? {
position: patch.position ?? currentObject.transform.position,
rotation: patch.rotation ?? currentObject.transform.rotation,
rotation: nextRotation ?? currentObject.transform.rotation,
scale: patch.scale ?? currentObject.transform.scale,
}
: null;
@@ -1720,7 +1732,7 @@ export const useDirectorStore = create<DirectorStore>((set, get) => {
...item,
transform: {
position: patch.position ?? item.transform.position,
rotation: patch.rotation ?? item.transform.rotation,
rotation: nextRotation ?? item.transform.rotation,
scale: patch.scale ?? item.transform.scale,
},
})),