If you're looking to apply boolean operations in your code, you might want to explore the possibilities offered by a library like ThreeCSG.js.
Imagine you have two mesh objects named cube_one
and cube_two
. You can perform the following operations:
cube_one_bsp = new ThreeBSP( cube_one );
cube_two_bsp = new ThreeBSP( cube_two );
cube_three_bsp = cube_one_bsp.intersect( cube_two_bsp );
After this, you can assign any material you desire to the resulting mesh called cube_three
by transforming it back to a THREE.Mesh
using the toMesh
method:
mesh = cube_three_bsp.toMesh( material );
Now, you have successfully created the intersected object as a THREE.Mesh
with your own custom material...