How to export morph changed meshes from threejs application?

[亡魂溺海] 提交于 2019-12-11 19:56:02

问题


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


回答1:


Does it help if you additionally execute this code:

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

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



来源:https://stackoverflow.com/questions/57423471/how-to-export-morph-changed-meshes-from-threejs-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!