Gizmos - simple line connecting the portals

This commit is contained in:
Vojtěch Struhár 2025-02-20 21:58:19 +01:00
parent 2da0429cdd
commit eeb35efa18
6 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,42 @@
extends EditorNode3DGizmoPlugin
func _init():
print("[gizmo] _init")
create_material("main", Color(1,0,1), false, true, false)
func _get_gizmo_name() -> String:
return "PortalGizmo"
func _has_gizmo(for_node_3d: Node3D) -> bool:
var result: bool = for_node_3d is Portal
if result: print("[gizmo] _has_gizmo: " + for_node_3d.name)
return result
func _redraw(gizmo):
var node3d = gizmo.get_node_3d() as Portal
print("[gizmo] _redraw: " + node3d.name)
gizmo.clear() # Always clear the gizmo
if node3d not in EditorInterface.get_selection().get_selected_nodes():
return # If not selected, don't draw anything
var lines = PackedVector3Array()
lines.push_back(Vector3(0, 0, 0))
if node3d.exit_portal != null:
lines.push_back(node3d.to_local(node3d.exit_portal.global_position))
else:
lines.push_back(Vector3(5, 5, 5))
#var handles = PackedVector3Array()
#handles.push_back(Vector3(0, 1, 0))
#handles.push_back(Vector3(0, 2, 0))
gizmo.add_lines(lines, get_material("main", gizmo), false)
#gizmo.add_handles(handles, get_material("handles", gizmo), [])

View File

@ -0,0 +1 @@
uid://b8vlwx31bxx4b

View File

@ -0,0 +1,7 @@
[plugin]
name="Portal Gizmos"
description="Plugin providing 3D Gizmos for portals"
author="Vojtech Struhar"
version="0.1"
script="portal_gizmos.gd"

View File

@ -0,0 +1,13 @@
@tool
extends EditorPlugin
const GIZMO_PACKED = preload("gizmo.gd")
var gizmo = GIZMO_PACKED.new()
func _enter_tree() -> void:
print("[portal_gizmos] Enter")
add_node_3d_gizmo_plugin(gizmo)
func _exit_tree() -> void:
print("[portal_gizmos] Exit")
remove_node_3d_gizmo_plugin(gizmo)

View File

@ -0,0 +1 @@
uid://c61kmx68labq0

View File

@ -20,6 +20,10 @@ config/icon="res://icon.svg"
window/size/viewport_width=1920
window/size/viewport_height=1080
[editor_plugins]
enabled=PackedStringArray("res://addons/portal_gizmos/plugin.cfg")
[input]
move_left={