问题
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