feat(web): wire Blender area light depth
This commit is contained in:
@@ -541,15 +541,16 @@ 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", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "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", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "areaSizeZ", "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`);
|
||||
for (const [field, minimum, maximum] of [["attenuationDistance", 0, 1e9], ["shadowFilterRadius", 0, 1e9], ["shadowMaximumResolution", 0.0000001, 1e9], ["shadowJitterOverblur", 0, 1e9]] as const) if (properties[field] !== undefined && !boundedNumber(properties[field], minimum, maximum)) throw report("RENDER_PROPERTY_INVALID", `Light ${field} is outside the bounded range`);
|
||||
for (const [field, minimum, maximum] of [["cascadeMaxDistance", 0, 1e9], ["cascadeExponent", 0, 100], ["cascadeFade", 0, 1]] as const) if (properties[field] !== undefined && !boundedNumber(properties[field], minimum, maximum)) throw report("RENDER_PROPERTY_INVALID", `Light ${field} is outside the bounded range`);
|
||||
if (properties.cascadeCount !== undefined && (!Number.isSafeInteger(properties.cascadeCount) || properties.cascadeCount < 1 || properties.cascadeCount > 4)) throw report("RENDER_PROPERTY_INVALID", "Light cascade count is outside the bounded range");
|
||||
if (properties.areaSizeZ !== undefined && !boundedNumber(properties.areaSizeZ, 0.0001, 1e9)) throw report("RENDER_PROPERTY_INVALID", "Light areaSizeZ 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) {
|
||||
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], ["areaSizeZ", 0.0001, 1e9], ["areaSpread", 0.0001, Math.PI], ["sunAngle", 0, Math.PI]] as const) {
|
||||
const value = properties[field];
|
||||
if (value !== undefined && !boundedNumber(value, minimum, maximum)) throw report("RENDER_PROPERTY_INVALID", `Light ${field} is outside the bounded range`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user