Add tests for actor scheduler animation and follow-path effects
This commit is contained in:
@@ -4,7 +4,9 @@ import { createBoxBrush } from "../../src/document/brushes";
|
|||||||
import {
|
import {
|
||||||
createActiveSceneControlTargetRef,
|
createActiveSceneControlTargetRef,
|
||||||
createActorControlTargetRef,
|
createActorControlTargetRef,
|
||||||
|
createFollowActorPathControlEffect,
|
||||||
createLightControlTargetRef,
|
createLightControlTargetRef,
|
||||||
|
createPlayActorAnimationControlEffect,
|
||||||
createSetActorPresenceControlEffect,
|
createSetActorPresenceControlEffect,
|
||||||
createSetAmbientLightColorControlEffect,
|
createSetAmbientLightColorControlEffect,
|
||||||
createSetLightIntensityControlEffect,
|
createSetLightIntensityControlEffect,
|
||||||
@@ -213,6 +215,71 @@ describe("validateSceneDocument", () => {
|
|||||||
expect(validation.errors).toEqual([]);
|
expect(validation.errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("accepts actor scheduler animation and follow-path effects when the actor has one bound NPC usage", () => {
|
||||||
|
const actorTarget = createActorControlTargetRef("actor-patroller");
|
||||||
|
const npcModelAsset = {
|
||||||
|
id: "asset-model-patroller",
|
||||||
|
kind: "model" as const,
|
||||||
|
sourceName: "patroller.glb",
|
||||||
|
mimeType: "model/gltf-binary",
|
||||||
|
storageKey: createProjectAssetStorageKey("asset-model-patroller"),
|
||||||
|
byteLength: 1024,
|
||||||
|
metadata: {
|
||||||
|
kind: "model" as const,
|
||||||
|
format: "glb" as const,
|
||||||
|
sceneName: null,
|
||||||
|
nodeCount: 1,
|
||||||
|
meshCount: 1,
|
||||||
|
materialNames: [],
|
||||||
|
textureNames: [],
|
||||||
|
animationNames: ["Walk"],
|
||||||
|
boundingBox: null,
|
||||||
|
warnings: []
|
||||||
|
}
|
||||||
|
} satisfies ModelAssetRecord;
|
||||||
|
const npc = createNpcEntity({
|
||||||
|
id: "entity-npc-patroller",
|
||||||
|
actorId: actorTarget.actorId,
|
||||||
|
modelAssetId: npcModelAsset.id
|
||||||
|
});
|
||||||
|
const path = createScenePath({
|
||||||
|
id: "path-patrol"
|
||||||
|
});
|
||||||
|
const document = createEmptySceneDocument();
|
||||||
|
document.assets[npcModelAsset.id] = npcModelAsset;
|
||||||
|
document.entities[npc.id] = npc;
|
||||||
|
document.paths[path.id] = path;
|
||||||
|
document.scheduler.routines["routine-patrol"] = createProjectScheduleRoutine({
|
||||||
|
id: "routine-patrol",
|
||||||
|
title: "Patrolling",
|
||||||
|
target: actorTarget,
|
||||||
|
startHour: 9,
|
||||||
|
endHour: 13,
|
||||||
|
effects: [
|
||||||
|
createSetActorPresenceControlEffect({
|
||||||
|
target: actorTarget,
|
||||||
|
active: true
|
||||||
|
}),
|
||||||
|
createPlayActorAnimationControlEffect({
|
||||||
|
target: actorTarget,
|
||||||
|
clipName: "Walk",
|
||||||
|
loop: true
|
||||||
|
}),
|
||||||
|
createFollowActorPathControlEffect({
|
||||||
|
target: actorTarget,
|
||||||
|
pathId: path.id,
|
||||||
|
speed: 2,
|
||||||
|
loop: false,
|
||||||
|
progressMode: "deriveFromTime"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const validation = validateSceneDocument(document);
|
||||||
|
|
||||||
|
expect(validation.errors).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it("detects invalid box sizes and missing material references", () => {
|
it("detects invalid box sizes and missing material references", () => {
|
||||||
const brush = createBoxBrush({
|
const brush = createBoxBrush({
|
||||||
id: "brush-invalid"
|
id: "brush-invalid"
|
||||||
|
|||||||
Reference in New Issue
Block a user