auto-git:
[change] tests/domain/build-runtime-scene.test.ts [change] tests/domain/scene-document-validation.test.ts [change] tests/serialization/scene-document-json.test.ts [change] tests/unit/entity-instances.test.ts [change] tests/unit/viewport-focus.test.ts
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_CAMERA_RIG_DEFAULT_ACTIVE,
|
||||
DEFAULT_CAMERA_RIG_LOOK_AROUND_ENABLED,
|
||||
DEFAULT_CAMERA_RIG_LOOK_AROUND_PITCH_LIMIT_DEGREES,
|
||||
DEFAULT_CAMERA_RIG_LOOK_AROUND_RECENTER_SPEED,
|
||||
DEFAULT_CAMERA_RIG_LOOK_AROUND_YAW_LIMIT_DEGREES,
|
||||
DEFAULT_CAMERA_RIG_PRIORITY,
|
||||
DEFAULT_CAMERA_RIG_TARGET_OFFSET,
|
||||
DEFAULT_CAMERA_RIG_TRANSITION_DURATION_SECONDS,
|
||||
DEFAULT_CAMERA_RIG_TRANSITION_MODE,
|
||||
DEFAULT_POINT_LIGHT_COLOR_HEX,
|
||||
DEFAULT_POINT_LIGHT_DISTANCE,
|
||||
DEFAULT_POINT_LIGHT_INTENSITY,
|
||||
@@ -86,6 +95,26 @@ describe("entity registry defaults", () => {
|
||||
distance: DEFAULT_POINT_LIGHT_DISTANCE
|
||||
});
|
||||
|
||||
expect(createDefaultEntityInstance("cameraRig")).toMatchObject({
|
||||
kind: "cameraRig",
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
rigType: "fixed",
|
||||
priority: DEFAULT_CAMERA_RIG_PRIORITY,
|
||||
defaultActive: DEFAULT_CAMERA_RIG_DEFAULT_ACTIVE,
|
||||
target: {
|
||||
kind: "player"
|
||||
},
|
||||
targetOffset: DEFAULT_CAMERA_RIG_TARGET_OFFSET,
|
||||
transitionMode: DEFAULT_CAMERA_RIG_TRANSITION_MODE,
|
||||
transitionDurationSeconds: DEFAULT_CAMERA_RIG_TRANSITION_DURATION_SECONDS,
|
||||
lookAround: {
|
||||
enabled: DEFAULT_CAMERA_RIG_LOOK_AROUND_ENABLED,
|
||||
yawLimitDegrees: DEFAULT_CAMERA_RIG_LOOK_AROUND_YAW_LIMIT_DEGREES,
|
||||
pitchLimitDegrees: DEFAULT_CAMERA_RIG_LOOK_AROUND_PITCH_LIMIT_DEGREES,
|
||||
recenterSpeed: DEFAULT_CAMERA_RIG_LOOK_AROUND_RECENTER_SPEED
|
||||
}
|
||||
});
|
||||
|
||||
expect(createDefaultEntityInstance("spotLight")).toMatchObject({
|
||||
kind: "spotLight",
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
|
||||
@@ -5,7 +5,13 @@ import { createBoxBrush } from "../../src/document/brushes";
|
||||
import { createScenePath } from "../../src/document/paths";
|
||||
import { createEmptySceneDocument } from "../../src/document/scene-document";
|
||||
import { createTerrain } from "../../src/document/terrains";
|
||||
import { createPointLightEntity, createPlayerStartEntity, createSpotLightEntity, createTriggerVolumeEntity } from "../../src/entities/entity-instances";
|
||||
import {
|
||||
createCameraRigEntity,
|
||||
createPointLightEntity,
|
||||
createPlayerStartEntity,
|
||||
createSpotLightEntity,
|
||||
createTriggerVolumeEntity
|
||||
} from "../../src/entities/entity-instances";
|
||||
import { resolveViewportFocusTarget } from "../../src/viewport-three/viewport-focus";
|
||||
|
||||
describe("resolveViewportFocusTarget", () => {
|
||||
@@ -169,6 +175,38 @@ describe("resolveViewportFocusTarget", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("frames the selected Camera Rig helper", () => {
|
||||
const cameraRig = createCameraRigEntity({
|
||||
id: "entity-camera-rig-focus",
|
||||
position: {
|
||||
x: -3,
|
||||
y: 2,
|
||||
z: 5
|
||||
}
|
||||
});
|
||||
const document = {
|
||||
...createEmptySceneDocument(),
|
||||
entities: {
|
||||
[cameraRig.id]: cameraRig
|
||||
}
|
||||
};
|
||||
|
||||
const focusTarget = resolveViewportFocusTarget(document, {
|
||||
kind: "entities",
|
||||
ids: [cameraRig.id]
|
||||
});
|
||||
|
||||
expect(focusTarget).toEqual({
|
||||
center: {
|
||||
x: -3,
|
||||
y: 2.28,
|
||||
z: 5
|
||||
},
|
||||
radius: expect.any(Number)
|
||||
});
|
||||
expect(focusTarget?.radius).toBeGreaterThan(0.45);
|
||||
});
|
||||
|
||||
it("frames the selected Path around its authored point bounds", () => {
|
||||
const path = createScenePath({
|
||||
id: "path-focus",
|
||||
|
||||
Reference in New Issue
Block a user