feat: schreibgeschuetzte 3D-Vorschau mit Glide-Clip
- Presentation3D mit Rink, Folge-/Uebersichtskamera und Skater - 2D/3D-Umschalter, Esc-Rueckweg, geteilte Playback-Steuerung - Skater laedt GLB ueber Manifest-ID, Platzhalter als Fallback - Glide-Clip (2 s) als v003, Manifest und FTP-Spiegel aktualisiert - 44 Praesentations-Assertions (1173 gesamt) - Doku, Architektur (D14) und Roadmap aktualisiert
This commit is contained in:
parent
697274ce1b
commit
723e1bc84a
20 changed files with 1282 additions and 34 deletions
|
|
@ -4,15 +4,15 @@
|
|||
"assets": [
|
||||
{
|
||||
"id": "character.skater.figure",
|
||||
"version": 2,
|
||||
"version": 3,
|
||||
"kind": "character",
|
||||
"format": "glb",
|
||||
"source": "library/characters/skater_figure_rigged_deform_v002.glb",
|
||||
"target": "assets/external/characters/skater_figure_rigged_deform_v002.glb",
|
||||
"remote": "characters/skater_figure_rigged_deform_v002.glb",
|
||||
"sha256": "1c1f06461b58b02d9b8332a756fdc88f533ff2d25f65a59d21ca0209b65128cb",
|
||||
"bytes": 8345424,
|
||||
"source_scene": "source/characters/skater/skater_rig_v002.blend",
|
||||
"source": "library/characters/skater_figure_glide_v003.glb",
|
||||
"target": "assets/external/characters/skater_figure_glide_v003.glb",
|
||||
"remote": "characters/skater_figure_glide_v003.glb",
|
||||
"sha256": "f45858cd256628395409829c42f1669132ca330523f6a1be7a9f8d1ffbe9a45b",
|
||||
"bytes": 8420244,
|
||||
"source_scene": "source/characters/skater/skater_rig_v003.blend",
|
||||
"created": "2026-10-31",
|
||||
"license": "Eigenes GenAI-Asset, Rig mit AutoRigPro erstellt.",
|
||||
"placement": {
|
||||
|
|
@ -28,8 +28,10 @@
|
|||
"deform_bones": 30,
|
||||
"bind": "PSEUDO_VOXELS"
|
||||
},
|
||||
"animations": [],
|
||||
"notes": "T-Pose, statisches Rig ohne Clips. Testclip und Vergleichsversionen liegen in derselben Workbench-Library."
|
||||
"animations": [
|
||||
"Glide"
|
||||
],
|
||||
"notes": "T-Pose als Rest, Glide als 2-s-Loop. Weitere Clips folgen über Rotoscoping."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
26
rinkplanner/scenes/presentation3d/presentation_3d.tscn
Normal file
26
rinkplanner/scenes/presentation3d/presentation_3d.tscn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=4 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://src/presentation3d/presentation_3d.gd" id="1_presentation"]
|
||||
[ext_resource type="Script" path="res://src/presentation3d/rink_3d.gd" id="2_rink"]
|
||||
[ext_resource type="Script" path="res://src/presentation3d/skater_3d.gd" id="3_skater"]
|
||||
|
||||
[node name="Presentation3D" type="Node3D"]
|
||||
script = ExtResource("1_presentation")
|
||||
|
||||
[node name="Sun" type="DirectionalLight3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
rotation_degrees = Vector3(-50, -35, 0)
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
fov = 50.0
|
||||
near = 0.1
|
||||
far = 250.0
|
||||
|
||||
[node name="Rink" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_rink")
|
||||
|
||||
[node name="Skater" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("3_skater")
|
||||
|
|
@ -175,6 +175,27 @@ layout_mode = 2
|
|||
theme_override_font_sizes/font_size = 16
|
||||
text = "Einpassen"
|
||||
|
||||
[node name="View3DSeparator" type="VSeparator" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="View3DButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(64, 56)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "3D"
|
||||
tooltip_text = "3D-Vorschau öffnen"
|
||||
|
||||
[node name="CameraModeButton" type="Button" parent="Layout/TopBar/Tools"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
custom_minimum_size = Vector2(168, 56)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 15
|
||||
text = "Kamera: Folge"
|
||||
tooltip_text = "Zwischen Folge- und Übersichtskamera wechseln"
|
||||
|
||||
[node name="Content" type="HBoxContainer" parent="Layout"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -277,6 +298,7 @@ theme_override_font_sizes/font_size = 15
|
|||
text = "Abschnitt löschen"
|
||||
|
||||
[node name="TimingBar" type="PanelContainer" parent="Layout"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 72)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_playback")
|
||||
|
|
|
|||
179
rinkplanner/src/presentation3d/presentation_3d.gd
Normal file
179
rinkplanner/src/presentation3d/presentation_3d.gd
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
class_name Presentation3D
|
||||
extends Node3D
|
||||
|
||||
## Schreibgeschützte 3D-Vorschau. Sie liest dieselben Metermaße wie das
|
||||
## 2D-Modell: +X bleibt +X, +Y wird zu -Z. Die Kamera folgt dem Skater oder
|
||||
## zeigt das ganze Rink.
|
||||
|
||||
enum CameraMode {
|
||||
FOLLOW,
|
||||
OVERVIEW,
|
||||
}
|
||||
|
||||
const FOLLOW_DISTANCE_M := 8.0
|
||||
const FOLLOW_HEIGHT_M := 5.5
|
||||
const OVERVIEW_POSITION := Vector3(0.0, 36.0, 40.0)
|
||||
const CAMERA_SMOOTHING := 4.0
|
||||
|
||||
@onready var camera: Camera3D = %Camera3D
|
||||
@onready var sun: DirectionalLight3D = %Sun
|
||||
@onready var rink: Rink3D = %Rink
|
||||
@onready var skater: Skater3D = %Skater
|
||||
|
||||
var _active: bool = false
|
||||
var _camera_mode: CameraMode = CameraMode.FOLLOW
|
||||
var _camera_initialized: bool = false
|
||||
var _look_target := Vector3(0.0, 1.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_setup_environment()
|
||||
camera.current = false
|
||||
visible = false
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_update_camera(delta)
|
||||
|
||||
|
||||
func setup(routine: Routine) -> void:
|
||||
var dimensions: RinkDimensions = RinkDimensions.new()
|
||||
if routine != null and routine.rink != null:
|
||||
dimensions = routine.rink
|
||||
rink.build(dimensions)
|
||||
skater.setup()
|
||||
|
||||
_camera_mode = CameraMode.FOLLOW
|
||||
_camera_initialized = false
|
||||
if routine == null or routine.get_length_m() <= 0.0:
|
||||
skater.clear_pose()
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func set_active(active: bool) -> void:
|
||||
_active = active
|
||||
visible = active
|
||||
camera.current = active
|
||||
set_process(active)
|
||||
if active:
|
||||
_camera_initialized = false
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func is_active() -> bool:
|
||||
return _active
|
||||
|
||||
|
||||
func update_pose(
|
||||
position_m: Vector2,
|
||||
heading: Vector2,
|
||||
_segment: PathSegment = null
|
||||
) -> void:
|
||||
var previous := skater.position
|
||||
skater.set_pose(position_m, heading)
|
||||
if not _active:
|
||||
return
|
||||
if (
|
||||
not _camera_initialized
|
||||
or previous.distance_to(skater.position) > 4.0
|
||||
):
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func clear_pose() -> void:
|
||||
skater.clear_pose()
|
||||
_camera_initialized = false
|
||||
if _active:
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func set_camera_mode(mode: CameraMode) -> void:
|
||||
if _camera_mode == mode:
|
||||
return
|
||||
_camera_mode = mode
|
||||
_camera_initialized = false
|
||||
if _active:
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func toggle_camera_mode() -> void:
|
||||
set_camera_mode(
|
||||
CameraMode.OVERVIEW
|
||||
if _camera_mode == CameraMode.FOLLOW
|
||||
else CameraMode.FOLLOW
|
||||
)
|
||||
|
||||
|
||||
func is_overview() -> bool:
|
||||
return _camera_mode == CameraMode.OVERVIEW
|
||||
|
||||
|
||||
func get_camera_mode_name() -> String:
|
||||
return "Übersicht" if is_overview() else "Folge"
|
||||
|
||||
|
||||
func get_skater_position() -> Vector3:
|
||||
return skater.position
|
||||
|
||||
|
||||
func get_skater_yaw() -> float:
|
||||
return skater.rotation.y
|
||||
|
||||
|
||||
func update_camera_now() -> void:
|
||||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func _update_camera(delta: float, snap: bool = false) -> void:
|
||||
var skater_position := skater.position
|
||||
var forward := Vector3(
|
||||
sin(skater.rotation.y),
|
||||
0.0,
|
||||
cos(skater.rotation.y)
|
||||
)
|
||||
|
||||
var desired := Vector3.ZERO
|
||||
var target := Vector3.ZERO
|
||||
if _camera_mode == CameraMode.OVERVIEW:
|
||||
desired = OVERVIEW_POSITION
|
||||
target = Vector3(0.0, 0.0, 0.0)
|
||||
else:
|
||||
desired = (
|
||||
skater_position
|
||||
- forward * FOLLOW_DISTANCE_M
|
||||
+ Vector3(0.0, FOLLOW_HEIGHT_M, 0.0)
|
||||
)
|
||||
target = skater_position + forward * 2.0 + Vector3(0.0, 1.1, 0.0)
|
||||
|
||||
if snap or not _camera_initialized:
|
||||
camera.position = desired
|
||||
_look_target = target
|
||||
camera.look_at(_look_target, Vector3.UP)
|
||||
_camera_initialized = true
|
||||
return
|
||||
|
||||
var weight := 1.0 - exp(-delta * CAMERA_SMOOTHING)
|
||||
camera.position = camera.position.lerp(desired, weight)
|
||||
_look_target = _look_target.lerp(target, weight)
|
||||
if camera.position.distance_squared_to(_look_target) > 0.000001:
|
||||
camera.look_at(_look_target, Vector3.UP)
|
||||
|
||||
|
||||
func _setup_environment() -> void:
|
||||
var environment := Environment.new()
|
||||
environment.background_mode = Environment.BG_COLOR
|
||||
environment.background_color = Color("aebdcd")
|
||||
environment.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
|
||||
environment.ambient_light_color = Color.WHITE
|
||||
environment.ambient_light_energy = 0.6
|
||||
|
||||
var world_environment := WorldEnvironment.new()
|
||||
world_environment.name = "WorldEnvironment"
|
||||
world_environment.environment = environment
|
||||
add_child(world_environment)
|
||||
|
||||
sun.rotation_degrees = Vector3(-50.0, -35.0, 0.0)
|
||||
sun.light_energy = 1.15
|
||||
sun.shadow_enabled = true
|
||||
sun.directional_shadow_max_distance = 80.0
|
||||
1
rinkplanner/src/presentation3d/presentation_3d.gd.uid
Normal file
1
rinkplanner/src/presentation3d/presentation_3d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b8ih1synfjyyr
|
||||
218
rinkplanner/src/presentation3d/rink_3d.gd
Normal file
218
rinkplanner/src/presentation3d/rink_3d.gd
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
class_name Rink3D
|
||||
extends Node3D
|
||||
|
||||
## Baut die 3D-Eisfläche aus den Rink-Maßen. Reine Darstellung; das Modell
|
||||
## bleibt in Metern und +Y zeigt im 2D-Modell nach oben, in 3D nach -Z.
|
||||
|
||||
const BOARDS_HEIGHT_M := 1.1
|
||||
const BOARDS_THICKNESS_M := 0.08
|
||||
const CORNER_SEGMENTS := 10
|
||||
const ICE_COLOR := Color("e8f3ff")
|
||||
const BOARD_COLOR := Color("f4f7fa")
|
||||
const RAIL_COLOR := Color("c0392b")
|
||||
const MARKING_COLOR := Color("7fa8c9")
|
||||
const GROUND_COLOR := Color("202b38")
|
||||
|
||||
|
||||
func build(dimensions: RinkDimensions) -> void:
|
||||
for child: Node in get_children():
|
||||
child.free()
|
||||
|
||||
if dimensions == null or not dimensions.is_valid():
|
||||
dimensions = RinkDimensions.new()
|
||||
|
||||
var outline := _build_outline(dimensions)
|
||||
_build_ice(outline, dimensions)
|
||||
_build_boards(outline)
|
||||
_build_markings(dimensions)
|
||||
_build_ground(dimensions)
|
||||
|
||||
|
||||
func _build_outline(dimensions: RinkDimensions) -> PackedVector2Array:
|
||||
var half_length := dimensions.get_half_length()
|
||||
var half_width := dimensions.get_half_width()
|
||||
var radius := minf(
|
||||
dimensions.corner_radius_m,
|
||||
minf(half_length, half_width)
|
||||
)
|
||||
var points := PackedVector2Array()
|
||||
|
||||
_append_point(
|
||||
points,
|
||||
Vector2(-half_length + radius, -half_width)
|
||||
)
|
||||
|
||||
var corners := [
|
||||
[Vector2(half_length - radius, -half_width + radius), -PI * 0.5, 0.0],
|
||||
[Vector2(half_length - radius, half_width - radius), 0.0, PI * 0.5],
|
||||
[Vector2(-half_length + radius, half_width - radius), PI * 0.5, PI],
|
||||
[Vector2(-half_length + radius, -half_width + radius), PI, PI * 1.5],
|
||||
]
|
||||
|
||||
for corner: Array in corners:
|
||||
var center: Vector2 = corner[0]
|
||||
var start_angle: float = corner[1]
|
||||
var end_angle: float = corner[2]
|
||||
for index: int in range(CORNER_SEGMENTS + 1):
|
||||
var angle := lerpf(
|
||||
start_angle,
|
||||
end_angle,
|
||||
float(index) / float(CORNER_SEGMENTS)
|
||||
)
|
||||
_append_point(
|
||||
points,
|
||||
center + Vector2(cos(angle), sin(angle)) * radius
|
||||
)
|
||||
|
||||
return points
|
||||
|
||||
|
||||
func _append_point(points: PackedVector2Array, point: Vector2) -> void:
|
||||
if (
|
||||
points.is_empty()
|
||||
or points[points.size() - 1].distance_squared_to(point) > 0.000001
|
||||
):
|
||||
points.append(point)
|
||||
|
||||
|
||||
func _build_ice(
|
||||
outline: PackedVector2Array,
|
||||
dimensions: RinkDimensions
|
||||
) -> void:
|
||||
var indices := Geometry2D.triangulate_polygon(outline)
|
||||
if indices.is_empty():
|
||||
push_warning("Rink3D: Eisfläche konnte nicht trianguliert werden.")
|
||||
return
|
||||
|
||||
var surface := SurfaceTool.new()
|
||||
surface.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
for point: Vector2 in outline:
|
||||
surface.set_normal(Vector3.UP)
|
||||
surface.set_uv(
|
||||
Vector2(
|
||||
point.x / dimensions.length_m + 0.5,
|
||||
0.5 - point.y / dimensions.width_m
|
||||
)
|
||||
)
|
||||
surface.add_vertex(Vector3(point.x, 0.0, -point.y))
|
||||
for index: int in range(0, indices.size(), 3):
|
||||
surface.add_index(indices[index])
|
||||
surface.add_index(indices[index + 2])
|
||||
surface.add_index(indices[index + 1])
|
||||
surface.generate_normals()
|
||||
|
||||
var ice := MeshInstance3D.new()
|
||||
ice.name = "Ice"
|
||||
ice.mesh = surface.commit()
|
||||
ice.material_override = _material(ICE_COLOR, 0.25)
|
||||
ice.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(ice)
|
||||
|
||||
|
||||
func _build_boards(outline: PackedVector2Array) -> void:
|
||||
var boards_material := _material(BOARD_COLOR, 0.6)
|
||||
var rail_material := _material(RAIL_COLOR, 0.5)
|
||||
|
||||
for index: int in range(outline.size()):
|
||||
var from := outline[index]
|
||||
var to := outline[(index + 1) % outline.size()]
|
||||
var edge := to - from
|
||||
var length := edge.length()
|
||||
if length < 0.0001:
|
||||
continue
|
||||
|
||||
var middle := (from + to) * 0.5
|
||||
var yaw := atan2(edge.y, edge.x)
|
||||
|
||||
var wall_mesh := BoxMesh.new()
|
||||
wall_mesh.size = Vector3(
|
||||
length + BOARDS_THICKNESS_M,
|
||||
BOARDS_HEIGHT_M,
|
||||
BOARDS_THICKNESS_M
|
||||
)
|
||||
var wall := MeshInstance3D.new()
|
||||
wall.name = "Board%03d" % index
|
||||
wall.mesh = wall_mesh
|
||||
wall.material_override = boards_material
|
||||
wall.position = Vector3(
|
||||
middle.x,
|
||||
BOARDS_HEIGHT_M * 0.5,
|
||||
-middle.y
|
||||
)
|
||||
wall.rotation.y = yaw
|
||||
wall.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(wall)
|
||||
|
||||
var rail_mesh := BoxMesh.new()
|
||||
rail_mesh.size = Vector3(
|
||||
length + BOARDS_THICKNESS_M + 0.02,
|
||||
0.06,
|
||||
BOARDS_THICKNESS_M + 0.04
|
||||
)
|
||||
var rail := MeshInstance3D.new()
|
||||
rail.name = "Rail%03d" % index
|
||||
rail.mesh = rail_mesh
|
||||
rail.material_override = rail_material
|
||||
rail.position = Vector3(
|
||||
middle.x,
|
||||
BOARDS_HEIGHT_M + 0.03,
|
||||
-middle.y
|
||||
)
|
||||
rail.rotation.y = yaw
|
||||
rail.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(rail)
|
||||
|
||||
|
||||
func _build_markings(dimensions: RinkDimensions) -> void:
|
||||
var material := _material(MARKING_COLOR, 0.8)
|
||||
material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
|
||||
var center_line_mesh := BoxMesh.new()
|
||||
center_line_mesh.size = Vector3(
|
||||
0.06,
|
||||
0.004,
|
||||
dimensions.width_m - 2.0
|
||||
)
|
||||
var center_line := MeshInstance3D.new()
|
||||
center_line.name = "CenterLine"
|
||||
center_line.mesh = center_line_mesh
|
||||
center_line.material_override = material
|
||||
center_line.position = Vector3(0.0, 0.004, 0.0)
|
||||
center_line.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(center_line)
|
||||
|
||||
var circle_mesh := TorusMesh.new()
|
||||
circle_mesh.inner_radius = 4.4
|
||||
circle_mesh.outer_radius = 4.52
|
||||
circle_mesh.rings = 64
|
||||
circle_mesh.ring_segments = 8
|
||||
var circle := MeshInstance3D.new()
|
||||
circle.name = "CenterCircle"
|
||||
circle.mesh = circle_mesh
|
||||
circle.material_override = material
|
||||
circle.position = Vector3(0.0, 0.004, 0.0)
|
||||
circle.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(circle)
|
||||
|
||||
|
||||
func _build_ground(dimensions: RinkDimensions) -> void:
|
||||
var ground_mesh := PlaneMesh.new()
|
||||
ground_mesh.size = Vector2(
|
||||
dimensions.length_m + 30.0,
|
||||
dimensions.width_m + 30.0
|
||||
)
|
||||
var ground := MeshInstance3D.new()
|
||||
ground.name = "Ground"
|
||||
ground.mesh = ground_mesh
|
||||
ground.material_override = _material(GROUND_COLOR, 0.9)
|
||||
ground.position = Vector3(0.0, -0.05, 0.0)
|
||||
ground.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
add_child(ground)
|
||||
|
||||
|
||||
func _material(color: Color, roughness: float) -> StandardMaterial3D:
|
||||
var material := StandardMaterial3D.new()
|
||||
material.albedo_color = color
|
||||
material.roughness = roughness
|
||||
material.metallic = 0.0
|
||||
return material
|
||||
1
rinkplanner/src/presentation3d/rink_3d.gd.uid
Normal file
1
rinkplanner/src/presentation3d/rink_3d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://6ctikgsp3nup
|
||||
133
rinkplanner/src/presentation3d/skater_3d.gd
Normal file
133
rinkplanner/src/presentation3d/skater_3d.gd
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
class_name Skater3D
|
||||
extends Node3D
|
||||
|
||||
## Lädt die Skater-GLB aus dem Asset-Manifest. Fehlt die Datei (z. B. in CI
|
||||
## oder auf einem frischen Checkout ohne Sync), wird ein Platzhalter gebaut.
|
||||
|
||||
const MANIFEST_PATH := "res://assets/asset_manifest.json"
|
||||
const ASSET_ID := "character.skater.figure"
|
||||
const FALLBACK_MODEL_PATH := "res://assets/external/characters/skater_figure_glide_v003.glb"
|
||||
const IDLE_ANIMATION := "Glide"
|
||||
|
||||
var _model: Node3D
|
||||
var _placeholder := false
|
||||
var _setup_done := false
|
||||
|
||||
|
||||
func setup() -> void:
|
||||
if _setup_done:
|
||||
return
|
||||
_setup_done = true
|
||||
|
||||
var model_path := resolve_model_path()
|
||||
if ResourceLoader.exists(model_path):
|
||||
var packed := load(model_path) as PackedScene
|
||||
if packed != null:
|
||||
_model = packed.instantiate() as Node3D
|
||||
if _model == null:
|
||||
_placeholder = true
|
||||
_model = _build_placeholder()
|
||||
add_child(_model)
|
||||
_play_idle_animation()
|
||||
|
||||
|
||||
func _play_idle_animation() -> void:
|
||||
if _model == null or _placeholder:
|
||||
return
|
||||
|
||||
var players := _model.find_children("*", "AnimationPlayer", true, false)
|
||||
if players.is_empty():
|
||||
return
|
||||
|
||||
var player := players[0] as AnimationPlayer
|
||||
if not player.has_animation(IDLE_ANIMATION):
|
||||
return
|
||||
|
||||
var animation := player.get_animation(IDLE_ANIMATION)
|
||||
animation.loop_mode = Animation.LOOP_LINEAR
|
||||
player.play(IDLE_ANIMATION)
|
||||
|
||||
|
||||
func set_pose(position_m: Vector2, heading: Vector2) -> void:
|
||||
position = Vector3(position_m.x, 0.0, -position_m.y)
|
||||
if heading.length_squared() > 0.000001:
|
||||
rotation.y = atan2(heading.x, -heading.y)
|
||||
|
||||
|
||||
func clear_pose() -> void:
|
||||
set_pose(Vector2.ZERO, Vector2.RIGHT)
|
||||
|
||||
|
||||
func has_model() -> bool:
|
||||
return _model != null and not _placeholder
|
||||
|
||||
|
||||
func is_placeholder() -> bool:
|
||||
return _placeholder
|
||||
|
||||
|
||||
func resolve_model_path() -> String:
|
||||
if not FileAccess.file_exists(MANIFEST_PATH):
|
||||
return FALLBACK_MODEL_PATH
|
||||
|
||||
var file := FileAccess.open(MANIFEST_PATH, FileAccess.READ)
|
||||
if file == null:
|
||||
return FALLBACK_MODEL_PATH
|
||||
var parsed: Variant = JSON.parse_string(file.get_as_text())
|
||||
if not parsed is Dictionary:
|
||||
return FALLBACK_MODEL_PATH
|
||||
|
||||
var assets: Variant = (parsed as Dictionary).get("assets", [])
|
||||
if not assets is Array:
|
||||
return FALLBACK_MODEL_PATH
|
||||
|
||||
for entry: Variant in assets:
|
||||
if not entry is Dictionary:
|
||||
continue
|
||||
var asset: Dictionary = entry
|
||||
if str(asset.get("id", "")) != ASSET_ID:
|
||||
continue
|
||||
var target := str(asset.get("target", ""))
|
||||
if not target.is_empty():
|
||||
return "res://" + target
|
||||
return FALLBACK_MODEL_PATH
|
||||
|
||||
|
||||
func _build_placeholder() -> Node3D:
|
||||
var root := Node3D.new()
|
||||
root.name = "PlaceholderSkater"
|
||||
|
||||
var body := MeshInstance3D.new()
|
||||
var capsule := CapsuleMesh.new()
|
||||
capsule.radius = 0.22
|
||||
capsule.height = 1.45
|
||||
body.mesh = capsule
|
||||
body.position = Vector3(0.0, 0.79, 0.0)
|
||||
body.material_override = _material(Color("2f6fbb"), 0.5)
|
||||
root.add_child(body)
|
||||
|
||||
var head := MeshInstance3D.new()
|
||||
var sphere := SphereMesh.new()
|
||||
sphere.radius = 0.15
|
||||
sphere.height = 0.3
|
||||
head.mesh = sphere
|
||||
head.position = Vector3(0.0, 1.64, 0.0)
|
||||
head.material_override = _material(Color("e8c4a8"), 0.6)
|
||||
root.add_child(head)
|
||||
|
||||
var direction_marker := MeshInstance3D.new()
|
||||
var box := BoxMesh.new()
|
||||
box.size = Vector3(0.12, 0.12, 0.35)
|
||||
direction_marker.mesh = box
|
||||
direction_marker.position = Vector3(0.0, 1.2, 0.3)
|
||||
direction_marker.material_override = _material(Color("f2c94c"), 0.4)
|
||||
root.add_child(direction_marker)
|
||||
|
||||
return root
|
||||
|
||||
|
||||
func _material(color: Color, roughness: float) -> StandardMaterial3D:
|
||||
var material := StandardMaterial3D.new()
|
||||
material.albedo_color = color
|
||||
material.roughness = roughness
|
||||
return material
|
||||
1
rinkplanner/src/presentation3d/skater_3d.gd.uid
Normal file
1
rinkplanner/src/presentation3d/skater_3d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cvkt2isa77qq0
|
||||
|
|
@ -49,6 +49,7 @@ const PROFILE_SPEEDS := [3.0, 3.8, 4.3, 5.0, 6.0]
|
|||
const ROUTINES_DIR := "user://routines"
|
||||
const EXPORTS_DIR := "user://exports"
|
||||
const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn")
|
||||
const PRESENTATION_3D_SCENE_PATH := "res://scenes/presentation3d/presentation_3d.tscn"
|
||||
const ELEMENT_CATALOG_SCRIPT := preload("res://src/core/rules/element_catalog.gd")
|
||||
const ELEMENT_LEVEL_RULES_SCRIPT := preload("res://src/core/rules/element_level_rules.gd")
|
||||
const ROUTINE_VALIDATOR_SCRIPT := preload("res://src/core/rules/routine_validator.gd")
|
||||
|
|
@ -83,6 +84,10 @@ const COMPACT_LAYOUT_WIDTH := 1280.0
|
|||
@onready var undo_button: Button = %UndoButton
|
||||
@onready var redo_button: Button = %RedoButton
|
||||
@onready var fit_button: Button = %FitButton
|
||||
@onready var view_3d_button: Button = %View3DButton
|
||||
@onready var view_3d_separator: VSeparator = %View3DSeparator
|
||||
@onready var camera_mode_button: Button = %CameraModeButton
|
||||
@onready var timing_bar: PanelContainer = %TimingBar
|
||||
@onready var status_label: Label = %StatusLabel
|
||||
@onready var delete_segment_button: Button = %DeleteSegmentButton
|
||||
@onready var section_list: VBoxContainer = %SectionList
|
||||
|
|
@ -207,6 +212,8 @@ var _updating_timeline: bool = false
|
|||
var _sync_thread: Thread
|
||||
var _sync_job: RoutineSync
|
||||
var _sync_running: bool = false
|
||||
var _presentation_3d: Presentation3D
|
||||
var _view_3d_active: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -300,6 +307,9 @@ func _ready() -> void:
|
|||
apply_score_assumptions_button.pressed.connect(_apply_score_assumptions)
|
||||
help_button.pressed.connect(open_help_dialog)
|
||||
element_type_option.item_selected.connect(_on_element_type_selected)
|
||||
view_3d_button.pressed.connect(_toggle_3d_view)
|
||||
camera_mode_button.pressed.connect(_toggle_camera_mode)
|
||||
camera_mode_button.visible = false
|
||||
|
||||
resized.connect(_apply_responsive_layout)
|
||||
_apply_display_scale()
|
||||
|
|
@ -2701,6 +2711,8 @@ func reset_playback() -> void:
|
|||
_playback_segment_id = ""
|
||||
_update_play_button()
|
||||
rink_canvas.clear_playback_state()
|
||||
if _view_3d_active and _presentation_3d != null:
|
||||
_presentation_3d.clear_pose()
|
||||
_update_playback_ui()
|
||||
|
||||
|
||||
|
|
@ -2810,6 +2822,8 @@ func _refresh_playback_timeline() -> void:
|
|||
_playback_section_id = ""
|
||||
_playback_segment_id = ""
|
||||
rink_canvas.clear_playback_state()
|
||||
if _view_3d_active and _presentation_3d != null:
|
||||
_presentation_3d.clear_pose()
|
||||
else:
|
||||
_playback_time = clampf(_playback_time, 0.0, total)
|
||||
if _playing and _playback_time >= total:
|
||||
|
|
@ -2828,6 +2842,8 @@ func _update_playback_state(
|
|||
) -> void:
|
||||
if _playback_entries.is_empty() or _routine == null:
|
||||
rink_canvas.clear_playback_state()
|
||||
if _view_3d_active and _presentation_3d != null:
|
||||
_presentation_3d.clear_pose()
|
||||
return
|
||||
|
||||
var entry: Dictionary = _playback_entries[_playback_entries.size() - 1]
|
||||
|
|
@ -2899,6 +2915,12 @@ func _update_playback_state(
|
|||
segment.edge,
|
||||
segment.direction
|
||||
)
|
||||
if _view_3d_active and _presentation_3d != null:
|
||||
_presentation_3d.update_pose(
|
||||
position,
|
||||
_playback_heading,
|
||||
segment
|
||||
)
|
||||
_update_playback_ui()
|
||||
|
||||
|
||||
|
|
@ -2954,6 +2976,141 @@ func _update_play_button() -> void:
|
|||
play_button.tooltip_text = "Pause" if _playing else "Abspielen"
|
||||
|
||||
|
||||
## --- 3D-Vorschau -----------------------------------------------------------
|
||||
|
||||
|
||||
func is_3d_view_active() -> bool:
|
||||
return _view_3d_active
|
||||
|
||||
|
||||
func get_presentation_3d() -> Presentation3D:
|
||||
return _presentation_3d
|
||||
|
||||
|
||||
func open_3d_view() -> void:
|
||||
if _view_3d_active:
|
||||
return
|
||||
if _presentation_3d == null:
|
||||
_setup_presentation_3d()
|
||||
if _presentation_3d == null:
|
||||
return
|
||||
|
||||
_view_3d_active = true
|
||||
_presentation_3d.setup(_routine)
|
||||
|
||||
if _playback_entries.is_empty():
|
||||
_presentation_3d.clear_pose()
|
||||
else:
|
||||
_update_playback_state(0.0, true)
|
||||
|
||||
_presentation_3d.set_active(true)
|
||||
_set_2d_controls_visible(false)
|
||||
|
||||
view_3d_button.text = "2D"
|
||||
view_3d_button.tooltip_text = "Zurück zur 2D-Bearbeitung"
|
||||
camera_mode_button.visible = true
|
||||
_update_camera_mode_button()
|
||||
rink_canvas.cancel_interaction()
|
||||
_update_status()
|
||||
|
||||
|
||||
func close_3d_view() -> void:
|
||||
if not _view_3d_active:
|
||||
return
|
||||
|
||||
_view_3d_active = false
|
||||
if _presentation_3d != null:
|
||||
_presentation_3d.set_active(false)
|
||||
_set_2d_controls_visible(true)
|
||||
|
||||
view_3d_button.text = "3D"
|
||||
view_3d_button.tooltip_text = "3D-Vorschau öffnen"
|
||||
camera_mode_button.visible = false
|
||||
_apply_responsive_layout()
|
||||
_update_status()
|
||||
rink_canvas.queue_redraw()
|
||||
|
||||
|
||||
func _toggle_3d_view() -> void:
|
||||
if _view_3d_active:
|
||||
close_3d_view()
|
||||
else:
|
||||
open_3d_view()
|
||||
|
||||
|
||||
func _toggle_camera_mode() -> void:
|
||||
if _presentation_3d == null:
|
||||
return
|
||||
_presentation_3d.toggle_camera_mode()
|
||||
_update_camera_mode_button()
|
||||
_update_status()
|
||||
|
||||
|
||||
func _update_camera_mode_button() -> void:
|
||||
if _presentation_3d == null:
|
||||
return
|
||||
|
||||
camera_mode_button.text = (
|
||||
"Kamera: %s" % _presentation_3d.get_camera_mode_name()
|
||||
)
|
||||
camera_mode_button.tooltip_text = (
|
||||
"Zur %s-Kamera wechseln"
|
||||
% ("Folge" if _presentation_3d.is_overview() else "Übersicht")
|
||||
)
|
||||
|
||||
|
||||
func _setup_presentation_3d() -> void:
|
||||
var packed := load(PRESENTATION_3D_SCENE_PATH) as PackedScene
|
||||
if packed == null:
|
||||
push_warning("3D-Vorschau konnte nicht geladen werden.")
|
||||
return
|
||||
|
||||
_presentation_3d = packed.instantiate() as Presentation3D
|
||||
if _presentation_3d == null:
|
||||
push_warning("3D-Vorschau konnte nicht instanziiert werden.")
|
||||
return
|
||||
|
||||
add_child(_presentation_3d)
|
||||
move_child(_presentation_3d, 0)
|
||||
_presentation_3d.set_active(false)
|
||||
|
||||
|
||||
func _set_2d_controls_visible(visible: bool) -> void:
|
||||
rink_canvas.visible = visible
|
||||
sections_panel.visible = visible
|
||||
timing_bar.visible = visible
|
||||
delete_segment_button.visible = visible
|
||||
|
||||
var controls: Array[Control] = [
|
||||
tool_label,
|
||||
tool_option,
|
||||
forward_button,
|
||||
backward_button,
|
||||
inside_button,
|
||||
outside_button,
|
||||
undo_button,
|
||||
redo_button,
|
||||
fit_button,
|
||||
]
|
||||
for control: Control in controls:
|
||||
control.visible = visible
|
||||
|
||||
var tools := $Layout/TopBar/Tools
|
||||
for node_name: String in ["TitleSeparator", "ToolSeparator", "EdgeSeparator"]:
|
||||
var separator := tools.get_node_or_null(node_name)
|
||||
if separator != null:
|
||||
(separator as Control).visible = visible
|
||||
|
||||
if visible:
|
||||
_apply_responsive_layout()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if _view_3d_active and event.is_action_pressed("ui_cancel"):
|
||||
close_3d_view()
|
||||
accept_event()
|
||||
|
||||
|
||||
func _format_seconds(seconds: float) -> String:
|
||||
return ("%.1f" % seconds).replace(".", ",")
|
||||
|
||||
|
|
@ -3244,6 +3401,8 @@ func _install_routine(
|
|||
active_section_id: String,
|
||||
refit: bool = true
|
||||
) -> void:
|
||||
if _view_3d_active:
|
||||
close_3d_view()
|
||||
_playing = false
|
||||
_playback_time = 0.0
|
||||
_playback_section_id = ""
|
||||
|
|
@ -3483,14 +3642,18 @@ func _apply_responsive_layout() -> void:
|
|||
|
||||
var compact := size.x < COMPACT_LAYOUT_WIDTH
|
||||
title_label.visible = not compact
|
||||
tool_label.visible = not compact
|
||||
tool_label.visible = not compact and not _view_3d_active
|
||||
timing_title.visible = not compact
|
||||
sections_panel.custom_minimum_size.x = 260.0 if compact else 300.0
|
||||
|
||||
undo_button.text = "Undo" if compact else "Rückgängig"
|
||||
redo_button.text = "Redo" if compact else "Wiederholen"
|
||||
undo_button.custom_minimum_size.x = 76.0 if compact else 100.0
|
||||
redo_button.custom_minimum_size.x = 76.0 if compact else 110.0
|
||||
undo_button.custom_minimum_size.x = 72.0 if compact else 100.0
|
||||
redo_button.custom_minimum_size.x = 72.0 if compact else 110.0
|
||||
fit_button.text = "Fit" if compact else "Einpassen"
|
||||
fit_button.custom_minimum_size.x = 56.0 if compact else 96.0
|
||||
view_3d_button.custom_minimum_size.x = 56.0 if compact else 64.0
|
||||
view_3d_separator.visible = not compact or _view_3d_active
|
||||
tool_option.custom_minimum_size.x = 150.0 if compact else 170.0
|
||||
calibrate_button.text = "Kalib." if compact else "Kalibrieren"
|
||||
calibrate_button.custom_minimum_size.x = 80.0 if compact else 100.0
|
||||
|
|
@ -3951,6 +4114,26 @@ func _update_status() -> void:
|
|||
|
||||
var segment_count := _active_section.segments.size()
|
||||
var segment_word := "Segment" if segment_count == 1 else "Segmente"
|
||||
|
||||
if _view_3d_active:
|
||||
var camera_name := (
|
||||
_presentation_3d.get_camera_mode_name()
|
||||
if _presentation_3d != null
|
||||
else "Folge"
|
||||
)
|
||||
status_label.text = (
|
||||
"3D-Vorschau · %s · %d %s · %.1f s · Kamera: %s · Esc: 2D"
|
||||
% [
|
||||
_active_section.title,
|
||||
segment_count,
|
||||
segment_word,
|
||||
_routine.get_duration_seconds(),
|
||||
camera_name,
|
||||
]
|
||||
)
|
||||
delete_segment_button.disabled = true
|
||||
return
|
||||
|
||||
var text := (
|
||||
"%s · %d %s · %.1f s"
|
||||
% [
|
||||
|
|
|
|||
71
rinkplanner/tests/manual/capture_3d.gd
Normal file
71
rinkplanner/tests/manual/capture_3d.gd
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
extends SceneTree
|
||||
|
||||
## Rendert die 3D-Vorschau mit einer kurzen Testkür.
|
||||
##
|
||||
## Aufruf:
|
||||
## xvfb-run -a godot --path rinkplanner \
|
||||
## --script res://tests/manual/capture_3d.gd -- 1400 900 /tmp/opencode/3d.png
|
||||
|
||||
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_capture.call_deferred()
|
||||
|
||||
|
||||
func _capture() -> void:
|
||||
var args := OS.get_cmdline_user_args()
|
||||
var width := int(args[0]) if args.size() > 0 else 1400
|
||||
var height := int(args[1]) if args.size() > 1 else 900
|
||||
var output := args[2] if args.size() > 2 else "user://capture_3d.png"
|
||||
var seek_time := float(args[3]) if args.size() > 3 else 4.0
|
||||
var camera_mode := args[4] if args.size() > 4 else "follow"
|
||||
|
||||
var controller := WhiteboardScene.instantiate() as WhiteboardController
|
||||
controller.restore_autosave = false
|
||||
controller.autosave_enabled = false
|
||||
root.add_child(controller)
|
||||
root.size = Vector2i(width, height)
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
controller.add_segment(
|
||||
Vector2(-22.0, -8.0),
|
||||
Vector2(-10.0, -8.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
controller.add_segment(
|
||||
Vector2(-10.0, -8.0),
|
||||
Vector2(2.0, 2.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.INSIDE,
|
||||
WhiteboardController.Tool.ARC_LEFT
|
||||
)
|
||||
controller.add_segment(
|
||||
Vector2(2.0, 2.0),
|
||||
Vector2(20.0, 2.0),
|
||||
PathSegment.Direction.BACKWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
controller.add_element_marker(
|
||||
Vector2(4.0, 8.0),
|
||||
PathSegment.ElementType.SPIN,
|
||||
"CCoSp4",
|
||||
3
|
||||
)
|
||||
|
||||
controller.open_3d_view()
|
||||
if camera_mode == "overview":
|
||||
controller.get_presentation_3d().set_camera_mode(
|
||||
Presentation3D.CameraMode.OVERVIEW
|
||||
)
|
||||
controller.seek_playback(seek_time)
|
||||
await process_frame
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var image := root.get_texture().get_image()
|
||||
image.save_png(output)
|
||||
print("SAVED ", output)
|
||||
quit(0)
|
||||
1
rinkplanner/tests/manual/capture_3d.gd.uid
Normal file
1
rinkplanner/tests/manual/capture_3d.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://kuf6qr2y4roq
|
||||
227
rinkplanner/tests/run_presentation3d_tests.gd
Normal file
227
rinkplanner/tests/run_presentation3d_tests.gd
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
extends SceneTree
|
||||
|
||||
## Headless tests for the 3D preview: coordinate mapping, rink construction,
|
||||
## camera modes and the 2D/3D toggle in the whiteboard controller.
|
||||
##
|
||||
## Run with:
|
||||
## godot --headless --path rinkplanner --script res://tests/run_presentation3d_tests.gd
|
||||
|
||||
const PresentationScene := preload(
|
||||
"res://scenes/presentation3d/presentation_3d.tscn"
|
||||
)
|
||||
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
|
||||
|
||||
var _assertions: int = 0
|
||||
var _failures: PackedStringArray = PackedStringArray()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
await _test_presentation()
|
||||
await _test_controller()
|
||||
_finish()
|
||||
|
||||
|
||||
func _test_presentation() -> void:
|
||||
var presentation := PresentationScene.instantiate() as Presentation3D
|
||||
root.add_child(presentation)
|
||||
await process_frame
|
||||
|
||||
var routine := Routine.new()
|
||||
routine.rink = RinkDimensions.new()
|
||||
presentation.setup(routine)
|
||||
|
||||
_check(
|
||||
presentation.rink.get_child_count() > 0,
|
||||
"rink builds geometry"
|
||||
)
|
||||
var ice := presentation.rink.get_node_or_null("Ice") as MeshInstance3D
|
||||
_check(ice != null, "rink has an ice mesh")
|
||||
if ice != null:
|
||||
var bounds := ice.mesh.get_aabb().size
|
||||
_check_approx(bounds.x, 60.0, "ice is 60 m long")
|
||||
_check_approx(bounds.z, 30.0, "ice is 30 m wide")
|
||||
_check(
|
||||
presentation.rink.get_node_or_null("CenterCircle") != null,
|
||||
"rink has a center circle"
|
||||
)
|
||||
_check(
|
||||
presentation.skater.get_child_count() > 0,
|
||||
"skater is instantiated"
|
||||
)
|
||||
|
||||
presentation.set_active(true)
|
||||
presentation.update_pose(Vector2(10.0, -5.0), Vector2(1.0, 0.0))
|
||||
presentation.update_camera_now()
|
||||
_check_approx(
|
||||
presentation.get_skater_position().x,
|
||||
10.0,
|
||||
"2D x maps to 3D x"
|
||||
)
|
||||
_check_approx(
|
||||
presentation.get_skater_position().z,
|
||||
5.0,
|
||||
"2D +y maps to 3D -z"
|
||||
)
|
||||
_check_approx(
|
||||
presentation.get_skater_yaw(),
|
||||
PI * 0.5,
|
||||
"heading +x turns the skater by 90 degrees"
|
||||
)
|
||||
|
||||
presentation.update_pose(Vector2(-3.0, 4.0), Vector2(0.0, 1.0))
|
||||
presentation.update_camera_now()
|
||||
_check_approx(
|
||||
presentation.get_skater_position().z,
|
||||
-4.0,
|
||||
"2D -y maps to 3D +z"
|
||||
)
|
||||
_check(
|
||||
absf(angle_difference(presentation.get_skater_yaw(), PI)) <= 0.001,
|
||||
"heading +y turns the skater by 180 degrees"
|
||||
)
|
||||
|
||||
presentation.set_camera_mode(Presentation3D.CameraMode.OVERVIEW)
|
||||
presentation.update_camera_now()
|
||||
_check(presentation.is_overview(), "overview mode is active")
|
||||
_check_approx(
|
||||
presentation.camera.position.y,
|
||||
Presentation3D.OVERVIEW_POSITION.y,
|
||||
"overview camera uses the configured height"
|
||||
)
|
||||
_check(
|
||||
presentation.get_camera_mode_name() == "Übersicht",
|
||||
"overview mode has a German label"
|
||||
)
|
||||
|
||||
presentation.set_camera_mode(Presentation3D.CameraMode.FOLLOW)
|
||||
presentation.update_camera_now()
|
||||
_check(not presentation.is_overview(), "follow mode is active")
|
||||
_check(
|
||||
presentation.get_camera_mode_name() == "Folge",
|
||||
"follow mode has a German label"
|
||||
)
|
||||
|
||||
presentation.clear_pose()
|
||||
_check_approx(
|
||||
presentation.get_skater_position().length(),
|
||||
0.0,
|
||||
"clear pose resets the skater position"
|
||||
)
|
||||
|
||||
presentation.set_active(false)
|
||||
_check(not presentation.visible, "inactive presentation is hidden")
|
||||
_check(not presentation.camera.current, "inactive presentation releases the camera")
|
||||
|
||||
presentation.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _test_controller() -> void:
|
||||
var controller := WhiteboardScene.instantiate() as WhiteboardController
|
||||
controller.restore_autosave = false
|
||||
controller.autosave_enabled = false
|
||||
root.add_child(controller)
|
||||
root.size = Vector2i(1400, 900)
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
controller.add_segment(
|
||||
Vector2(-20.0, 0.0),
|
||||
Vector2(20.0, 0.0),
|
||||
PathSegment.Direction.FORWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
controller.seek_playback(0.0)
|
||||
|
||||
_check(not controller.is_3d_view_active(), "3D view starts inactive")
|
||||
_check(controller.view_3d_button.text == "3D", "toolbar starts in 3D mode")
|
||||
|
||||
controller.open_3d_view()
|
||||
await process_frame
|
||||
|
||||
_check(controller.is_3d_view_active(), "3D view opens")
|
||||
_check(controller.view_3d_button.text == "2D", "toolbar offers the way back")
|
||||
_check(controller.camera_mode_button.visible, "camera button is visible in 3D")
|
||||
_check(not controller.rink_canvas.visible, "2D canvas is hidden in 3D")
|
||||
_check(not controller.sections_panel.visible, "section panel is hidden in 3D")
|
||||
_check(not controller.timing_bar.visible, "timing bar is hidden in 3D")
|
||||
_check(not controller.delete_segment_button.visible, "delete button is hidden in 3D")
|
||||
_check(controller.play_button.visible, "playback bar stays visible in 3D")
|
||||
|
||||
var presentation := controller.get_presentation_3d()
|
||||
_check(presentation != null, "controller owns a presentation")
|
||||
if presentation == null:
|
||||
return
|
||||
|
||||
_check(presentation.is_active(), "presentation is active")
|
||||
var expected := controller.get_playback_position()
|
||||
var skater_position := presentation.get_skater_position()
|
||||
_check_approx(skater_position.x, expected.x, "skater follows the playback x")
|
||||
_check_approx(skater_position.z, -expected.y, "skater follows the playback y")
|
||||
|
||||
var duration := controller.get_playback_duration()
|
||||
controller.seek_playback(duration * 0.5)
|
||||
await process_frame
|
||||
expected = controller.get_playback_position()
|
||||
skater_position = presentation.get_skater_position()
|
||||
_check_approx(skater_position.x, expected.x, "scrubbing updates the skater x")
|
||||
_check_approx(skater_position.z, -expected.y, "scrubbing updates the skater y")
|
||||
|
||||
var was_overview := presentation.is_overview()
|
||||
controller.camera_mode_button.pressed.emit()
|
||||
_check(
|
||||
presentation.is_overview() != was_overview,
|
||||
"camera button switches the camera mode"
|
||||
)
|
||||
|
||||
controller.close_3d_view()
|
||||
_check(not controller.is_3d_view_active(), "3D view closes")
|
||||
_check(controller.view_3d_button.text == "3D", "toolbar returns to 3D action")
|
||||
_check(controller.rink_canvas.visible, "2D canvas is restored")
|
||||
_check(controller.sections_panel.visible, "section panel is restored")
|
||||
_check(controller.timing_bar.visible, "timing bar is restored")
|
||||
_check(not controller.camera_mode_button.visible, "camera button is hidden in 2D")
|
||||
_check(not presentation.is_active(), "presentation is inactive after closing")
|
||||
|
||||
controller.open_3d_view()
|
||||
await process_frame
|
||||
var escape := InputEventKey.new()
|
||||
escape.keycode = KEY_ESCAPE
|
||||
escape.physical_keycode = KEY_ESCAPE
|
||||
escape.pressed = true
|
||||
controller._unhandled_input(escape)
|
||||
_check(not controller.is_3d_view_active(), "Escape closes the 3D view")
|
||||
|
||||
controller.queue_free()
|
||||
await process_frame
|
||||
|
||||
|
||||
func _check_approx(
|
||||
actual: float,
|
||||
expected: float,
|
||||
message: String,
|
||||
tolerance: float = 0.001
|
||||
) -> void:
|
||||
_check(absf(actual - expected) <= tolerance, message)
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
_assertions += 1
|
||||
if not condition:
|
||||
_failures.append(message)
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if _failures.is_empty():
|
||||
print("PASS: %d assertions" % _assertions)
|
||||
quit(0)
|
||||
return
|
||||
|
||||
for failure: String in _failures:
|
||||
printerr("FAIL: %s" % failure)
|
||||
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
|
||||
quit(1)
|
||||
1
rinkplanner/tests/run_presentation3d_tests.gd.uid
Normal file
1
rinkplanner/tests/run_presentation3d_tests.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cmdw4eamvyxhv
|
||||
Loading…
Add table
Add a link
Reference in a new issue