fix: make nightdrive signage reliable and legible
This commit is contained in:
@@ -565,11 +565,15 @@ describe("procedural world models", () => {
|
||||
const sign = createSign(resources);
|
||||
for (const name of [
|
||||
"sign-backplate",
|
||||
"sign-face-panel",
|
||||
"sign-face",
|
||||
"sign-housing",
|
||||
"sign-edge-light",
|
||||
"sign-post",
|
||||
"sign-post-secondary",
|
||||
"sign-bracket",
|
||||
"sign-back-rails",
|
||||
"sign-fasteners",
|
||||
"sign-footing",
|
||||
]) {
|
||||
expect(sign.group.getObjectByName(name), name).toBeDefined();
|
||||
@@ -577,8 +581,14 @@ describe("procedural world models", () => {
|
||||
const face = sign.group.getObjectByName("sign-face") as {
|
||||
userData: { textureUpdateCount: number };
|
||||
material: {
|
||||
depthWrite: boolean;
|
||||
opacity: number;
|
||||
map: { anisotropy: number; image: { width: number; height: number } };
|
||||
toneMapped: boolean;
|
||||
map: {
|
||||
anisotropy: number;
|
||||
image: { width: number; height: number };
|
||||
premultiplyAlpha: boolean;
|
||||
};
|
||||
};
|
||||
geometry: {
|
||||
boundingBox: { min: { x: number; y: number }; max: { x: number; y: number } } | null;
|
||||
@@ -606,7 +616,25 @@ describe("procedural world models", () => {
|
||||
expect(faceWidth / faceHeight).toBeCloseTo(4, 6);
|
||||
expect(face.material.map.image).toMatchObject({ width: 2_048, height: 512 });
|
||||
expect(face.material.map.anisotropy).toBeGreaterThanOrEqual(8);
|
||||
expect(face.material.map.premultiplyAlpha).toBe(true);
|
||||
expect(face.material.depthWrite).toBe(false);
|
||||
expect(face.material.toneMapped).toBe(false);
|
||||
expect(face.material).toBeInstanceOf(THREE.MeshBasicMaterial);
|
||||
const facePanel = sign.group.getObjectByName("sign-face-panel") as { material: unknown };
|
||||
expect(facePanel.material).toBeInstanceOf(THREE.MeshStandardMaterial);
|
||||
const allocation = resources.snapshot();
|
||||
let renderablePartCount = 0;
|
||||
(sign.group as unknown as {
|
||||
traverse(callback: (object: { isMesh?: boolean }) => void): void;
|
||||
}).traverse((object) => {
|
||||
if (object.isMesh === true) renderablePartCount += 1;
|
||||
});
|
||||
expect(renderablePartCount).toBe(20);
|
||||
expect(allocation.owned).toMatchObject({
|
||||
geometry: 13,
|
||||
material: 7,
|
||||
texture: 1,
|
||||
});
|
||||
|
||||
sign.update(null);
|
||||
expect((sign.group as { visible: boolean }).visible).toBe(false);
|
||||
@@ -656,6 +684,50 @@ describe("procedural world models", () => {
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("caps the sign texture to the renderer limit without changing its four-to-one sampling ratio", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources, {
|
||||
maximumAnisotropy: 4,
|
||||
maximumTextureSize: 1_024,
|
||||
});
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 });
|
||||
|
||||
expect(sign.inspect(createChaseCamera(16 / 9), 1_440, 900)?.texture).toMatchObject({
|
||||
width: 1_024,
|
||||
height: 256,
|
||||
maximumSize: 1_024,
|
||||
anisotropy: 4,
|
||||
});
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("accepts a new target when the previous face is below the concealed threshold", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const face = sign.group.getObjectByName("sign-face") as {
|
||||
userData: { textureUpdateCount: number };
|
||||
};
|
||||
|
||||
sign.update({
|
||||
targetId: "profile",
|
||||
phase: "approach",
|
||||
progress: 0.03,
|
||||
opacity: 0.01,
|
||||
});
|
||||
expect(face.userData.textureUpdateCount).toBe(1);
|
||||
|
||||
sign.update({
|
||||
targetId: "experience",
|
||||
phase: "anticipate",
|
||||
progress: 0,
|
||||
opacity: 0,
|
||||
});
|
||||
|
||||
expect(face.userData.textureUpdateCount).toBe(2);
|
||||
expect(sign.inspect(createChaseCamera(16 / 9), 1_440, 900)?.corridor).toBe("left");
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("begins sign departure from the rendered approach pose without a teleport", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
@@ -681,21 +753,26 @@ describe("procedural world models", () => {
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("defers responsive pose changes for the complete lifecycle, including concealed anticipation", () => {
|
||||
it("reflows a live sign to a new responsive pose without a resize teleport", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(16 / 9);
|
||||
sign.setViewportSize(1_440, 900);
|
||||
sign.update({ targetId: "profile", phase: "anticipate", progress: 0, opacity: 0 });
|
||||
const dwell = { targetId: "profile", phase: "dwell", progress: 1, opacity: 1 } as const;
|
||||
sign.update(dwell, 0);
|
||||
const resizeOrigin = sign.group.position.clone();
|
||||
|
||||
sign.setViewportSize(844, 390);
|
||||
const concealed = sign.inspect(camera, 844, 390);
|
||||
expect(concealed?.viewportProfile).toBe("wide");
|
||||
sign.update({ targetId: "profile", phase: "approach", progress: 0.5, opacity: 0.7 });
|
||||
expect(sign.inspect(camera, 844, 390)?.viewportProfile).toBe("wide");
|
||||
sign.update(dwell, 100);
|
||||
expect(sign.group.position.distanceTo(resizeOrigin)).toBeLessThan(0.001);
|
||||
sign.update(dwell, 260);
|
||||
const midpoint = sign.group.position.clone();
|
||||
expect(midpoint.distanceTo(resizeOrigin)).toBeGreaterThan(0.1);
|
||||
sign.update(dwell, 450);
|
||||
expect(sign.group.position.distanceTo(midpoint)).toBeGreaterThan(0.1);
|
||||
|
||||
sign.update(null);
|
||||
sign.update({ targetId: "experience", phase: "anticipate", progress: 0, opacity: 0 });
|
||||
const camera = createChaseCamera(844 / 390);
|
||||
expect(sign.inspect(camera, 844, 390)?.viewportProfile).toBe("short");
|
||||
resources.dispose();
|
||||
|
||||
@@ -709,23 +786,70 @@ describe("procedural world models", () => {
|
||||
opacity: 1,
|
||||
viewportProfile: "wide",
|
||||
});
|
||||
expect(rebuilt.inspect(camera, 844, 390)?.viewportProfile).toBe("wide");
|
||||
expect(rebuilt.inspect(camera, 844, 390)?.viewportProfile).toBe("short");
|
||||
rebuiltResources.dispose();
|
||||
});
|
||||
|
||||
it("departs laterally without crossing the chase camera plane or growing toward the car", () => {
|
||||
it("reflows a visible portrait sign into its navigator-safe pose without a teleport", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(390 / 844);
|
||||
sign.setViewportSize(390, 844);
|
||||
const passiveDwell = {
|
||||
targetId: "profile",
|
||||
phase: "dwell",
|
||||
progress: 1,
|
||||
opacity: 1,
|
||||
} as const;
|
||||
sign.update(passiveDwell, 0);
|
||||
const passivePosition = sign.group.position.clone();
|
||||
|
||||
const navigationDwell = { ...passiveDwell, navigationArrival: true as const };
|
||||
sign.update(navigationDwell, 100);
|
||||
expect(sign.group.position.distanceTo(passivePosition)).toBeLessThan(0.001);
|
||||
sign.update(navigationDwell, 260);
|
||||
const midpoint = sign.group.position.clone();
|
||||
expect(midpoint.distanceTo(passivePosition)).toBeGreaterThan(0.1);
|
||||
sign.update(navigationDwell, 450);
|
||||
|
||||
const presentation = sign.inspect(camera, 390, 844);
|
||||
if (presentation === null) throw new Error("Missing navigator-safe Profile sign");
|
||||
expect(sign.group.position.distanceTo(midpoint)).toBeGreaterThan(0.1);
|
||||
expect(presentation.bounds.top).toBeGreaterThanOrEqual(626);
|
||||
expect(presentation.bounds.bottom).toBeLessThanOrEqual(690);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("drives past a sign at constant world scale before carrying it beyond the roadside edge", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(16 / 9);
|
||||
sign.setViewportSize(1_440, 900);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 });
|
||||
const dwellX = sign.group.position.x;
|
||||
const dwell = sign.inspect(camera, 1_440, 900);
|
||||
if (dwell === null) throw new Error("Missing Profile dwell presentation");
|
||||
const dwellPosition = sign.group.position.clone();
|
||||
const dwellScale = sign.group.scale.x;
|
||||
|
||||
sign.update({ targetId: "profile", phase: "depart", progress: 0.9, opacity: 0.1 });
|
||||
sign.update({ targetId: "profile", phase: "depart", progress: 0.5, opacity: 1 });
|
||||
const passing = sign.inspect(camera, 1_440, 900);
|
||||
if (passing === null) throw new Error("Missing Profile pass-by presentation");
|
||||
|
||||
expect(sign.group.position.x).toBeLessThan(dwellX);
|
||||
expect(sign.group.position.z).toBeLessThanOrEqual(0);
|
||||
expect(sign.group.scale.x).toBeLessThan(dwellScale);
|
||||
expect(sign.group.position.x).toBeLessThan(dwellPosition.x);
|
||||
expect(sign.group.position.y).toBeCloseTo(dwellPosition.y, 6);
|
||||
expect(sign.group.position.z).toBeGreaterThan(dwellPosition.z);
|
||||
expect(sign.group.scale.x).toBeCloseTo(dwellScale, 6);
|
||||
expect(passing.bounds.width).toBeGreaterThan(dwell.bounds.width);
|
||||
expect(passing.bounds.left).toBeLessThan(dwell.bounds.left);
|
||||
|
||||
const passingZ = sign.group.position.z;
|
||||
sign.update({ targetId: "profile", phase: "depart", progress: 0.9, opacity: 0.1 });
|
||||
const leaving = sign.inspect(camera, 1_440, 900);
|
||||
if (leaving === null) throw new Error("Missing Profile departure presentation");
|
||||
expect(sign.group.position.z).toBeGreaterThan(passingZ);
|
||||
expect(sign.group.position.z).toBeLessThan(camera.position.z - 2);
|
||||
expect(sign.group.scale.x).toBeCloseTo(dwellScale, 6);
|
||||
expect(leaving.bounds.right).toBeLessThan(passing.bounds.right);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
@@ -746,7 +870,82 @@ describe("procedural world models", () => {
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("places route signs in the corridor opposite their destination content", () => {
|
||||
it("keeps a short-landscape left sign inside the narrow desktop roadside gutter", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(780 / 493);
|
||||
camera.position.set(-1.35, 8.6, 22);
|
||||
camera.lookAt(1.6, 4.8, -128);
|
||||
sign.setViewportSize(780, 493);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 });
|
||||
|
||||
const presentation = sign.inspect(camera, 780, 493);
|
||||
if (presentation === null) throw new Error("Missing short-landscape Profile sign");
|
||||
expect(presentation.bounds.left).toBeGreaterThanOrEqual(8);
|
||||
expect(presentation.bounds.right).toBeLessThanOrEqual(265);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("keeps a short-landscape left sign horizontally clear at 844 by 390", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(844 / 390);
|
||||
camera.position.set(-1.35, 8.6, 22);
|
||||
camera.lookAt(1.6, 4.8, -128);
|
||||
sign.setViewportSize(844, 390);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 });
|
||||
|
||||
const presentation = sign.inspect(camera, 844, 390);
|
||||
if (presentation === null) throw new Error("Missing 844 by 390 Profile sign");
|
||||
expect(presentation.bounds.left).toBeGreaterThanOrEqual(8);
|
||||
expect(presentation.bounds.right).toBeLessThanOrEqual(288);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("places a portrait navigator arrival below its full-width destination panel", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
const camera = createChaseCamera(390 / 844);
|
||||
sign.setViewportSize(390, 844);
|
||||
sign.update({
|
||||
targetId: "profile",
|
||||
phase: "dwell",
|
||||
progress: 1,
|
||||
opacity: 1,
|
||||
navigationArrival: true,
|
||||
});
|
||||
|
||||
const presentation = sign.inspect(camera, 390, 844);
|
||||
if (presentation === null) throw new Error("Missing portrait navigator sign");
|
||||
expect(presentation.bounds.left).toBeGreaterThanOrEqual(8);
|
||||
expect(presentation.bounds.top).toBeGreaterThanOrEqual(626);
|
||||
expect(presentation.bounds.right).toBeLessThanOrEqual(382);
|
||||
expect(presentation.bounds.bottom).toBeLessThanOrEqual(690);
|
||||
expect(presentation.bounds.width).toBeGreaterThanOrEqual(85);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("lands a resized Profile lifecycle in the short-landscape safe corridor", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
sign.setViewportSize(1_440, 900);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 });
|
||||
|
||||
sign.setViewportSize(844, 390);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 }, 100);
|
||||
sign.update({ targetId: "profile", phase: "dwell", progress: 1, opacity: 1 }, 450);
|
||||
const camera = createChaseCamera(844 / 390);
|
||||
camera.position.set(-1.35, 8.6, 22);
|
||||
camera.lookAt(1.6, 4.8, -128);
|
||||
const presentation = sign.inspect(camera, 844, 390);
|
||||
if (presentation === null) throw new Error("Missing resized Profile sign");
|
||||
expect(presentation.viewportProfile).toBe("short");
|
||||
expect(presentation.bounds.left).toBeGreaterThanOrEqual(8);
|
||||
expect(presentation.bounds.right).toBeLessThanOrEqual(288);
|
||||
resources.dispose();
|
||||
});
|
||||
|
||||
it("places route signs in their authored transition-safe corridors", () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const sign = createSign(resources);
|
||||
sign.setViewportAspect(16 / 9);
|
||||
@@ -762,7 +961,7 @@ describe("procedural world models", () => {
|
||||
expect(profileBounds.maxX).toBeLessThan(0.08);
|
||||
|
||||
sign.update(null);
|
||||
sign.update({ targetId: "experience", phase: "dwell", progress: 1, opacity: 1 });
|
||||
sign.update({ targetId: "contact", phase: "dwell", progress: 1, opacity: 1 });
|
||||
sign.group.updateMatrixWorld(true);
|
||||
const experienceBounds = projectedBounds(profileFace, camera);
|
||||
expect(experienceBounds.minX).toBeGreaterThan(0);
|
||||
|
||||
Reference in New Issue
Block a user