我正在尝试截取使用three.js 的STLLoader 函数加载的心脏模型的横截面。我目前正在尝试将ThreeCSG包装器用于csg.js库,与此堆栈溢出帖子中的相同。
这是我的 csg 减法代码
function modelLoadedCallBack( geometry ) {
material = new THREE.MeshPhongMaterial( { color: model.color } );
mesh = new THREE.Mesh( geometry, material );
mesh.rotation.set( model.rotationX, model.rotationY, model.rotationZ );
mesh.scale.set( model.scale, model.scale, model.scale );
var originalBSP = new ThreeBSP( mesh );
var xSectionBSP = new ThreeBSP( xSection );
var subtractedBSP = originalBSP.subtract( xSectionBSP );
var result = subtractedBSP.toMesh( material );
result.geometry.computeVertexNormals();
scene.add( result );
};
我加载了 stl 模型,然后在加载器的回调函数中,我尝试减去网格。我得到的错误是在 ThreeCSG 包装文件的第 34 行,说
ThreeCSG.js:34 Uncaught TypeError:无法读取未定义的属性“长度”
我猜这是因为(a)我没有正确使用 ThreeCSG,(b)我需要在代码的其他地方做减法,或者(c)不支持 STL 格式模型。
无论如何,我完全被难住了,我会感谢在使用 three.js 方面更有经验的人的建议。