Update runtime interaction tests to use directional view vectors instead of discrete rays
This commit is contained in:
@@ -84,9 +84,7 @@ function createRuntimeSceneFixture(options: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("runtime interaction targeting", () => {
|
describe("runtime interaction targeting", () => {
|
||||||
const centerRay = { x: 0, y: 0, z: 1 };
|
const centerView = { x: 0, y: 0, z: 1 };
|
||||||
const leftRay = { x: -0.3, y: 0, z: 1 };
|
|
||||||
const rightRay = { x: 0.3, y: 0, z: 1 };
|
|
||||||
|
|
||||||
it("orders visible NPC and interactable targets by view and distance score", () => {
|
it("orders visible NPC and interactable targets by view and distance score", () => {
|
||||||
const centerNpc = createNpc({
|
const centerNpc = createNpc({
|
||||||
@@ -184,68 +182,68 @@ describe("runtime interaction targeting", () => {
|
|||||||
expect(
|
expect(
|
||||||
system.resolveClickInteractionPrompt(
|
system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 0 },
|
{ x: 0, y: 1, z: 0 },
|
||||||
{ x: 0, y: 1.6, z: -1 },
|
{ x: 0, y: 0, z: 1 },
|
||||||
[centerRay],
|
|
||||||
1.5,
|
1.5,
|
||||||
|
30,
|
||||||
scene
|
scene
|
||||||
)
|
)
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prefers the center ray over side-ray hits when both are valid", () => {
|
it("captures off-center targets without ray dead zones", () => {
|
||||||
const centerNpc = createNpc({
|
const npc = createNpc({
|
||||||
entityId: "npc-center",
|
entityId: "npc-dead-zone",
|
||||||
name: "Center",
|
name: "Dead Zone",
|
||||||
position: { x: 0, y: 0, z: 3 }
|
position: { x: 0.52, y: 0, z: 2.55 }
|
||||||
});
|
|
||||||
const sideNpc = createNpc({
|
|
||||||
entityId: "npc-side",
|
|
||||||
name: "Side",
|
|
||||||
position: { x: 0.9, y: 0, z: 3 }
|
|
||||||
});
|
});
|
||||||
const scene = createRuntimeSceneFixture({
|
const scene = createRuntimeSceneFixture({
|
||||||
npcs: [centerNpc, sideNpc],
|
npcs: [npc],
|
||||||
links: [createClickLink(centerNpc.entityId), createClickLink(sideNpc.entityId)]
|
links: [createClickLink(npc.entityId)]
|
||||||
});
|
});
|
||||||
const system = new RuntimeInteractionSystem();
|
const system = new RuntimeInteractionSystem();
|
||||||
|
|
||||||
const prompt = system.resolveClickInteractionPrompt(
|
const prompt = system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 0 },
|
{ x: 0, y: 1, z: 0 },
|
||||||
{ x: 0, y: 1, z: 0 },
|
centerView,
|
||||||
[centerRay, leftRay, rightRay],
|
|
||||||
3,
|
3,
|
||||||
|
30,
|
||||||
scene
|
scene
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(prompt?.sourceEntityId).toBe(centerNpc.entityId);
|
expect(prompt?.sourceEntityId).toBe(npc.entityId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to the nearest side-ray hit when the center ray misses", () => {
|
it("uses the authored interaction angle to widen prompt acquisition", () => {
|
||||||
const leftNpc = createNpc({
|
const npc = createNpc({
|
||||||
entityId: "npc-left",
|
entityId: "npc-angle",
|
||||||
name: "Left",
|
name: "Angle",
|
||||||
position: { x: -0.9, y: 0, z: 2.4 }
|
position: { x: 1.15, y: 0, z: 2.35 }
|
||||||
});
|
|
||||||
const rightNpc = createNpc({
|
|
||||||
entityId: "npc-right",
|
|
||||||
name: "Right",
|
|
||||||
position: { x: 0.9, y: 0, z: 3.4 }
|
|
||||||
});
|
});
|
||||||
const scene = createRuntimeSceneFixture({
|
const scene = createRuntimeSceneFixture({
|
||||||
npcs: [leftNpc, rightNpc],
|
npcs: [npc],
|
||||||
links: [createClickLink(leftNpc.entityId), createClickLink(rightNpc.entityId)]
|
links: [createClickLink(npc.entityId)]
|
||||||
});
|
});
|
||||||
const system = new RuntimeInteractionSystem();
|
const system = new RuntimeInteractionSystem();
|
||||||
|
|
||||||
const prompt = system.resolveClickInteractionPrompt(
|
expect(
|
||||||
{ x: 0, y: 1, z: 0 },
|
system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 0 },
|
{ x: 0, y: 1, z: 0 },
|
||||||
[centerRay, leftRay, rightRay],
|
centerView,
|
||||||
4,
|
3,
|
||||||
scene
|
20,
|
||||||
);
|
scene
|
||||||
|
)
|
||||||
|
).toBeNull();
|
||||||
|
|
||||||
expect(prompt?.sourceEntityId).toBe(leftNpc.entityId);
|
expect(
|
||||||
|
system.resolveClickInteractionPrompt(
|
||||||
|
{ x: 0, y: 1, z: 0 },
|
||||||
|
centerView,
|
||||||
|
3,
|
||||||
|
60,
|
||||||
|
scene
|
||||||
|
)?.sourceEntityId
|
||||||
|
).toBe(npc.entityId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses the authored interaction reach to extend prompt distance", () => {
|
it("uses the authored interaction reach to extend prompt distance", () => {
|
||||||
@@ -263,9 +261,9 @@ describe("runtime interaction targeting", () => {
|
|||||||
expect(
|
expect(
|
||||||
system.resolveClickInteractionPrompt(
|
system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 0 },
|
{ x: 0, y: 1, z: 0 },
|
||||||
{ x: 0, y: 1, z: 0 },
|
centerView,
|
||||||
[centerRay],
|
|
||||||
1.5,
|
1.5,
|
||||||
|
30,
|
||||||
scene
|
scene
|
||||||
)
|
)
|
||||||
).toBeNull();
|
).toBeNull();
|
||||||
@@ -273,9 +271,9 @@ describe("runtime interaction targeting", () => {
|
|||||||
expect(
|
expect(
|
||||||
system.resolveClickInteractionPrompt(
|
system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 0 },
|
{ x: 0, y: 1, z: 0 },
|
||||||
{ x: 0, y: 1, z: 0 },
|
centerView,
|
||||||
[centerRay],
|
|
||||||
2.5,
|
2.5,
|
||||||
|
30,
|
||||||
scene
|
scene
|
||||||
)?.sourceEntityId
|
)?.sourceEntityId
|
||||||
).toBe(npc.entityId);
|
).toBe(npc.entityId);
|
||||||
@@ -295,9 +293,9 @@ describe("runtime interaction targeting", () => {
|
|||||||
|
|
||||||
const prompt = system.resolveClickInteractionPrompt(
|
const prompt = system.resolveClickInteractionPrompt(
|
||||||
{ x: 0, y: 1, z: 2.5 },
|
{ x: 0, y: 1, z: 2.5 },
|
||||||
{ x: 0, y: 1, z: 0 },
|
centerView,
|
||||||
[centerRay],
|
|
||||||
1.5,
|
1.5,
|
||||||
|
30,
|
||||||
scene
|
scene
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user