feat(web): wire Blender light contribution factors
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-30 18:36:55 +08:00
parent 2f00b3e322
commit 8bc5d61b75
41 changed files with 1967 additions and 24 deletions

View File

@@ -541,9 +541,10 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
case "setLightProperties": {
const light = currentSnapshot?.lights.find((candidate) => candidate.id === payload.dataId);
const properties = payload.properties;
if (!light || !validPropertyKeys(properties, ["type", "areaShape", "color", "energy", "exposure", "temperature", "useTemperature", "castsShadow", "radius", "spotAngle", "spotBlend", "areaSize", "areaSizeY", "areaSpread", "sunAngle"])) throw report("RENDER_PROPERTY_INVALID", "Light target or properties are invalid");
if (!light || !validPropertyKeys(properties, ["type", "areaShape", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "color", "energy", "exposure", "temperature", "useTemperature", "castsShadow", "radius", "spotAngle", "spotBlend", "areaSize", "areaSizeY", "areaSpread", "sunAngle"])) throw report("RENDER_PROPERTY_INVALID", "Light target or properties are invalid");
if (properties.type !== undefined && !["POINT", "SUN", "SPOT", "AREA"].includes(properties.type)) throw report("RENDER_PROPERTY_INVALID", "Light type is invalid");
if (properties.areaShape !== undefined && ![0, 1, 4, 5].includes(properties.areaShape)) throw report("RENDER_PROPERTY_INVALID", "Light area shape is invalid");
for (const field of ["diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor"] as const) if (properties[field] !== undefined && !boundedNumber(properties[field], 0, 1)) throw report("RENDER_PROPERTY_INVALID", `Light ${field} is outside the bounded range`);
if (properties.color !== undefined && (!Array.isArray(properties.color) || properties.color.length !== 3 || properties.color.some((value) => !boundedNumber(value, 0, 100)))) throw report("RENDER_PROPERTY_INVALID", "Light color is invalid");
for (const [field, minimum, maximum] of [["energy", 0, 1e9], ["exposure", -20, 20], ["temperature", 800, 20000], ["radius", 0, 1e9], ["spotAngle", 0.0001, Math.PI], ["spotBlend", 0, 1], ["areaSize", 0.0001, 1e9], ["areaSizeY", 0.0001, 1e9], ["areaSpread", 0.0001, Math.PI], ["sunAngle", 0, Math.PI]] as const) {
const value = properties[field];