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
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