urholaukkarinen / transform-gizmo

3d transformation gizmo
https://github.com/urholaukkarinen/transform-gizmo
Apache License 2.0
191 stars 49 forks source link

Entity-specific gizmo configuration in bevy integration #56

Open ThomasAlban opened 4 months ago

ThomasAlban commented 4 months ago

Is there any way with the current system to configure certain GizmoTargets to not be editable in certain gizmo modes? For example, I want some entities to not be rotatable and some not scaleable (the gizmo would just do nothing to those entities' rotations/scales if edited in that mode). I'm not exactly sure of the best way this could be implemented (unless it is already possible and I'm missing it!). Perhaps an optional GizmoTargetConfig component which contains properties such as use_rotation/use_scale. If the entity has both GizmoTarget and GizmoTargetConfig, the config options would be applied to that specific entity. This approach could be good, as it would open the door to potentially more entity-specific gizmo config options in the future.

ThomasAlban commented 4 months ago

To clarify with an example: if an entity has use_rotation: false, then the gizmo does not affect the entity's rotation. If it has GizmoTarget as well as another entity with use_rotation: true, and both entities are rotated about the median point with the gizmo, then the entity with use_rotation: false would still move, but its rotation would not be affected.

urholaukkarinen commented 4 months ago

The current system does not support entity-specific configuration, but something like that GizmoTargetConfig could indeed work. In the meantime it could perhaps be implemented outside the gizmo plugin with a system that reverts any changes to scale, rotation or translation, depending on which of them are editable.

ThomasAlban commented 4 months ago

Yeah sounds good. Does the current underlying gizmo implementation support turning off certain axes e.g. for entities which should only be translated in the x and z axes (then the gizmo would only show the relevant arrows)? This would be another feature that would be nice to have in the entity-specific gizmo config if it was implemented!

urholaukkarinen commented 4 months ago

The current main version does not yet support that, but that is implemented in the more-modes branch: https://github.com/urholaukkarinen/transform-gizmo/commit/c7c89923618d525ce7d6dd0794e2e62aaf16d7fa It allows you to mix and match the "sub-modes" however you like.