diff --git a/tests/e2e/entities-foundation.e2e.ts b/tests/e2e/entities-foundation.e2e.ts index 70860048..c5dece0d 100644 --- a/tests/e2e/entities-foundation.e2e.ts +++ b/tests/e2e/entities-foundation.e2e.ts @@ -21,10 +21,11 @@ test("user can place and select typed entities from the entity foundation workfl await page.reload(); await page.getByTestId("add-entity-soundEmitter").click(); - await expect(page.getByTestId("sound-emitter-radius")).toHaveValue("6"); + await expect(page.getByTestId("sound-emitter-ref-distance")).toHaveValue("6"); + await expect(page.getByTestId("sound-emitter-max-distance")).toHaveValue("24"); - await page.getByTestId("sound-emitter-radius").fill("9"); - await page.getByTestId("sound-emitter-radius").press("Tab"); + await page.getByTestId("sound-emitter-ref-distance").fill("9"); + await page.getByTestId("sound-emitter-ref-distance").press("Tab"); await page.getByTestId("add-entity-interactable").click(); await expect(page.getByTestId("interactable-prompt")).toHaveValue("Use"); @@ -35,7 +36,7 @@ test("user can place and select typed entities from the entity foundation workfl .first() .click(); - await expect(page.getByTestId("sound-emitter-radius")).toHaveValue("9"); + await expect(page.getByTestId("sound-emitter-ref-distance")).toHaveValue("9"); await expect(page.getByTestId("interactable-prompt")).toHaveCount(0); expect(pageErrors).toEqual([]); diff --git a/tests/serialization/scene-document-json.test.ts b/tests/serialization/scene-document-json.test.ts index 413db2e5..69f09a32 100644 --- a/tests/serialization/scene-document-json.test.ts +++ b/tests/serialization/scene-document-json.test.ts @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { createBoxBrush } from "../../src/document/brushes"; import { + ANIMATION_PLAYBACK_SCENE_DOCUMENT_VERSION, ENTITY_SYSTEM_FOUNDATION_SCENE_DOCUMENT_VERSION, FIRST_ROOM_POLISH_SCENE_DOCUMENT_VERSION, LOCAL_LIGHTS_AND_SKYBOX_SCENE_DOCUMENT_VERSION, @@ -21,10 +22,17 @@ import { createTeleportTargetEntity, createTriggerVolumeEntity } from "../../src/entities/entity-instances"; -import { createTeleportPlayerInteractionLink, createToggleVisibilityInteractionLink, createPlayAnimationInteractionLink, createStopAnimationInteractionLink } from "../../src/interactions/interaction-links"; +import { + createPlayAnimationInteractionLink, + createPlaySoundInteractionLink, + createStopAnimationInteractionLink, + createStopSoundInteractionLink, + createTeleportPlayerInteractionLink, + createToggleVisibilityInteractionLink +} from "../../src/interactions/interaction-links"; import { STARTER_MATERIAL_LIBRARY } from "../../src/materials/starter-material-library"; import { createModelInstance } from "../../src/assets/model-instances"; -import { createProjectAssetStorageKey, type ImageAssetRecord, type ModelAssetRecord } from "../../src/assets/project-assets"; +import { createProjectAssetStorageKey, type AudioAssetRecord, type ImageAssetRecord, type ModelAssetRecord } from "../../src/assets/project-assets"; import { parseSceneDocumentJson, serializeSceneDocument } from "../../src/serialization/scene-document-json"; describe("scene document JSON", () => { @@ -211,6 +219,21 @@ describe("scene document JSON", () => { const playerStart = createPlayerStartEntity({ id: "entity-player-start-main" }); + const audioAsset = { + id: "asset-audio-main", + kind: "audio" as const, + sourceName: "lobby-loop.ogg", + mimeType: "audio/ogg", + storageKey: createProjectAssetStorageKey("asset-audio-main"), + byteLength: 4096, + metadata: { + kind: "audio" as const, + durationSeconds: 4.5, + channelCount: 2, + sampleRateHz: 48000, + warnings: [] + } + } satisfies AudioAssetRecord; const soundEmitter = createSoundEmitterEntity({ id: "entity-sound-main", position: { @@ -218,8 +241,10 @@ describe("scene document JSON", () => { y: 2, z: 3 }, - radius: 7, - gain: 0.6, + audioAssetId: audioAsset.id, + volume: 0.6, + refDistance: 7, + maxDistance: 18, autoplay: true, loop: true }); @@ -258,6 +283,9 @@ describe("scene document JSON", () => { }); const document = { ...createEmptySceneDocument({ name: "Typed Entity Scene" }), + assets: { + [audioAsset.id]: audioAsset + }, entities: { [playerStart.id]: playerStart, [soundEmitter.id]: soundEmitter, @@ -273,6 +301,59 @@ describe("scene document JSON", () => { expect(roundTripDocument.modelInstances).toEqual({}); }); + it("round-trips authored playSound and stopSound interaction links", () => { + const audioAsset = { + id: "asset-audio-main", + kind: "audio" as const, + sourceName: "lobby-loop.ogg", + mimeType: "audio/ogg", + storageKey: createProjectAssetStorageKey("asset-audio-main"), + byteLength: 4096, + metadata: { + kind: "audio" as const, + durationSeconds: 4.5, + channelCount: 2, + sampleRateHz: 48000, + warnings: [] + } + } satisfies AudioAssetRecord; + const triggerVolume = createTriggerVolumeEntity({ + id: "entity-trigger-main" + }); + const soundEmitter = createSoundEmitterEntity({ + id: "entity-sound-main", + audioAssetId: audioAsset.id + }); + const playLink = createPlaySoundInteractionLink({ + id: "link-play-sound", + sourceEntityId: triggerVolume.id, + trigger: "enter", + targetSoundEmitterId: soundEmitter.id + }); + const stopLink = createStopSoundInteractionLink({ + id: "link-stop-sound", + sourceEntityId: triggerVolume.id, + trigger: "exit", + targetSoundEmitterId: soundEmitter.id + }); + const document = { + ...createEmptySceneDocument({ name: "Sound Link Scene" }), + assets: { + [audioAsset.id]: audioAsset + }, + entities: { + [triggerVolume.id]: triggerVolume, + [soundEmitter.id]: soundEmitter + }, + interactionLinks: { + [playLink.id]: playLink, + [stopLink.id]: stopLink + } + }; + + expect(parseSceneDocumentJson(serializeSceneDocument(document))).toEqual(document); + }); + it("round-trips imported model assets and placed model instances", () => { const asset = { id: "asset-model-triangle",