feat: Kufenspur blendet am Kuer-Ende aus
- Trail-Fade in Echtzeit, wenn die Wiedergabe endet und die Figur steht - Pausieren mitten in der Kuer laesst die Spur weiterhin stehen - Controller synchronisiert den Fade bei Play/Pause/Seek/Ende - 57 Praesentations-Assertions (1186 gesamt)
This commit is contained in:
parent
1530914814
commit
e79fa9635b
9 changed files with 131 additions and 15 deletions
|
|
@ -130,6 +130,14 @@ func clear_pose() -> void:
|
|||
_update_camera(0.0, true)
|
||||
|
||||
|
||||
func fade_trail_out() -> void:
|
||||
trail.start_fade()
|
||||
|
||||
|
||||
func stop_trail_fade() -> void:
|
||||
trail.stop_fade()
|
||||
|
||||
|
||||
func set_camera_mode(mode: CameraMode) -> void:
|
||||
if _camera_mode == mode:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ var _samples: Array[Dictionary] = []
|
|||
var _mesh: ImmediateMesh
|
||||
var _mesh_instance: MeshInstance3D
|
||||
var _time: float = 0.0
|
||||
var _fading: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -30,6 +31,33 @@ func _ready() -> void:
|
|||
material.albedo_color = Color.WHITE
|
||||
_mesh_instance.material_override = material
|
||||
add_child(_mesh_instance)
|
||||
set_process(false)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not _fading:
|
||||
return
|
||||
_time += delta
|
||||
_prune()
|
||||
_rebuild()
|
||||
if _samples.is_empty():
|
||||
stop_fade()
|
||||
|
||||
|
||||
func start_fade() -> void:
|
||||
if _samples.is_empty():
|
||||
return
|
||||
_fading = true
|
||||
set_process(true)
|
||||
|
||||
|
||||
func stop_fade() -> void:
|
||||
_fading = false
|
||||
set_process(false)
|
||||
|
||||
|
||||
func is_fading() -> bool:
|
||||
return _fading
|
||||
|
||||
|
||||
func add_sample(
|
||||
|
|
@ -38,6 +66,7 @@ func add_sample(
|
|||
color: Color,
|
||||
time_seconds: float = -1.0
|
||||
) -> void:
|
||||
stop_fade()
|
||||
_time = time_seconds if time_seconds >= 0.0 else _now()
|
||||
_prune()
|
||||
|
||||
|
|
@ -65,6 +94,7 @@ func add_sample(
|
|||
|
||||
|
||||
func clear() -> void:
|
||||
stop_fade()
|
||||
_samples.clear()
|
||||
if _mesh != null:
|
||||
_mesh.clear_surfaces()
|
||||
|
|
|
|||
|
|
@ -2695,6 +2695,7 @@ func play() -> void:
|
|||
_update_play_button()
|
||||
_update_playback_ui()
|
||||
_update_status()
|
||||
_sync_trail_fade()
|
||||
|
||||
|
||||
func pause() -> void:
|
||||
|
|
@ -2703,6 +2704,7 @@ func pause() -> void:
|
|||
_playing = false
|
||||
_update_play_button()
|
||||
_update_playback_ui()
|
||||
_sync_trail_fade()
|
||||
|
||||
|
||||
func reset_playback() -> void:
|
||||
|
|
@ -2715,6 +2717,7 @@ func reset_playback() -> void:
|
|||
if _view_3d_active and _presentation_3d != null:
|
||||
_presentation_3d.clear_pose()
|
||||
_update_playback_ui()
|
||||
_sync_trail_fade()
|
||||
|
||||
|
||||
func seek_playback(time: float) -> void:
|
||||
|
|
@ -2724,6 +2727,7 @@ func seek_playback(time: float) -> void:
|
|||
else:
|
||||
_update_playback_state(0.0, true)
|
||||
_update_playback_ui()
|
||||
_sync_trail_fade()
|
||||
|
||||
|
||||
func advance_playback(delta: float) -> void:
|
||||
|
|
@ -2741,6 +2745,7 @@ func advance_playback(delta: float) -> void:
|
|||
_playing = false
|
||||
_update_play_button()
|
||||
_update_playback_ui()
|
||||
_sync_trail_fade()
|
||||
return
|
||||
|
||||
_update_playback_state(delta)
|
||||
|
|
@ -3015,6 +3020,7 @@ func open_3d_view() -> void:
|
|||
_update_camera_mode_button()
|
||||
rink_canvas.cancel_interaction()
|
||||
_update_status()
|
||||
_sync_trail_fade()
|
||||
|
||||
|
||||
func close_3d_view() -> void:
|
||||
|
|
@ -3023,6 +3029,7 @@ func close_3d_view() -> void:
|
|||
|
||||
_view_3d_active = false
|
||||
if _presentation_3d != null:
|
||||
_presentation_3d.stop_trail_fade()
|
||||
_presentation_3d.set_active(false)
|
||||
_set_2d_controls_visible(true)
|
||||
|
||||
|
|
@ -3063,6 +3070,20 @@ func _update_camera_mode_button() -> void:
|
|||
)
|
||||
|
||||
|
||||
func _sync_trail_fade() -> void:
|
||||
if _presentation_3d == null or not _view_3d_active:
|
||||
return
|
||||
|
||||
var at_end := (
|
||||
_playback_total_duration > 0.0
|
||||
and _playback_time >= _playback_total_duration - 0.0001
|
||||
)
|
||||
if at_end and not _playing:
|
||||
_presentation_3d.fade_trail_out()
|
||||
else:
|
||||
_presentation_3d.stop_trail_fade()
|
||||
|
||||
|
||||
func _setup_presentation_3d() -> void:
|
||||
var packed := load(PRESENTATION_3D_SCENE_PATH) as PackedScene
|
||||
if packed == null:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ func _capture() -> void:
|
|||
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 fade_wait := float(args[5]) if args.size() > 5 else 0.0
|
||||
var with_marker := not (args.size() > 6 and args[6] == "no-marker")
|
||||
|
||||
var controller := WhiteboardScene.instantiate() as WhiteboardController
|
||||
controller.restore_autosave = false
|
||||
|
|
@ -48,12 +50,13 @@ func _capture() -> void:
|
|||
PathSegment.Direction.BACKWARD,
|
||||
PathSegment.Edge.OUTSIDE
|
||||
)
|
||||
controller.add_element_marker(
|
||||
Vector2(4.0, 8.0),
|
||||
PathSegment.ElementType.SPIN,
|
||||
"CCoSp4",
|
||||
3
|
||||
)
|
||||
if with_marker:
|
||||
controller.add_element_marker(
|
||||
Vector2(4.0, 8.0),
|
||||
PathSegment.ElementType.SPIN,
|
||||
"CCoSp4",
|
||||
3
|
||||
)
|
||||
|
||||
controller.open_3d_view()
|
||||
if camera_mode == "overview":
|
||||
|
|
@ -67,6 +70,8 @@ func _capture() -> void:
|
|||
controller.pause()
|
||||
await process_frame
|
||||
await process_frame
|
||||
if fade_wait > 0.0:
|
||||
await create_timer(fade_wait).timeout
|
||||
|
||||
var presentation := controller.get_presentation_3d()
|
||||
print(
|
||||
|
|
@ -81,7 +86,9 @@ func _capture() -> void:
|
|||
"TRAIL ",
|
||||
presentation.trail.get_sample_count(),
|
||||
" ",
|
||||
presentation.trail.get_last_color()
|
||||
presentation.trail.get_last_color(),
|
||||
" fading ",
|
||||
presentation.trail.is_fading()
|
||||
)
|
||||
|
||||
var image := root.get_texture().get_image()
|
||||
|
|
|
|||
|
|
@ -157,6 +157,23 @@ func _test_presentation() -> void:
|
|||
"backward trail is orange"
|
||||
)
|
||||
|
||||
presentation.trail.start_fade()
|
||||
_check(presentation.trail.is_fading(), "the trail can fade out")
|
||||
presentation.trail._process(2.0)
|
||||
_check(
|
||||
presentation.trail.get_sample_count() == 0,
|
||||
"the trail fades out when the skater stands"
|
||||
)
|
||||
presentation.update_pose(
|
||||
Vector2(3.0, 0.0),
|
||||
Vector2.RIGHT,
|
||||
forward_segment
|
||||
)
|
||||
_check(
|
||||
not presentation.trail.is_fading(),
|
||||
"new movement stops the fade"
|
||||
)
|
||||
|
||||
presentation.update_pose(
|
||||
Vector2(20.0, 0.0),
|
||||
Vector2.RIGHT,
|
||||
|
|
@ -240,6 +257,15 @@ func _test_controller() -> void:
|
|||
"camera button switches the camera mode"
|
||||
)
|
||||
|
||||
controller.seek_playback(maxf(duration - 0.05, 0.0))
|
||||
controller.play()
|
||||
controller.advance_playback(1.0)
|
||||
_check(not controller.is_playing(), "playback stops at the end")
|
||||
_check(
|
||||
presentation.trail.is_fading(),
|
||||
"trail fades after the program ends"
|
||||
)
|
||||
|
||||
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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue