Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming a hole / empty space in three.js

i'd like to programm something like a hole in three.js. it should be like, e.g. a 3x3x3 cube with an 1x1x1 hole in it. is there a possibility, that i first use something like cubegeometry and afterwards another "geometry" that cuts out the stuff that i want to have deleted? an deletion geometry? :D

Thanks :)

like image 594
Applecow Avatar asked Dec 27 '22 20:12

Applecow


1 Answers

If you are looking to "cut" things out in certain shapes, you may be interested in this post on a Constructive Solid Geometry library. It comes with a wrapper for THREE.js objects.

It lets you do things like this:

var cube = new CSG.cube();
var sphere = CSG.sphere({radius: 1.3, stacks: 16});
var geometry = cube.subtract(sphere);

=>

enter image description here

Here is another short tutorial on the subject.

like image 110
ty. Avatar answered Dec 29 '22 10:12

ty.