浏览代码

RoundedBoxBufferGeometry: Ensure radius isn't bigger than shortest side.

Mr.doob 4 年之前
父节点
当前提交
4c0e435e8f
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      examples/jsm/geometries/RoundedBoxBufferGeometry.js

+ 3 - 0
examples/jsm/geometries/RoundedBoxBufferGeometry.js

@@ -44,6 +44,9 @@ class RoundedBoxBufferGeometry extends BoxBufferGeometry {
 		// ensure segments is odd so we have a plane connecting the rounded corners
 		segments = segments * 2 + 1;
 
+		// ensure radius isn't bigger than shortest side
+		radius = Math.min( width / 2, height / 2, depth / 2, radius );
+
 		super( 1, 1, 1, segments, segments, segments );
 
 		// if we just have one segment we're the same as a regular box