66 */
77
88import {
9- NumberProperty ,
109 Property ,
1110 type TReadOnlyProperty ,
1211} from "scenerystack/axon" ;
@@ -26,17 +25,17 @@ const GRAPH_HEIGHT = 200;
2625const MAX_DATA_POINTS = 5000 ;
2726
2827/**
29- * Creates a PlottableProperty for a kinematic variable with a subStepAccessor.
28+ * Creates a PlottableProperty for a kinematic variable driven entirely by
29+ * subStepAccessor. No backing Property is needed because KinematicsGraphNode
30+ * always feeds data via addDataPointsFromSubSteps rather than addDataPoint.
3031 */
3132function createPlottableProperty (
3233 name : string ,
3334 unit : string | TReadOnlyProperty < string > ,
34- dummyProperty : NumberProperty ,
3535 accessor : ( point : SubStepDataPoint ) => number ,
3636) : PlottableProperty {
3737 return {
3838 name,
39- property : dummyProperty ,
4039 unit,
4140 subStepAccessor : accessor ,
4241 } ;
@@ -51,17 +50,6 @@ export class KinematicsGraphNode extends VBox {
5150 private currentComboBox : ComboBox < string | null > | null = null ;
5251 private readonly disposeKinematicsGraph : ( ) => void ;
5352
54- // Dummy properties for the graph (values aren't used directly, we push data manually)
55- private readonly tProperty = new NumberProperty ( 0 ) ;
56- private readonly xProperty = new NumberProperty ( 0 ) ;
57- private readonly yProperty = new NumberProperty ( 0 ) ;
58- private readonly vxProperty = new NumberProperty ( 0 ) ;
59- private readonly vyProperty = new NumberProperty ( 0 ) ;
60- private readonly speedProperty = new NumberProperty ( 0 ) ;
61- private readonly axProperty = new NumberProperty ( 0 ) ;
62- private readonly ayProperty = new NumberProperty ( 0 ) ;
63- private readonly aMagProperty = new NumberProperty ( 0 ) ;
64-
6553 public constructor ( model : SimModel , listParent : Node ) {
6654 super ( {
6755 spacing : 8 ,
@@ -72,58 +60,18 @@ export class KinematicsGraphNode extends VBox {
7260 this . listParent = listParent ;
7361 this . selectedTrackProperty = new Property < string | null > ( null ) ;
7462
75- // Create plottable properties using unit properties from the model
76- // Accessor functions return 0 for undefined values (filtered out later by NaN check)
63+ // Create plottable properties using unit properties from the model.
64+ // Accessor functions return 0 for undefined values (filtered out later by NaN check).
7765 const plottableProperties : PlottableProperty [ ] = [
78- createPlottableProperty ( "t" , "s" , this . tProperty , ( pt ) => pt . t ?? 0 ) ,
79- createPlottableProperty (
80- "x" ,
81- model . distanceUnitProperty ,
82- this . xProperty ,
83- ( pt ) => pt . x ?? 0 ,
84- ) ,
85- createPlottableProperty (
86- "y" ,
87- model . distanceUnitProperty ,
88- this . yProperty ,
89- ( pt ) => pt . y ?? 0 ,
90- ) ,
91- createPlottableProperty (
92- "vx" ,
93- model . velocityUnitProperty ,
94- this . vxProperty ,
95- ( pt ) => pt . vx ?? 0 ,
96- ) ,
97- createPlottableProperty (
98- "vy" ,
99- model . velocityUnitProperty ,
100- this . vyProperty ,
101- ( pt ) => pt . vy ?? 0 ,
102- ) ,
103- createPlottableProperty (
104- "speed" ,
105- model . velocityUnitProperty ,
106- this . speedProperty ,
107- ( pt ) => pt . speed ?? 0 ,
108- ) ,
109- createPlottableProperty (
110- "ax" ,
111- model . accelerationUnitProperty ,
112- this . axProperty ,
113- ( pt ) => pt . ax ?? 0 ,
114- ) ,
115- createPlottableProperty (
116- "ay" ,
117- model . accelerationUnitProperty ,
118- this . ayProperty ,
119- ( pt ) => pt . ay ?? 0 ,
120- ) ,
121- createPlottableProperty (
122- "|a|" ,
123- model . accelerationUnitProperty ,
124- this . aMagProperty ,
125- ( pt ) => pt . aMag ?? 0 ,
126- ) ,
66+ createPlottableProperty ( "t" , "s" , ( pt ) => pt . t ?? 0 ) ,
67+ createPlottableProperty ( "x" , model . distanceUnitProperty , ( pt ) => pt . x ?? 0 ) ,
68+ createPlottableProperty ( "y" , model . distanceUnitProperty , ( pt ) => pt . y ?? 0 ) ,
69+ createPlottableProperty ( "vx" , model . velocityUnitProperty , ( pt ) => pt . vx ?? 0 ) ,
70+ createPlottableProperty ( "vy" , model . velocityUnitProperty , ( pt ) => pt . vy ?? 0 ) ,
71+ createPlottableProperty ( "speed" , model . velocityUnitProperty , ( pt ) => pt . speed ?? 0 ) ,
72+ createPlottableProperty ( "ax" , model . accelerationUnitProperty , ( pt ) => pt . ax ?? 0 ) ,
73+ createPlottableProperty ( "ay" , model . accelerationUnitProperty , ( pt ) => pt . ay ?? 0 ) ,
74+ createPlottableProperty ( "|a|" , model . accelerationUnitProperty , ( pt ) => pt . aMag ?? 0 ) ,
12775 ] ;
12876
12977 // Default: plot y vs x (trajectory)
@@ -216,15 +164,6 @@ export class KinematicsGraphNode extends VBox {
216164 }
217165 this . selectedTrackProperty . dispose ( ) ;
218166 this . graph . dispose ( ) ;
219- this . tProperty . dispose ( ) ;
220- this . xProperty . dispose ( ) ;
221- this . yProperty . dispose ( ) ;
222- this . vxProperty . dispose ( ) ;
223- this . vyProperty . dispose ( ) ;
224- this . speedProperty . dispose ( ) ;
225- this . axProperty . dispose ( ) ;
226- this . ayProperty . dispose ( ) ;
227- this . aMagProperty . dispose ( ) ;
228167 } ;
229168 }
230169
0 commit comments