如何从threejs应用程序导出变形改变的网格? [英] How to export morph changed meshes from threejs application?

查看:33
本文介绍了如何从threejs应用程序导出变形改变的网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自定义一个网格,然后使用 Threejs 的 gltfExporter 将其导出,但是它仍然导出所有变形/形状键,我想在最终导出网格中删除它们.

I'm trying to customize a mesh and then export it by using gltfExporter from Threejs, however it still exports with all morph/shape keys attached, I would like to remove them in the final export mesh.

克隆场景/网格不起作用.

Cloning the scene / mesh didn't work.

function exportModel() {
    var exporter = new THREE.GLTFExporter();
    if (!gltfExportEnabled) gltfExporterConfig.binary = false;

    var finalRenderModel = mainScene.children[2];
    // Remove Morph Targets
    if (!!removeExportMorphs) {
        // finalRenderModel.children[0].children[1].morphTargetDictionary = [];
        // finalRenderModel.children[0].children[1].morphTargetInfluences = [];
    }
    exporter.parse([finalRenderModel], function(gltf) {
        if (!!gltfExportEnabled) generateDownload([gltf], exportFileName + ".glb");
    }, gltfExporterConfig);
}

var generateDownload = (function() {
    var a = document.createElement("a");
    document.body.appendChild(a);
    a.style = "display: none";
    return function(data, name) {
        var blob = new Blob(data, { type: "octet/stream" }),
            url = window.URL.createObjectURL(blob);
        a.href = url;
        a.download = name;
        a.click();
        window.URL.revokeObjectURL(url);
    };
}());

网格被导出并附有所有变形/形状键或不导出

Mesh gets exported with all morphs/shape keys attached or does not get exported

推荐答案

如果你额外执行这段代码是否有帮助:

Does it help if you additionally execute this code:

finalRenderModel.children[0].children[1].geometry.morphAttributes = {};

变形属性被分配给几何体.Mesh.morphTargetInfluencesMesh.morphTargetDictionary 在创建 Mesh 的新实例时基于这些几何数据生成.

Morph attributes are assigned to the geometry. Mesh.morphTargetInfluences and Mesh.morphTargetDictionary are generated based on these geometry data when a new instance of Mesh is created.

three.js R107

这篇关于如何从threejs应用程序导出变形改变的网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆