角色动画

This commit is contained in:
2026-10-02 09:32:11 +08:00
parent 5173b45066
commit d367c8370b
10 changed files with 240 additions and 68 deletions
+4 -4
View File
@@ -156,12 +156,12 @@ func _rebuild_cable() -> void:
prev = p
# 截面参考轴取「切线 × 世界上方向」。切线接近竖直时叉乘会退化成零向量,
# 这时换 RIGHT 兜底,否则 normalize() 会吐 NaN 把整根缆搅烂。
var tan := (_local_sample(minf(t + 0.01, 1.0)) - _local_sample(maxf(t - 0.01, 0.0))).normalized()
var n := tan.cross(Vector3.UP)
var tan_dir := (_local_sample(minf(t + 0.01, 1.0)) - _local_sample(maxf(t - 0.01, 0.0))).normalized()
var n := tan_dir.cross(Vector3.UP)
if n.length_squared() < 0.0001:
n = tan.cross(Vector3.RIGHT)
n = tan_dir.cross(Vector3.RIGHT)
n = n.normalized()
var binormal := n.cross(tan).normalized()
var binormal := n.cross(tan_dir).normalized()
for j in range(RING_SEGMENTS + 1):
var ang := TAU * float(j) / float(RING_SEGMENTS)
var off := n * cos(ang) + binormal * sin(ang)