瀏覽代碼

exposes getSplineLength

clementlandrin 2 月之前
父節點
當前提交
1bcd2c6278
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      hrt/prefab/l3d/Spline.hx

+ 9 - 4
hrt/prefab/l3d/Spline.hx

@@ -737,10 +737,7 @@ class Spline extends hrt.prefab.Object3D {
 				toCompute.push({ s: curP, idx: i });
 		}
 
-		// Compute the average length of the spline
-		var length = 0.0;
-		for( i in 0 ... samples.length - 1 )
-			length += samples[i].pos.distance(samples[i+1].pos);
+		var length = getSplineLength();
 
 		var l = 0.0;
 		for( i in 0 ... toCompute.length - 1 ) {
@@ -760,6 +757,14 @@ class Spline extends hrt.prefab.Object3D {
 		p.length = length;
 	}
 
+	public function getSplineLength() {
+		// Compute the average length of the spline
+		var length = 0.0;
+		for( i in 0 ... samples.length - 1 )
+			length += samples[i].pos.distance(samples[i+1].pos);
+		return length;
+	}
+	
 
 	// -- Spline maths -- //
 	inline function getPointBetween( t : Float, p1 : SplinePoint, p2 : SplinePoint ) : h3d.col.Point {