我正在对多维数据集和球面做一些简单的CSG操作。为此,我使用了三个csg.js库表单"https://github.com/manthrax/THREE-CSGMesh“,在给出操作后,我得到了诸如”uncaughtcsg.js“这样的错误。/3-csg.js‘不提供名为'CSG’的导出。
按如下所示编码,并根据需要添加了另外两个库(CSG-lib.js,csg-lib.js)
import { CSG } from "./three-csg.js";
// -----------------------------------------------------(scene, camera, renderer are defined)
const cubegeometry = new THREE.BoxGeometry( 0.02, 0.02, 0.02 );
const cubematerial = new THREE.MeshBasicMaterial( {color: 0x00ff00,} );
const cube = new THREE.Mesh( cubegeometry, cubematerial );
const cubegeometry = new THREE.BoxGeometry( 0.02, 0.02, 0.02 );
const cubematerial = new THREE.MeshBasicMaterial( {color: 0x00ff00,} );
const cube = new THREE.Mesh( cubegeometry, cubematerial );
const cubeCSG = CSG.fromMesh(cube);
const sphereCSG = CSG.fromMesh(sphere);
const resultCSG = cubeCSG.subtract(sphereCSG);
const CSGmaterial = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const meshCSG = CSG.toMesh( resultCSG );
meshCSG.material = CSGmaterial;
scene.add( meshCSG );发布于 2021-08-17 19:28:22
你看过演示的源代码了吗?你所需要做的就是拆下花括号
import CSG from "./three-csg.js";https://stackoverflow.com/questions/68813472
复制相似问题