2.1 KiB
local-player-presentation-state Specification
Purpose
Define how the local player's presentation layer holds current display state and smoothly interpolates toward the simulation layer's target state each frame.
ADDED Requirements
Requirement: Presentation layer holds current and target state
The local player's presentation layer SHALL maintain _currentPosition and _currentRotation (the actively displayed state) separately from _targetPosition and _targetRotation (the simulation layer's output).
Scenario: Presentation state initializes from first simulation target
- WHEN the presentation layer is initialized or first receives a simulation target
- THEN
_currentPositionand_currentRotationare set equal to the initial target - THEN subsequent updates lerp toward the target
Requirement: Presentation layer lerps toward target each frame
The presentation layer SHALL each frame interpolate _currentPosition and _currentRotation toward _targetPosition and _targetRotation using linear interpolation, then apply the result to the Rigidbody.
Scenario: Lerp position and rotation toward target
- WHEN the presentation layer updates each frame with interpolation alpha α
- THEN
_currentPositionis updated toVector3.Lerp(_currentPosition, _targetPosition, α) - THEN
_currentRotationis updated toQuaternion.Slerp(_currentRotation, _targetRotation, α) - THEN
_rigid.positionand_rigid.rotationare set to_currentPositionand_currentRotation
Requirement: Presentation layer snaps when target error exceeds threshold
When the distance between _currentPosition and _targetPosition exceeds the snap threshold, the presentation layer SHALL immediately snap _currentPosition to _targetPosition without lerping.
Scenario: Snap when error exceeds threshold
- WHEN
Vector3.Distance(_currentPosition, _targetPosition) > SnapThreshold - THEN
_currentPositionis set equal to_targetPosition - THEN
_currentRotationis set equal to_targetRotation - THEN no lerping occurs in this frame