Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a cube with rounded corners in Three.js

Is it possible to create a cube with rounded corners of custom radius in three.js and then be able to texture that cube with an image?

like image 337
fncombo Avatar asked Oct 21 '12 01:10

fncombo


2 Answers

You can use RoundedBoxGeometry from the three.js examples.

const geometry = new RoundedBoxGeometry( 10, 10, 10, 6, 2 );

Import it into your project using a pattern like so:

import { RoundedBoxGeometry } from './threejs/examples/jsm/geometries/RoundedBoxGeometry.js';

three.js r.131

like image 196
WestLangley Avatar answered Sep 20 '22 14:09

WestLangley


For a simple and straightforward example of subdivision modifiers on cubes (and other basic geometries), check out

http://stemkoski.github.com/Three.js/Subdivision-Cube.html

like image 41
Stemkoski Avatar answered Sep 19 '22 14:09

Stemkoski