当前添加线框效果很好。也删除了,除了我的纹理消失了,剩下一个“黑色”模型。
删除线框并将模型恢复到旧状态的正确方法是什么?
function toggleWireframe()
{
if(wireframe == false) {
model.traverse(function(child) {
if (child.isMesh) {
// Add a mesh which will be used for our wireframe
let geometry = child.geometry;
let material = child.material.color = new THREE.Color(0x000000);
let mesh = new THREE.Mesh(geometry, material);
mesh.name = 'mesh';
scene.add(mesh);
// Setup our wireframe
const wireframeGeometry = new THREE.WireframeGeometry(geometry);
const wireframeMaterial = new THREE.LineBasicMaterial({color: 0xFFFFFF});
const wireframe = new THREE.LineSegments(wireframeGeometry, wireframeMaterial);
wireframe.name = 'wireframe';
mesh.add(wireframe);
}
});
wireframe = true;
} else {
scene.remove(scene.getObjectByName('mesh'));
scene.remove(scene.getObjectByName('wireframe'));
wireframe = false;
}
}