@@ -6,9 +6,10 @@ namespace DotStimulus
66 public class Dot
77 {
88 private readonly Vector2 _velocity ;
9- private Vector3 _position ;
9+ public Vector3 Position { get ; private set ; }
10+ private Vector3 _currentPosition ;
1011 private Vector3 _oldPosition ;
11- private readonly float _scale ;
12+ public readonly float scale ;
1213 private readonly StimulusSettings _settings ;
1314
1415 private readonly float _apertureRadius ;
@@ -18,14 +19,15 @@ public class Dot
1819 public Dot ( Vector2 velocity , Vector3 startingPosition , StimulusSettings settings )
1920 {
2021 _velocity = velocity ;
21- _position = startingPosition ;
22+ _currentPosition = startingPosition ;
23+ Position = _currentPosition ;
2224 _settings = settings ;
2325 _elapsedTime = 0 ;
2426
2527 var dotSize = settings . dotSizeArcMinutes * Mathf . PI / ( 60 * 180 ) * settings . stimDepthMeters ;
2628 _apertureRadius = Mathf . Tan ( settings . apertureRadiusDegrees * Mathf . PI / 180 ) * settings . stimDepthMeters ;
2729 _sqrApertureRadius = _apertureRadius * _apertureRadius ;
28- _scale = dotSize ;
30+ scale = dotSize ;
2931
3032 // In case first update puts dot outside circle
3133 var randomPosition = Random . insideUnitCircle * _apertureRadius ;
@@ -37,35 +39,26 @@ public void UpdateDot()
3739 if ( _elapsedTime > Random . Range ( _settings . minDotLifetime , _settings . maxDotLifetime ) )
3840 {
3941 var randomPosition = Random . insideUnitCircle * _apertureRadius ;
40- _position . x = randomPosition . x ;
41- _position . z = randomPosition . y ;
42+ _currentPosition . x = randomPosition . x ;
43+ _currentPosition . z = randomPosition . y ;
4244 _elapsedTime = 0.0f ;
4345 }
4446 else
4547 {
46- _position . x += _velocity . x * Time . deltaTime ;
47- _position . z += _velocity . y * Time . deltaTime ;
48+ _currentPosition . x += _velocity . x * Time . deltaTime ;
49+ _currentPosition . z += _velocity . y * Time . deltaTime ;
4850
4951 // Square magnitude used for efficiency
50- if ( _position . sqrMagnitude > _sqrApertureRadius )
52+ if ( _currentPosition . sqrMagnitude > _sqrApertureRadius )
5153 {
52- _position . x = - _oldPosition . x ;
53- _position . z = - _oldPosition . z ;
54+ _currentPosition . x = - _oldPosition . x ;
55+ _currentPosition . z = - _oldPosition . z ;
5456 }
5557 }
5658
59+ Position = _currentPosition ;
5760 _elapsedTime += Time . deltaTime ;
58- _oldPosition = _position ;
59- }
60-
61- public Vector3 GetPosition ( )
62- {
63- return _position ;
64- }
65-
66- public float GetScale ( )
67- {
68- return _scale ;
61+ _oldPosition = _currentPosition ;
6962 }
7063 }
7164}
0 commit comments