javascriptimportthree.jscsg

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


I want to work with THREE.js and especially with CSG, so that I can subtract two obj models from each other using boolean operations. For this purpose I import the respective local files in a central JavaScript file, so that I can work with them in it.

With THREE.js, OBJLoader2, etc. I have solved it that way:

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

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

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

Then I can access the corresponding elements. (e.g. const objLoader = new OBJLoader2();) So I am currently able to import obj models and visualize them in a canvas element.

Unfortunately I can't do this for the CSG.js file.

I found the file here: https://github.com/evanw/csg.js/blob/master/csg.js.

How do I import the local CSG.js file into my central JavaScript file?

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

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

Both imports unfortunately do not work.


Solution

  • Use my csg library :) Its more robust than the existing csg library.

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