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

问题描述

我试图自定义网格,然后使用Threejs中的gltfExporter导出它,但是它仍然在导出时附加了所有的morph / shape键,我想在最终的导出网格中将其删除。

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.

克隆场景/网格无效。

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.morphTargetInfluences 和 Mesh.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应用程序导出变形的网格物体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 10:40