2

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.

1 Answer 1

-1

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

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much for reply. How can I convert an Object3D into a mesh?
function convert2BSP (object) { var BSP; object.traverse( function ( child ) { //console.dir(child); if ( child instanceof THREE.Mesh ) { //console.dir(child); BSP = child.clone(); BSP = CSG.fromMesh(BSP); } }); return BSP; } » I get the Mesh of the Object3D, but how can I Subtract?
Thank your very much, it works with your library :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.