feat(web): wire Blender world environment strength
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:59:14 +08:00
parent 6692739cfe
commit ed25fafee2
36 changed files with 1947 additions and 19 deletions

View File

@@ -5660,6 +5660,35 @@ bool web_engine_blend_main_set_world_probe_controls(WebBlendMainState *state,
return true;
}
bool web_engine_blend_main_set_world_environment_strength(WebBlendMainState *state,
const char *target_id,
const float strength,
std::string &error)
{
if (state == nullptr || state->main == nullptr || target_id == nullptr) {
error = "RENDER_PROPERTY_INVALID: world environment target is missing";
return false;
}
World *world = find_world(state->main, target_id);
if (world == nullptr || world->id.lib != nullptr) {
error = "LINKED_DATA_MUTATION_BLOCKED: World is not editable";
return false;
}
if (!std::isfinite(strength) || strength < 0.0f || strength > 1.0e9f) {
error = "RENDER_PROPERTY_INVALID: world environment strength is outside the bounded range";
return false;
}
bNode *background = find_node(world->nodetree, SH_NODE_BACKGROUND);
if (background == nullptr) {
error = "RENDER_PROPERTY_INVALID: World Background node is unavailable";
return false;
}
set_socket_float(background, "Strength", strength);
if (world->nodetree != nullptr) world->nodetree->id.recalc |= ID_RECALC_NTREE_OUTPUT;
world->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,
@@ -5981,7 +6010,7 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
if (strncmp(target_id, "world:", 6) == 0) {
World *world = find_world(state->main, target_id);
if (world == nullptr || world->id.lib != nullptr ||
!reject_unknown({"color", "exposure", "ambientOcclusionDistance", "ambientOcclusionEnergy", "sunThreshold", "sunAngle", "sunShadowMaximumResolution", "sunShadowJitterOverblur", "sunShadowFilterRadius", "probeResolution", "useSunShadow", "useSunShadowJitter", "mist"}) ||
!reject_unknown({"color", "exposure", "environmentStrength", "ambientOcclusionDistance", "ambientOcclusionEnergy", "sunThreshold", "sunAngle", "sunShadowMaximumResolution", "sunShadowJitterOverblur", "sunShadowFilterRadius", "probeResolution", "useSunShadow", "useSunShadowJitter", "mist"}) ||
!read_color("color", &world->horr) ||
!read_float("exposure", -20.0f, 20.0f, world->exposure))
{
@@ -6028,6 +6057,13 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
}
if (!web_engine_blend_main_set_world_probe_controls(state, target_id, probe_resolution, use_sun_shadow, use_sun_shadow_jitter, error)) return false;
}
if (properties.contains("environmentStrength")) {
if (!properties["environmentStrength"].is_number()) {
error = "RENDER_PROPERTY_INVALID: environmentStrength must be numeric";
return false;
}
if (!web_engine_blend_main_set_world_environment_strength(state, target_id, properties["environmentStrength"].get<float>(), error)) return false;
}
if (properties.contains("mist")) {
const json &mist = properties["mist"];
if (!mist.is_object() || mist.empty()) {

View File

@@ -569,6 +569,10 @@ bool web_engine_blend_main_set_world_probe_controls(WebBlendMainState *state,
bool use_sun_shadow,
bool use_sun_shadow_jitter,
std::string &error);
bool web_engine_blend_main_set_world_environment_strength(WebBlendMainState *state,
const char *target_id,
float strength,
std::string &error);
bool web_engine_blend_main_set_scene_properties(WebBlendMainState *state,
const char *target_id,
const char *properties_json,