chore: checkpoint web Blender migration source, tools and docs
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

Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-10 11:18:01 +08:00
parent 122142c26c
commit f3e21c6b98
6887 changed files with 257154 additions and 12294 deletions

View File

@@ -8,10 +8,12 @@
#include <algorithm>
#include <system_error>
#include <stdexcept>
#include "BKE_attribute.hh"
#include "BKE_blender_version.h"
#include "BKE_mesh.hh"
#include "BKE_packedFile.hh"
#include "BLI_color_types.hh"
#include "BLI_enumerable_thread_specific.hh"
@@ -709,8 +711,21 @@ void MTLWriter::write_texture_map(const MTLMaterial &mtl_material,
options.append(" -bm ").append(std::to_string(mtl_material.normal_strength));
}
std::string path = path_reference(
texture_map.image_path.c_str(), blen_filedir, dest_dir, path_mode, &copy_set);
std::string path;
#ifdef WITH_WEB
if (texture_map.packed_file && path_mode == PATH_REFERENCE_COPY) {
path = BLI_path_basename(texture_map.image_path.c_str());
char filepath[FILE_MAX];
BLI_path_join(filepath, sizeof(filepath), dest_dir, path.c_str());
if (BKE_packedfile_write_to_file(nullptr, blen_filedir, filepath, texture_map.packed_file) != RET_OK) {
throw std::runtime_error("Unable to export packed OBJ texture");
}
} else
#endif
{
path = path_reference(
texture_map.image_path.c_str(), blen_filedir, dest_dir, path_mode, &copy_set);
}
/* Always emit forward slashes for cross-platform compatibility. */
std::replace(path.begin(), path.end(), '\\', '/');

View File

@@ -375,6 +375,12 @@ static void store_image_textures(const bNode *bsdf_node,
copy_property_from_node(SOCK_VECTOR, mapping, "Scale", {value.scale, 3});
value.image_path = tex_image_filepath;
#ifdef WITH_WEB
const Image *image = reinterpret_cast<const Image *>(tex_node->id);
if (const auto *packed = static_cast<const ImagePackedFile *>(image->packedfiles.first)) {
value.packed_file = packed->packedfile;
}
#endif
}
}

View File

@@ -15,6 +15,7 @@
namespace blender {
struct Material;
struct PackedFile;
namespace io::obj {
@@ -45,6 +46,9 @@ struct MTLTexMap {
/* Only Flat and Sphere projections are supported. */
int projection_type = SHD_PROJ_FLAT;
std::string image_path;
#ifdef WITH_WEB
PackedFile *packed_file = nullptr;
#endif
std::string mtl_dir_path;
};

View File

@@ -9,6 +9,7 @@
#include <cstdio>
#include <memory>
#include <system_error>
#include <stdexcept>
#include "DNA_collection_types.h"
#include "DNA_curve_enums.h"
@@ -344,7 +345,12 @@ void export_objects(const OBJExportParams &export_params,
write_mesh_objects(meshes, *obj_writer, mtl_writer.get(), export_params);
write_nurbs_curve_objects(curves, *obj_writer);
if (mtl_writer && export_params.export_materials) {
write_materials(mtl_writer.get(), export_params);
try {
write_materials(mtl_writer.get(), export_params);
}
catch (const std::runtime_error &ex) {
BKE_report(export_params.reports, RPT_ERROR, ex.what());
}
}
}
@@ -373,7 +379,14 @@ bool append_frame_to_filename(const char *filepath,
void exporter_main(bContext *C, const OBJExportParams &export_params)
{
#ifdef WITH_WEB
if (Object *active = CTX_data_active_object(C); active && active->mode != OB_MODE_OBJECT) {
BKE_report(export_params.reports, RPT_ERROR, "Web OBJ export requires Object mode");
return;
}
#else
ed::object::mode_set(C, OB_MODE_OBJECT);
#endif
Collection *collection = nullptr;
if (export_params.collection[0]) {

View File

@@ -77,6 +77,12 @@ static Image *load_image_at_path(Main *bmain, const std::string &path, bool rela
return nullptr;
}
CLOG_INFO(&LOG, "Loaded image from: '%s'", path.c_str());
#ifdef WITH_WEB
if (path.find("/browser/cache/") == 0 && path.find("/model/") != std::string::npos &&
!BKE_image_has_packedfile(image)) {
BKE_image_packfiles(nullptr, image, BKE_main_blendfile_path(bmain));
}
#endif
if (relative_paths) {
BLI_path_rel(image->filepath, BKE_main_blendfile_path(bmain));
BLI_path_normalize(image->filepath);