feat: 增加轨迹
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
applySnapshotToControls,
|
||||
DEFAULT_DIRECTOR_VIEW_SNAPSHOT,
|
||||
getViewportGizmoHitButtonStyle,
|
||||
getViewportSnapshotFromGizmoDirection,
|
||||
@@ -6,7 +7,7 @@ import {
|
||||
} from "./DirectorCanvas";
|
||||
import { createDefaultDirectorProject } from "../store/directorStore";
|
||||
import { getCameraViewSnapshotFromShot } from "../schema/cameraGeometry";
|
||||
import { Vector3 } from "three";
|
||||
import { PerspectiveCamera, Vector3 } from "three";
|
||||
|
||||
function expectTupleToBeCloseTo(
|
||||
received: [number, number, number],
|
||||
@@ -21,6 +22,27 @@ it("keeps the viewport grid visible when there is no panorama background", () =>
|
||||
expect(shouldRenderViewportGrid(false, false)).toBe(true);
|
||||
});
|
||||
|
||||
it("flushes leftover orbit inertia before writing the reset view back", () => {
|
||||
const dampingStateDuringUpdate: boolean[] = [];
|
||||
const controls = {
|
||||
enableDamping: true,
|
||||
target: new Vector3(9, 9, 9),
|
||||
update: () => dampingStateDuringUpdate.push(controls.enableDamping),
|
||||
};
|
||||
const camera = new PerspectiveCamera();
|
||||
|
||||
applySnapshotToControls(controls, camera, DEFAULT_DIRECTOR_VIEW_SNAPSHOT);
|
||||
|
||||
// 两次 update 都在「阻尼关闭」状态下跑:第一次结算残余惯性,第二次稳在新视角上。
|
||||
// 如果带着残余惯性直接写回,画布还在滑行时点重置视角就会被继续推走(表现为重置无效)。
|
||||
expect(dampingStateDuringUpdate).toEqual([false, false]);
|
||||
// 用完把阻尼恢复原状
|
||||
expect(controls.enableDamping).toBe(true);
|
||||
expect(controls.target.toArray()).toEqual(DEFAULT_DIRECTOR_VIEW_SNAPSHOT.target);
|
||||
expect(camera.fov).toBe(DEFAULT_DIRECTOR_VIEW_SNAPSHOT.fov);
|
||||
expect(camera.position.toArray()).toEqual(DEFAULT_DIRECTOR_VIEW_SNAPSHOT.position);
|
||||
});
|
||||
|
||||
it("keeps the viewport grid visible when a panorama background is active", () => {
|
||||
expect(shouldRenderViewportGrid(true, false)).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user