feat(web): wire Blender light clip start
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 19:48:41 +08:00
parent 6414d899fb
commit e9e1788b14
38 changed files with 1952 additions and 21 deletions

View File

@@ -5178,6 +5178,7 @@ json scene_ir_from_blend(const ParsedBlend &blend,
{"areaSize", read_float(*blend.sdna, element, "area_size").value_or(0.25f)},
{"areaSizeY", read_float(*blend.sdna, element, "area_sizey").value_or(0.25f)},
{"areaSizeZ", read_float(*blend.sdna, element, "area_sizez").value_or(0.25f)},
{"clipStart", read_float(*blend.sdna, element, "clipsta").value_or(0.05f)},
{"areaSpread", read_float(*blend.sdna, element, "area_spread").value_or(3.14159265f)},
{"sunAngle", read_float(*blend.sdna, element, "sun_angle").value_or(0.00918f)}});
}

View File

@@ -5569,6 +5569,29 @@ bool web_engine_blend_main_set_light_area_size_z(WebBlendMainState *state,
return true;
}
bool web_engine_blend_main_set_light_clip_start(WebBlendMainState *state,
const char *target_id,
const float clip_start,
std::string &error)
{
if (state == nullptr || state->main == nullptr || target_id == nullptr) {
error = "RENDER_PROPERTY_INVALID: light clip start target is missing";
return false;
}
Light *light = find_light(state->main, target_id);
if (light == nullptr || !ensure_single_user_data(state->main, &light->id, error)) {
if (error.empty()) error = "RENDER_PROPERTY_INVALID: light was not found";
return false;
}
if (!std::isfinite(clip_start) || clip_start < 0.0001f || clip_start > 1.0e9f) {
error = "RENDER_PROPERTY_INVALID: light clip start is outside the bounded range";
return false;
}
light->clipsta = clip_start;
light->id.recalc |= ID_RECALC_PARAMETERS;
return true;
}
bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
const char *target_id,
const char *properties_json,
@@ -5765,7 +5788,7 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
if (strncmp(target_id, "light:", 6) == 0) {
Light *light = find_light(state->main, target_id);
if (light == nullptr || !ensure_single_user_data(state->main, &light->id, error)) return false;
if (!reject_unknown({"type", "areaShape", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "areaSizeZ", "color", "energy", "exposure", "temperature", "useTemperature",
if (!reject_unknown({"type", "areaShape", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "areaSizeZ", "clipStart", "color", "energy", "exposure", "temperature", "useTemperature",
"castsShadow", "radius", "spotAngle", "spotBlend", "areaSize",
"areaSizeY", "areaSpread", "sunAngle"}))
{
@@ -5848,6 +5871,13 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
}
if (!web_engine_blend_main_set_light_area_size_z(state, target_id, properties["areaSizeZ"].get<float>(), error)) return false;
}
if (properties.contains("clipStart")) {
if (!properties["clipStart"].is_number()) {
error = "RENDER_PROPERTY_INVALID: clipStart must be numeric";
return false;
}
if (!web_engine_blend_main_set_light_clip_start(state, target_id, properties["clipStart"].get<float>(), error)) return false;
}
if (!read_color("color", &light->r) ||
!read_float("energy", 0.0f, 1.0e9f, light->energy) ||
!read_float("exposure", -20.0f, 20.0f, light->exposure) ||

View File

@@ -549,6 +549,10 @@ bool web_engine_blend_main_set_light_area_size_z(WebBlendMainState *state,
const char *target_id,
float area_size_z,
std::string &error);
bool web_engine_blend_main_set_light_clip_start(WebBlendMainState *state,
const char *target_id,
float clip_start,
std::string &error);
bool web_engine_blend_main_set_scene_properties(WebBlendMainState *state,
const char *target_id,
const char *properties_json,