Miguelpef commited on
Commit
bd5dee7
·
verified ·
1 Parent(s): 620dc90

Upload viewer.py

Browse files
Files changed (1) hide show
  1. viewer.py +15 -5
viewer.py CHANGED
@@ -32,11 +32,21 @@ def create_3d_scatter(voxels, palette):
32
  x, y, z = np.nonzero(voxels)
33
  color_indices = voxels[x, y, z] - 1 # Subtract 1 since palette indices in .vox start at 1
34
 
35
- # Apply rotation to orient the model correctly
36
- # Negate y coordinate to flip the model upright and rotate z to face forward
37
- y = -y
38
- temp_z = z.copy()
39
- z = -temp_z # Negate z to make the model face forward
 
 
 
 
 
 
 
 
 
 
40
 
41
  # Convert palette indices to RGB colors using direct palette indexing
42
  rgb_colors = [f'rgb({int(palette[c][0])}, {int(palette[c][1])}, {int(palette[c][2])})'
 
32
  x, y, z = np.nonzero(voxels)
33
  color_indices = voxels[x, y, z] - 1 # Subtract 1 since palette indices in .vox start at 1
34
 
35
+ # Apply rotations: first 90 degrees in X, then 180 degrees in Z
36
+ # Convert to radians
37
+ theta_x = np.pi / 2 # 90 degrees
38
+ theta_z = np.pi # 180 degrees
39
+
40
+ # First rotation around X axis
41
+ y_rot = y * np.cos(theta_x) - z * np.sin(theta_x)
42
+ z_rot = y * np.sin(theta_x) + z * np.cos(theta_x)
43
+ y, z = y_rot, z_rot
44
+
45
+ # Then rotation around Z axis
46
+ x_rot = x * np.cos(theta_z) - y * np.sin(theta_z)
47
+ y_rot = x * np.sin(theta_z) + y * np.cos(theta_z)
48
+ x, y = x_rot, y_rot
49
+
50
 
51
  # Convert palette indices to RGB colors using direct palette indexing
52
  rgb_colors = [f'rgb({int(palette[c][0])}, {int(palette[c][1])}, {int(palette[c][2])})'