From 5f3afaf97e1949a5b26e34fac33b44be06aeb0c8 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 31 Mar 2026 20:17:34 +0200 Subject: [PATCH] Add point light and spot light entities to test scene --- tests/domain/build-runtime-scene.test.ts | 84 ++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 5 deletions(-) diff --git a/tests/domain/build-runtime-scene.test.ts b/tests/domain/build-runtime-scene.test.ts index 3e681a77..bf8063ae 100644 --- a/tests/domain/build-runtime-scene.test.ts +++ b/tests/domain/build-runtime-scene.test.ts @@ -3,9 +3,11 @@ import { describe, expect, it } from "vitest"; import { createBoxBrush } from "../../src/document/brushes"; import { createEmptySceneDocument } from "../../src/document/scene-document"; import { + createPointLightEntity, createInteractableEntity, createPlayerStartEntity, createSoundEmitterEntity, + createSpotLightEntity, createTeleportTargetEntity, createTriggerVolumeEntity } from "../../src/entities/entity-instances"; @@ -87,6 +89,42 @@ describe("buildRuntimeSceneFromDocument", () => { prompt: "Use Console", enabled: true }); + const pointLight = createPointLightEntity({ + id: "entity-point-light-main", + position: { + x: 2, + y: 3, + z: 1 + } + }); + const spotLight = createSpotLightEntity({ + id: "entity-spot-light-main", + position: { + x: -2, + y: 4, + z: 0 + }, + direction: { + x: 0.2, + y: -1, + z: 0.1 + } + }); + const imageAsset = { + id: "asset-background-panorama", + kind: "image" as const, + sourceName: "skybox-panorama.svg", + mimeType: "image/svg+xml", + storageKey: createProjectAssetStorageKey("asset-background-panorama"), + byteLength: 2048, + metadata: { + kind: "image" as const, + width: 512, + height: 256, + hasAlpha: false, + warnings: [] + } + }; const modelAsset = { id: "asset-model-triangle", kind: "model" as const, @@ -149,7 +187,8 @@ describe("buildRuntimeSceneFromDocument", () => { [brush.id]: brush }, assets: { - [modelAsset.id]: modelAsset + [modelAsset.id]: modelAsset, + [imageAsset.id]: imageAsset }, modelInstances: { [modelInstance.id]: modelInstance @@ -159,7 +198,9 @@ describe("buildRuntimeSceneFromDocument", () => { [soundEmitter.id]: soundEmitter, [triggerVolume.id]: triggerVolume, [teleportTarget.id]: teleportTarget, - [interactable.id]: interactable + [interactable.id]: interactable, + [pointLight.id]: pointLight, + [spotLight.id]: spotLight }, interactionLinks: { "link-teleport": createTeleportPlayerInteractionLink({ @@ -184,9 +225,8 @@ describe("buildRuntimeSceneFromDocument", () => { } }; document.world.background = { - mode: "verticalGradient", - topColorHex: "#5f7693", - bottomColorHex: "#11161d" + mode: "image", + assetId: imageAsset.id }; document.world.ambientLight.intensity = 0.55; document.world.sunLight.direction = { @@ -330,6 +370,40 @@ describe("buildRuntimeSceneFromDocument", () => { } ] }); + expect(runtimeScene.localLights).toEqual({ + pointLights: [ + { + entityId: "entity-point-light-main", + position: { + x: 2, + y: 3, + z: 1 + }, + colorHex: "#ffffff", + intensity: 1.25, + distance: 8 + } + ], + spotLights: [ + { + entityId: "entity-spot-light-main", + position: { + x: -2, + y: 4, + z: 0 + }, + direction: { + x: 0.2, + y: -1, + z: 0.1 + }, + colorHex: "#ffffff", + intensity: 1.5, + distance: 12, + angleDegrees: 35 + } + ] + }); expect(runtimeScene.interactionLinks).toEqual([ { id: "link-click-teleport",