chore(web): checkpoint export fixes, operator routing and three-domain evidence
- Web engine CMake: apply WITH_WEB_USD_PYTHON to blender_web_engine_core, embed /usd resources, link pxr Python bindings after the core archive and whole-archive the monolithic OpenUSD archive. Fixes the wm.usd_export abort and restores Alembic/USD embedded export. - ?ui=web menus: fix inverted localOnly gating and route queueLocalDesktopOperator and nativeAdd through the desktop operator channel with a VIEW_3D context; non-mesh edit-mode selection uses the native VIEW3D_SELECT bridge. - Refresh WebEngine wasm/js artifacts, manual/course pages and the complete course video asset. - Record focused Chromium probes for Add/F3/parameters/modifier/UV/curve/deform, scene operations, OPFS save/reopen and worker restart. Evidence is NOT_CLAIMED. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -420,11 +420,13 @@ if(WITH_USD)
|
||||
set(WEB_USD_ROOT "${CMAKE_SOURCE_DIR}/../build_web_usd/install")
|
||||
endif()
|
||||
include("${WEB_USD_ROOT}/cmake/webengine-pxr.cmake")
|
||||
target_compile_definitions(web_engine PRIVATE WITH_WEB_USD_PYTHON)
|
||||
target_include_directories(web_engine PRIVATE "${WEB_USD_ROOT}/include")
|
||||
target_link_libraries(web_engine PRIVATE ${WEB_USD_PYTHON_LIBRARIES})
|
||||
# web_engine_python.cpp (which calls RegisterPlugins and registers the static
|
||||
# pxr modules) is compiled into blender_web_engine_core, not this target.
|
||||
target_compile_definitions(blender_web_engine_core PRIVATE WITH_WEB_USD_PYTHON)
|
||||
target_include_directories(blender_web_engine_core PRIVATE "${WEB_USD_ROOT}/include")
|
||||
target_link_options(web_engine PRIVATE
|
||||
"SHELL:--embed-file \"${WEB_USD_ROOT}/lib/webengine-pxr.zip@/python/lib/webengine-pxr.zip\"")
|
||||
"SHELL:--embed-file \"${WEB_USD_ROOT}/lib/webengine-pxr.zip@/python/lib/webengine-pxr.zip\""
|
||||
"SHELL:--embed-file \"${WEB_USD_ROOT}/lib/usd@/usd\"")
|
||||
set_property(TARGET web_engine APPEND PROPERTY LINK_DEPENDS
|
||||
${WEB_USD_PYTHON_LIBRARIES} "${WEB_USD_ROOT}/lib/webengine-pxr.zip")
|
||||
# Imported link options embed these files, but file contents must also dirty
|
||||
@@ -444,7 +446,9 @@ endforeach()
|
||||
if(WITH_USD)
|
||||
# Raw TARGET_FILE entries bypass bf_io_usd's link interface. Put the
|
||||
# monolithic archive once after its Blender callers and Python bindings.
|
||||
list(APPEND WEB_ENGINE_ARCHIVES ${USD_LIBRARIES})
|
||||
# Monolithic static OpenUSD relies on unreferenced registration objects
|
||||
# (file formats, resolvers, Vt types), so wasm-ld must pull the whole archive.
|
||||
list(APPEND WEB_ENGINE_ARCHIVES -Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive)
|
||||
endif()
|
||||
if(WITH_GMP)
|
||||
list(APPEND WEB_ENGINE_ARCHIVES ${GMP_LIBRARIES})
|
||||
@@ -471,6 +475,11 @@ target_link_libraries(web_engine PRIVATE
|
||||
"${WEB_CPYTHON_ROOT}/build/Modules/expat/libexpat.a"
|
||||
"${WEB_CPYTHON_ROOT}/build/Modules/_hacl/libHacl_Hash_SHA2.a"
|
||||
)
|
||||
if(WITH_USD)
|
||||
# The pxr Python bindings resolve PyInit__* symbols from this archive set,
|
||||
# which the single-pass wasm-ld scan can only pull after the core archive.
|
||||
target_link_libraries(web_engine PRIVATE ${WEB_USD_PYTHON_LIBRARIES})
|
||||
endif()
|
||||
# Reuse Blender's complete bundled font stack. The Emscripten FreeType port has
|
||||
# no Brotli decoder, so unpack WOFF2 on the host instead of replacing fonts or
|
||||
# adding a second runtime font implementation. Individual outputs are incremental
|
||||
|
||||
@@ -33,6 +33,7 @@ extern bool web_engine_blend_main_set_sequencer_strip_modifiers(WebBlendMainStat
|
||||
extern bool web_engine_blend_main_set_sequencer_transitions(WebBlendMainState *, const char *, const char *, std::string &);
|
||||
extern bool web_engine_blend_main_set_sequencer_color_balance(WebBlendMainState *, const char *, const char *, const char *, std::string &);
|
||||
extern bool web_engine_blend_main_set_compositor_node_graph(WebBlendMainState *, const char *, const char *, std::string &);
|
||||
extern bool web_engine_blend_main_compositor_evaluate(WebBlendMainState *, const char *, std::string &, int &, int &, std::string &);
|
||||
extern bool web_engine_blend_main_create_action(WebBlendMainState *, const char *, const char *, std::string &, std::string &, bool);
|
||||
extern bool web_engine_blend_main_remove_action(WebBlendMainState *, const char *, std::string &);
|
||||
extern bool web_engine_blend_main_set_keyframe(WebBlendMainState *, const char *, const char *, int, const char *, const char *, const char *, const char *, std::string &);
|
||||
@@ -4645,6 +4646,36 @@ EMSCRIPTEN_KEEPALIVE int web_engine_call_json(const int handle,
|
||||
result["step"] = params.value("step", 1);
|
||||
}
|
||||
}
|
||||
else if (cmd == "compositorEvaluate") {
|
||||
EngineState *engine = find_engine(handle);
|
||||
if (engine == nullptr || !engine->authoritative_commands || engine->authoritative_main == nullptr) {
|
||||
set_error(WEB_ENGINE_NOT_IMPLEMENTED, "COMPOSITOR_MAIN_REQUIRED: compositor evaluation requires an authoritative Main");
|
||||
return write_json_result({{"ok", false}, {"cmd", cmd}, {"code", last_error_code}, {"error", last_error_message}}, result_data, result_length);
|
||||
}
|
||||
const std::string compose_scene_id = params.value("sceneId", std::string());
|
||||
if (compose_scene_id.empty()) {
|
||||
set_error(WEB_ENGINE_INVALID_ARGUMENT, "COMPOSITOR_SCENE_REQUIRED: sceneId is required");
|
||||
return write_json_result({{"ok", false}, {"cmd", cmd}, {"code", last_error_code}, {"error", last_error_message}}, result_data, result_length);
|
||||
}
|
||||
std::string pixels_base64;
|
||||
std::string compose_error;
|
||||
int compose_width = 0;
|
||||
int compose_height = 0;
|
||||
if (!web_engine_blend_main_compositor_evaluate(engine->authoritative_main,
|
||||
compose_scene_id.c_str(),
|
||||
pixels_base64,
|
||||
compose_width,
|
||||
compose_height,
|
||||
compose_error))
|
||||
{
|
||||
set_error(WEB_ENGINE_INVALID_ARGUMENT, compose_error.c_str());
|
||||
return write_json_result({{"ok", false}, {"cmd", cmd}, {"code", last_error_code}, {"error", last_error_message}}, result_data, result_length);
|
||||
}
|
||||
result = {{"width", compose_width},
|
||||
{"height", compose_height},
|
||||
{"pixelsBase64", pixels_base64},
|
||||
{"sceneId", compose_scene_id}};
|
||||
}
|
||||
else if (cmd == "applyCommand") {
|
||||
if (!params.contains("command") || !params["command"].is_object()) {
|
||||
set_error(WEB_ENGINE_INVALID_ARGUMENT, "applyCommand params.command must be an object");
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
#include "BKE_image.hh"
|
||||
#include "BKE_image_format.hh"
|
||||
#include "IMB_imbuf_types.hh"
|
||||
#include "BKE_scene_runtime.hh"
|
||||
#include "RE_compositor.hh"
|
||||
#include "RE_pipeline.h"
|
||||
#include "BKE_idprop.hh"
|
||||
#include "BKE_geometry_set_instances.hh"
|
||||
|
||||
@@ -15667,7 +15670,18 @@ bool web_engine_blend_main_set_shader_graph(WebBlendMainState *state,
|
||||
spec.type == "BUMP" ? SH_NODE_BUMP :
|
||||
spec.type == "PRINCIPLED" ? SH_NODE_BSDF_PRINCIPLED :
|
||||
spec.type == "IMAGE_TEXTURE" ? SH_NODE_TEX_IMAGE :
|
||||
spec.type == "NORMAL_MAP" ? SH_NODE_NORMAL_MAP : SH_NODE_OUTPUT_MATERIAL;
|
||||
spec.type == "NORMAL_MAP" ? SH_NODE_NORMAL_MAP :
|
||||
spec.type == "DIFFUSE" ? SH_NODE_BSDF_DIFFUSE :
|
||||
spec.type == "GLOSSY" ? SH_NODE_BSDF_GLOSSY :
|
||||
spec.type == "EMISSION" ? SH_NODE_EMISSION :
|
||||
spec.type == "MIX_SHADER" ? SH_NODE_MIX_SHADER :
|
||||
spec.type == "ADD_SHADER" ? SH_NODE_ADD_SHADER :
|
||||
spec.type == "NOISE" ? SH_NODE_TEX_NOISE :
|
||||
spec.type == "GRADIENT" ? SH_NODE_TEX_GRADIENT :
|
||||
spec.type == "CHECKER" ? SH_NODE_TEX_CHECKER :
|
||||
spec.type == "FRESNEL" ? SH_NODE_FRESNEL :
|
||||
spec.type == "LAYER_WEIGHT" ? SH_NODE_LAYER_WEIGHT :
|
||||
SH_NODE_OUTPUT_MATERIAL;
|
||||
bNode *node = bke::node_add_static_node(nullptr, *tree, legacy_type);
|
||||
if (node == nullptr) {
|
||||
error = "SHADER_INVALID_GRAPH: Blender could not create a declared node";
|
||||
@@ -20633,6 +20647,120 @@ bool web_engine_blend_main_set_compositor_node_graph(WebBlendMainState *state,
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::string encode_base64_rgba(const std::vector<uint8_t> &bytes)
|
||||
{
|
||||
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
std::string out;
|
||||
out.reserve((bytes.size() + 2) / 3 * 4);
|
||||
size_t index = 0;
|
||||
while (index + 2 < bytes.size()) {
|
||||
const uint32_t value = (uint32_t(bytes[index]) << 16) | (uint32_t(bytes[index + 1]) << 8) |
|
||||
bytes[index + 2];
|
||||
out.push_back(table[(value >> 18) & 63]);
|
||||
out.push_back(table[(value >> 12) & 63]);
|
||||
out.push_back(table[(value >> 6) & 63]);
|
||||
out.push_back(table[value & 63]);
|
||||
index += 3;
|
||||
}
|
||||
if (index < bytes.size()) {
|
||||
uint32_t value = uint32_t(bytes[index]) << 16;
|
||||
if (index + 1 < bytes.size()) {
|
||||
value |= uint32_t(bytes[index + 1]) << 8;
|
||||
}
|
||||
out.push_back(table[(value >> 18) & 63]);
|
||||
out.push_back(table[(value >> 12) & 63]);
|
||||
out.push_back(index + 1 < bytes.size() ? table[(value >> 6) & 63] : '=');
|
||||
out.push_back('=');
|
||||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool web_engine_blend_main_compositor_evaluate(WebBlendMainState *state,
|
||||
const char *scene_id,
|
||||
std::string &pixels_base64,
|
||||
int &width,
|
||||
int &height,
|
||||
std::string &error)
|
||||
{
|
||||
Scene *scene = state != nullptr ? find_scene(state->main, scene_id) : nullptr;
|
||||
if (scene == nullptr || scene->compositing_node_group == nullptr) {
|
||||
error = "COMPOSITOR_NODE_GROUP_MISSING: scene has no compositing node group";
|
||||
return false;
|
||||
}
|
||||
ViewLayer *view_layer = static_cast<ViewLayer *>(scene->view_layers.first);
|
||||
if (view_layer == nullptr) {
|
||||
error = "COMPOSITOR_VIEW_LAYER_MISSING";
|
||||
return false;
|
||||
}
|
||||
bke::CompositorRuntime &runtime = scene->runtime->compositor;
|
||||
if (runtime.preview_depsgraph == nullptr) {
|
||||
runtime.preview_depsgraph = DEG_graph_new(state->main, scene, view_layer, DAG_EVAL_RENDER);
|
||||
}
|
||||
if (runtime.preview_depsgraph == nullptr) {
|
||||
error = "COMPOSITOR_DEPSGRAPH_UNAVAILABLE";
|
||||
return false;
|
||||
}
|
||||
DEG_graph_build_for_compositor_preview(runtime.preview_depsgraph);
|
||||
DEG_evaluate_on_refresh(runtime.preview_depsgraph);
|
||||
bNodeTree *tree = DEG_get_evaluated(runtime.preview_depsgraph, scene->compositing_node_group);
|
||||
if (tree == nullptr) {
|
||||
error = "COMPOSITOR_NODE_TREE_UNAVAILABLE";
|
||||
return false;
|
||||
}
|
||||
Render *render = RE_NewSceneRender(scene);
|
||||
if (render == nullptr) {
|
||||
error = "COMPOSITOR_RENDER_UNAVAILABLE";
|
||||
return false;
|
||||
}
|
||||
RE_compositor_execute(*render,
|
||||
*state->main,
|
||||
*scene,
|
||||
scene->r,
|
||||
*tree,
|
||||
"",
|
||||
nullptr,
|
||||
/* NodeGroupOutputTypes::GroupOutputNode (1); the compositor
|
||||
* header is not on the web_engine include path. */
|
||||
static_cast<compositor::NodeGroupOutputTypes>(1));
|
||||
RenderResult *result = RE_AcquireResultRead(render);
|
||||
if (result == nullptr || !result->have_combined) {
|
||||
if (result != nullptr) {
|
||||
RE_ReleaseResult(render);
|
||||
}
|
||||
error = "COMPOSITOR_RESULT_MISSING";
|
||||
return false;
|
||||
}
|
||||
RenderView *view = RE_RenderViewGetByName(result, "");
|
||||
ImBuf *image = view != nullptr ? RE_RenderViewEnsureImBuf(result, view) : nullptr;
|
||||
if (image == nullptr || image->x <= 0 || image->y <= 0) {
|
||||
RE_ReleaseResult(render);
|
||||
error = "COMPOSITOR_RESULT_EMPTY";
|
||||
return false;
|
||||
}
|
||||
width = image->x;
|
||||
height = image->y;
|
||||
std::vector<uint8_t> rgba(size_t(width) * size_t(height) * 4);
|
||||
if (image->float_buffer.data != nullptr) {
|
||||
const float *source = image->float_buffer.data;
|
||||
for (size_t index = 0; index < rgba.size(); index++) {
|
||||
rgba[index] = uint8_t(std::clamp(source[index], 0.0f, 1.0f) * 255.0f + 0.5f);
|
||||
}
|
||||
}
|
||||
else if (image->byte_buffer.data != nullptr) {
|
||||
std::memcpy(rgba.data(), image->byte_buffer.data, rgba.size());
|
||||
}
|
||||
else {
|
||||
RE_ReleaseResult(render);
|
||||
error = "COMPOSITOR_RESULT_UNREADABLE";
|
||||
return false;
|
||||
}
|
||||
pixels_base64 = encode_base64_rgba(rgba);
|
||||
RE_ReleaseResult(render);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_physics_simulation_json(WebBlendMainState *state,
|
||||
std::string &physics_json,
|
||||
std::string &error)
|
||||
@@ -23405,8 +23533,10 @@ bool web_engine_blend_main_set_tracking_markers(WebBlendMainState *state,
|
||||
error = "TRACKING_SCHEMA_INVALID: markers must be a bounded array";
|
||||
return false;
|
||||
}
|
||||
g_web_tracking_mask_store[state].payloads["tracking:" + std::string(clip_id) + ":" + track_id] = markers.dump();
|
||||
return true;
|
||||
/* Tracking edits are executed through the embedded bpy channel, which owns
|
||||
* the real MovieClip data. Do not report a Main mutation from this store. */
|
||||
error = "TRACKING_COMMAND_UNSUPPORTED: use the embedded bpy tracking channel";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_tracking_solve(WebBlendMainState *state,
|
||||
@@ -23423,8 +23553,8 @@ bool web_engine_blend_main_set_tracking_solve(WebBlendMainState *state,
|
||||
error = "TRACKING_SCHEMA_INVALID: solve must be an object";
|
||||
return false;
|
||||
}
|
||||
g_web_tracking_mask_store[state].payloads["solve:" + std::string(clip_id)] = solve.dump();
|
||||
return true;
|
||||
error = "TRACKING_COMMAND_UNSUPPORTED: use the embedded bpy tracking channel";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_mask_spline(WebBlendMainState *state,
|
||||
@@ -23442,8 +23572,8 @@ bool web_engine_blend_main_set_mask_spline(WebBlendMainState *state,
|
||||
error = "MASK_SCHEMA_INVALID: spline points are invalid";
|
||||
return false;
|
||||
}
|
||||
g_web_tracking_mask_store[state].payloads["spline:" + std::string(mask_id) + ":" + layer_id + ":" + spline.value("id", "")] = spline.dump();
|
||||
return true;
|
||||
error = "MASK_COMMAND_UNSUPPORTED: use the embedded bpy mask channel";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_mask_point(WebBlendMainState *state,
|
||||
@@ -23462,8 +23592,8 @@ bool web_engine_blend_main_set_mask_point(WebBlendMainState *state,
|
||||
error = "MASK_SCHEMA_INVALID: point payload is invalid";
|
||||
return false;
|
||||
}
|
||||
g_web_tracking_mask_store[state].payloads["point:" + std::string(mask_id) + ":" + layer_id + ":" + spline_id + ":" + point.value("id", "")] = point.dump();
|
||||
return true;
|
||||
error = "MASK_COMMAND_UNSUPPORTED: use the embedded bpy mask channel";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_scene_stamp_settings(WebBlendMainState *state,
|
||||
|
||||
@@ -759,6 +759,12 @@ bool web_engine_blend_main_set_compositor_node_graph(WebBlendMainState *state,
|
||||
const char *scene_id,
|
||||
const char *graph_json,
|
||||
std::string &error);
|
||||
bool web_engine_blend_main_compositor_evaluate(WebBlendMainState *state,
|
||||
const char *scene_id,
|
||||
std::string &pixels_base64,
|
||||
int &width,
|
||||
int &height,
|
||||
std::string &error);
|
||||
bool web_engine_blend_main_physics_simulation_json(WebBlendMainState *state,
|
||||
std::string &physics_json,
|
||||
std::string &error);
|
||||
|
||||
Reference in New Issue
Block a user