首先,我使用:
npm install three --save
npm install @types/three
npm install three-js-csg --save
之后:
import * as THREE from 'three';
import * as csg from 'three-js-csg';
let sphere1BSP = new csg(sphere1);
let cube2BSP = new csg(cube);
let resultBSP = sphere1BSP.subtract(cube2BSP);
但是它引发了以下异常:
core.js:1633错误错误:未捕获(承诺):TypeError: sphere1BSP.subtract不是函数
答案 0 :(得分:0)
基于npm页面:https://www.npmjs.com/package/three-js-csg,看来您可能需要使用 THREE 实例化“ three-js-csg”。
import THREE from 'three';
import * as csg from 'three-js-csg';
const ThreeBSG = csg(THREE);
虽然我没有对此进行测试,所以我可能会误会了。