Add point light and spot light entities to test scene

This commit is contained in:
2026-03-31 20:17:34 +02:00
parent f73f9571f3
commit 5f3afaf97e

View File

@@ -3,9 +3,11 @@ import { describe, expect, it } from "vitest";
import { createBoxBrush } from "../../src/document/brushes"; import { createBoxBrush } from "../../src/document/brushes";
import { createEmptySceneDocument } from "../../src/document/scene-document"; import { createEmptySceneDocument } from "../../src/document/scene-document";
import { import {
createPointLightEntity,
createInteractableEntity, createInteractableEntity,
createPlayerStartEntity, createPlayerStartEntity,
createSoundEmitterEntity, createSoundEmitterEntity,
createSpotLightEntity,
createTeleportTargetEntity, createTeleportTargetEntity,
createTriggerVolumeEntity createTriggerVolumeEntity
} from "../../src/entities/entity-instances"; } from "../../src/entities/entity-instances";
@@ -87,6 +89,42 @@ describe("buildRuntimeSceneFromDocument", () => {
prompt: "Use Console", prompt: "Use Console",
enabled: true 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 = { const modelAsset = {
id: "asset-model-triangle", id: "asset-model-triangle",
kind: "model" as const, kind: "model" as const,
@@ -149,7 +187,8 @@ describe("buildRuntimeSceneFromDocument", () => {
[brush.id]: brush [brush.id]: brush
}, },
assets: { assets: {
[modelAsset.id]: modelAsset [modelAsset.id]: modelAsset,
[imageAsset.id]: imageAsset
}, },
modelInstances: { modelInstances: {
[modelInstance.id]: modelInstance [modelInstance.id]: modelInstance
@@ -159,7 +198,9 @@ describe("buildRuntimeSceneFromDocument", () => {
[soundEmitter.id]: soundEmitter, [soundEmitter.id]: soundEmitter,
[triggerVolume.id]: triggerVolume, [triggerVolume.id]: triggerVolume,
[teleportTarget.id]: teleportTarget, [teleportTarget.id]: teleportTarget,
[interactable.id]: interactable [interactable.id]: interactable,
[pointLight.id]: pointLight,
[spotLight.id]: spotLight
}, },
interactionLinks: { interactionLinks: {
"link-teleport": createTeleportPlayerInteractionLink({ "link-teleport": createTeleportPlayerInteractionLink({
@@ -184,9 +225,8 @@ describe("buildRuntimeSceneFromDocument", () => {
} }
}; };
document.world.background = { document.world.background = {
mode: "verticalGradient", mode: "image",
topColorHex: "#5f7693", assetId: imageAsset.id
bottomColorHex: "#11161d"
}; };
document.world.ambientLight.intensity = 0.55; document.world.ambientLight.intensity = 0.55;
document.world.sunLight.direction = { 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([ expect(runtimeScene.interactionLinks).toEqual([
{ {
id: "link-click-teleport", id: "link-click-teleport",