Skip to content

Commit af53aab

Browse files
committed
Rock geometry
1 parent 5a93d7d commit af53aab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/geometry/rocks/RockGeometry.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { BufferGeometry, SphereGeometry } from "three";
2+
import { Direction } from "../../constants/Direction.js";
3+
import { randomTransformVertices } from "../../utils/VertexUtils.js";
4+
5+
export class RockGeometry extends BufferGeometry {
6+
constructor(radius = 1, widthSegments = 4, heightSegments = 4) {
7+
super();
8+
9+
const sphere = new SphereGeometry(radius, widthSegments, heightSegments);
10+
this.copy(randomTransformVertices(sphere, Direction.XYZ, 0.5, 1.0));
11+
this.computeVertexNormals();
12+
this.center();
13+
}
14+
}

0 commit comments

Comments
 (0)