1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Fix origin of 3D shapes exported from 0.x being scaled

Continuation of #927
This commit is contained in:
Emmanouil Papadeas 2023-10-25 00:42:13 +03:00
parent c3a651f01d
commit 16a4ae6899

View file

@ -237,12 +237,16 @@ func convert_0x_to_1x(dict: Dictionary) -> void:
# Convert a String to a Vector3
object_info[object_property] = str_to_var("Vector3" + object_info[object_property])
# Special operations to adjust gizmo
# take note of origin
var origin = object_info["transform"].origin
match object_info["type"]:
0: # BOX
object_info["transform"] = object_info["transform"].scaled(Vector3.ONE * 2)
object_info["transform"].origin = origin
object_info["mesh_size"] /= 2
1: # SPHERE
object_info["transform"] = object_info["transform"].scaled(Vector3.ONE * 2)
object_info["transform"].origin = origin
object_info["mesh_radius"] /= 2
object_info["mesh_height"] /= 2
2: # CAPSULE
@ -251,20 +255,24 @@ func convert_0x_to_1x(dict: Dictionary) -> void:
. scaled(Vector3.ONE * 2)
. rotated_local(Vector3.LEFT, deg_to_rad(-90))
)
object_info["transform"].origin = origin
object_info["mesh_radius"] /= 2
object_info["mesh_height"] = (
object_info["mesh_mid_height"] + object_info["mesh_radius"]
)
3: # CYLINDER
object_info["transform"] = object_info["transform"].scaled(Vector3.ONE * 2)
object_info["transform"].origin = origin
object_info["mesh_height"] /= 2
object_info["mesh_bottom_radius"] /= 2
object_info["mesh_top_radius"] /= 2
4: # PRISM
object_info["transform"] = object_info["transform"].scaled(Vector3.ONE * 2)
object_info["transform"].origin = origin
object_info["mesh_size"] /= 2
6: # PLANE
object_info["transform"] = object_info["transform"].scaled(Vector3.ONE * 2)
object_info["transform"].origin = origin
object_info["mesh_sizev2"] /= 2
7: # TEXT
object_info["mesh_vertical_alignment"] = VERTICAL_ALIGNMENT_BOTTOM