fix: 优化空格播放和截图角色标签对不上
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { Box3, DoubleSide, Vector3 } from "three";
|
||||
import { afterEach, beforeEach, vi } from "vitest";
|
||||
import { VIEWPORT_CAMERA_VISUAL_SCALE } from "../schema/cameraGeometry";
|
||||
@@ -274,6 +275,16 @@ it("uses the requested dark ground surface color", () => {
|
||||
expect(groundMaterial?.outerHTML.toLowerCase()).toContain("polygonoffsetunits=\"1\"");
|
||||
});
|
||||
|
||||
it("paints the ground with the ground color from the scene settings", () => {
|
||||
useDirectorStore.getState().updateScene({ groundColor: "#204060" });
|
||||
|
||||
const { container } = render(<SceneRoot />);
|
||||
|
||||
// 地面颜色和天空颜色一样是工程设置:面板上改了颜色,视口里的地面材质就得跟着变
|
||||
expect(container.querySelector('meshbasicmaterial[color="#204060"]')).toBeInTheDocument();
|
||||
expect(container.querySelector('meshbasicmaterial[color="#303640"]')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the ground visible when the view drops below the ground plane", () => {
|
||||
const { container } = render(<SceneRoot />);
|
||||
const groundMaterial = container.querySelector('meshbasicmaterial[color="#303640"]');
|
||||
@@ -680,6 +691,21 @@ it("renders solid trajectory spheres and a smooth curve through the waypoints",
|
||||
expect(container.querySelectorAll('mesh[name^="trajectory-point-"]')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("keeps the trajectory marker material writing depth so an opaque ground cannot hide it", () => {
|
||||
// 这条约束落在材质参数上(jsdom 里 <mesh> / <meshBasicMaterial> 只是普通 DOM 节点,
|
||||
// depthWrite 这种 unknown 布尔属性不会落到 DOM 上,跑不出来),所以按源码契约断言。
|
||||
const source = readFileSync("src/editor/canvas/SceneRoot.tsx", "utf8");
|
||||
const markerMaterialLine = source
|
||||
.split("\n")
|
||||
.find((line) => line.includes("<meshBasicMaterial color={selected ? TRAJECTORY_SELECTED_COLOR : color}"));
|
||||
|
||||
expect(markerMaterialLine).toBeDefined();
|
||||
// 地面是 transparent 材质:即使透明度为 1 也走透明通道、排在所有不透明物体之后渲染。
|
||||
// 小球一旦不写深度(depthWrite={false}),地面会整片盖住它 ——
|
||||
// 表现就是「地面透明度为 1 时看不到轨迹点」。
|
||||
expect(markerMaterialLine).not.toContain("depthWrite");
|
||||
});
|
||||
|
||||
it("puts a walking character at its trajectory sample for the current playhead", () => {
|
||||
useDirectorStore.getState().addTrajectoryPoint("char_default_a", [8, 0, 0]);
|
||||
// 单点轨迹:0s 在角色起始位置,时间轴末尾(5s)到达该轨迹点
|
||||
|
||||
Reference in New Issue
Block a user