回答編集履歴
1
追記
test
CHANGED
@@ -13,3 +13,63 @@
|
|
13
13
|
また、以下のようなものもありましたので`BoxGeometry()`を元にしても作成できるのかもしれません。ご参考までに。
|
14
14
|
|
15
15
|
https://threejs.org/examples/webgl_modifier_subdivision.html
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
追記
|
20
|
+
|
21
|
+
私の環境ですと以下のようなコードで角丸BOXが表示されましたがダメでしょうか?
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
//中略
|
26
|
+
|
27
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/89/three.min.js"></script>
|
28
|
+
|
29
|
+
//中略
|
30
|
+
|
31
|
+
var cubeGeometry = new createBoxWithRoundedEdges(300, 300, 300, 30, 2);
|
32
|
+
|
33
|
+
var cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000});
|
34
|
+
|
35
|
+
var cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
|
36
|
+
|
37
|
+
//中略
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
function createBoxWithRoundedEdges( width, height, depth, radius0, smoothness ) {
|
42
|
+
|
43
|
+
let shape = new THREE.Shape();
|
44
|
+
|
45
|
+
let eps = 0.00001;
|
46
|
+
|
47
|
+
let radius = radius0 - eps;
|
48
|
+
|
49
|
+
shape.absarc( eps, eps, eps, -Math.PI / 2, -Math.PI, true );
|
50
|
+
|
51
|
+
shape.absarc( eps, height - radius * 2, eps, Math.PI, Math.PI / 2, true );
|
52
|
+
|
53
|
+
shape.absarc( width - radius * 2, height - radius * 2, eps, Math.PI / 2, 0, true );
|
54
|
+
|
55
|
+
shape.absarc( width - radius * 2, eps, eps, 0, -Math.PI / 2, true );
|
56
|
+
|
57
|
+
let geometry = new THREE.ExtrudeBufferGeometry( shape, {
|
58
|
+
|
59
|
+
amount: depth - radius0 * 2,
|
60
|
+
|
61
|
+
bevelEnabled: true,
|
62
|
+
|
63
|
+
bevelSegments: smoothness * 2,
|
64
|
+
|
65
|
+
steps: 1,
|
66
|
+
|
67
|
+
bevelSize: radius,
|
68
|
+
|
69
|
+
bevelThickness: radius0,
|
70
|
+
|
71
|
+
curveSegments: smoothness
|
72
|
+
|
73
|
+
});
|
74
|
+
|
75
|
+
```
|