feat(web): wire Blender world probe controls
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 20:32:02 +08:00
parent b15ac3770a
commit 6692739cfe
38 changed files with 1976 additions and 20 deletions

View File

@@ -585,10 +585,12 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
case "setWorldProperties": {
const world = currentSnapshot?.worlds.find((candidate) => candidate.id === payload.dataId);
const properties = payload.properties;
if (!world || !validPropertyKeys(properties, ["color", "exposure", "ambientOcclusionDistance", "ambientOcclusionEnergy", "sunThreshold", "sunAngle", "sunShadowMaximumResolution", "sunShadowJitterOverblur", "sunShadowFilterRadius", "mist"])) throw report("RENDER_PROPERTY_INVALID", "World target or properties are invalid");
if (!world || !validPropertyKeys(properties, ["color", "exposure", "ambientOcclusionDistance", "ambientOcclusionEnergy", "sunThreshold", "sunAngle", "sunShadowMaximumResolution", "sunShadowJitterOverblur", "sunShadowFilterRadius", "probeResolution", "useSunShadow", "useSunShadowJitter", "mist"])) throw report("RENDER_PROPERTY_INVALID", "World target or properties are invalid");
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", "World color is invalid");
if (properties.exposure !== undefined && !boundedNumber(properties.exposure, -20, 20)) throw report("RENDER_PROPERTY_INVALID", "World exposure is invalid");
for (const [field, minimum, maximum] of [["ambientOcclusionDistance", 0, 1e9], ["ambientOcclusionEnergy", 0, 1e9], ["sunThreshold", 0, 1e9], ["sunAngle", 0, Math.PI], ["sunShadowMaximumResolution", 0.0000001, 1e9], ["sunShadowJitterOverblur", 0, 1e9], ["sunShadowFilterRadius", 0, 1e9]] as const) if (properties[field] !== undefined && !boundedNumber(properties[field], minimum, maximum)) throw report("RENDER_PROPERTY_INVALID", `World ${field} is outside the bounded range`);
if (properties.probeResolution !== undefined && (!Number.isSafeInteger(properties.probeResolution) || properties.probeResolution < 7 || properties.probeResolution > 12)) throw report("RENDER_PROPERTY_INVALID", "World probe resolution is invalid");
for (const field of ["useSunShadow", "useSunShadowJitter"] as const) if (properties[field] !== undefined && typeof properties[field] !== "boolean") throw report("RENDER_PROPERTY_INVALID", `World ${field} must be boolean`);
if (properties.mist !== undefined) {
const mist = properties.mist;
if (!validPropertyKeys(mist, ["enabled", "type", "start", "depth", "intensity", "height"])) throw report("RENDER_PROPERTY_INVALID", "World mist is invalid");