|
@@ -14,6 +14,8 @@ from OpenGL.GL import *
|
|
|
from OpenGL.GLU import *
|
|
from OpenGL.GLU import *
|
|
|
from OpenGL.GLUT import *
|
|
from OpenGL.GLUT import *
|
|
|
|
|
|
|
|
|
|
+EXCLUDED_DIR = ['.git', '.vscode', '.idea', 'node_modules', '__pycache__']
|
|
|
|
|
+
|
|
|
# 初始化字体
|
|
# 初始化字体
|
|
|
pygame.font.init()
|
|
pygame.font.init()
|
|
|
# 使用默认字体,增大字体大小
|
|
# 使用默认字体,增大字体大小
|
|
@@ -165,7 +167,7 @@ def build_directory_tree(root_path, max_depth=3, max_children_per_node=30):
|
|
|
filtered_entries = []
|
|
filtered_entries = []
|
|
|
for entry in entries:
|
|
for entry in entries:
|
|
|
# 过滤常见的版本控制和IDE目录
|
|
# 过滤常见的版本控制和IDE目录
|
|
|
- if entry in ['.git', '.vscode', '.idea', 'node_modules', '__pycache__']:
|
|
|
|
|
|
|
+ if entry in EXCLUDED_DIR:
|
|
|
continue
|
|
continue
|
|
|
filtered_entries.append(entry)
|
|
filtered_entries.append(entry)
|
|
|
|
|
|
|
@@ -218,19 +220,26 @@ def build_directory_tree(root_path, max_depth=3, max_children_per_node=30):
|
|
|
|
|
|
|
|
# 计算当前节点位置
|
|
# 计算当前节点位置
|
|
|
if node_id == 0: # 根节点
|
|
if node_id == 0: # 根节点
|
|
|
- positions[node_id] = [0.0, max_depth_found * 0.4, 0.0] # 顶部,高度减半
|
|
|
|
|
|
|
+ # positions[node_id] = [0.0, max_depth_found * 0.4, 0.0] # 顶部,高度减半
|
|
|
|
|
+ positions[node_id] = [0.0, max_depth_found * 0.6, 0.0] # 顶部,高度减半
|
|
|
else:
|
|
else:
|
|
|
parent_id = nodes[node_id][2]
|
|
parent_id = nodes[node_id][2]
|
|
|
if parent_id >= 0:
|
|
if parent_id >= 0:
|
|
|
# 子节点围绕父节点在圆上分布
|
|
# 子节点围绕父节点在圆上分布
|
|
|
child_index = children[parent_id].index(node_id)
|
|
child_index = children[parent_id].index(node_id)
|
|
|
|
|
+ # 用于表示某个节点的兄弟节点数量
|
|
|
num_siblings = len(children[parent_id])
|
|
num_siblings = len(children[parent_id])
|
|
|
|
|
|
|
|
# 计算角度(在父节点周围的圆上)
|
|
# 计算角度(在父节点周围的圆上)
|
|
|
|
|
+ # 这行代码确保多个子节点在指定的角度范围内均匀分布,避免它们在3D空间中重叠或拥挤。例如,如果起始角度是0度,结束角度是360度,有4个子节点,那么它们的角度会分别是0度、90度、180度和270度,均匀分布在圆周上
|
|
|
angle = start_angle + (end_angle - start_angle) * (child_index / max(num_siblings, 1))
|
|
angle = start_angle + (end_angle - start_angle) * (child_index / max(num_siblings, 1))
|
|
|
|
|
|
|
|
# 半径随深度减小
|
|
# 半径随深度减小
|
|
|
- radius = 0.75 * (0.75 ** depth) # 深度越大,半径越小,基础半径减半
|
|
|
|
|
|
|
+ # radius = 0.75 * (0.75 ** depth) # 深度越大,半径越小,基础半径减半
|
|
|
|
|
+ if depth == 1:
|
|
|
|
|
+ radius = 2
|
|
|
|
|
+ else:
|
|
|
|
|
+ radius = 0.75 * (0.75 ** depth) # 深度越大,半径越小,基础半径减半
|
|
|
|
|
|
|
|
# 计算位置
|
|
# 计算位置
|
|
|
px, py, pz = positions[parent_id]
|
|
px, py, pz = positions[parent_id]
|