CSG (THREE.js) » 将本地 csg.js 导入另一个 JS 文件?

CSG (THREE.js) » Import local csg.js into another JS-File?

我想与 THREE.js 合作,尤其是与 CSG 合作,这样我就可以使用布尔运算将两个 obj 模型相互减去。 为此,我将相应的本地文件导入中央 JavaScript 文件,以便我可以在其中使用它们。

THREE.jsOBJLoader2等,我是这样解决的:

import * as THREE from './three.module.js';

import {OBJLoader2} from './OBJLoader2.js';

import {MTLLoader} from './MTLLoader.js';

然后我就可以访问相应的元素了。 (例如 const objLoader = new OBJLoader2();) 所以我目前能够导入 obj 模型并在 canvas 元素中可视化它们。

很遗憾,我无法为 CSG.js 文件执行此操作。

我在这里找到了文件:https://github.com/evanw/csg.js/blob/master/csg.js

如何将本地 CSG.js 文件导入中央 JavaScript 文件?

import * as CSGfrom './CSG.js';

import {CSG} from './CSG.js';

不幸的是,这两种导入都不起作用。

使用我的 csg 库 :) 它比现有的 csg 库更健壮。

https://github.com/manthrax/THREE-CSGMesh