diff --git a/js/common/model/AncillaryTool.ts b/js/common/model/AncillaryTool.ts index 6b4a7382..9f5429bd 100644 --- a/js/common/model/AncillaryTool.ts +++ b/js/common/model/AncillaryTool.ts @@ -163,10 +163,11 @@ export default class AncillaryTool extends PhetioObject { /** * As the xProperty for a curve changes, provide the corresponding CurvePoint. + * Note that curve.pointsProperty may also be changed via PhET-iO, see https://github.com/phetsims/calculus-grapher/issues/307. * Return type is ReadOnlyProperty so that we can call notifyListenersStatic. */ function createCurvePointProperty( curve: Curve, xProperty: TReadOnlyProperty ): ReadOnlyProperty { - return new DerivedProperty( [ xProperty ], x => curve.getClosestPointAt( x ) ); + return new DerivedProperty( [ curve.pointsProperty, xProperty ], ( points, x ) => curve.getClosestPointAt( x ) ); } /** diff --git a/js/common/model/Curve.ts b/js/common/model/Curve.ts index ab1e2249..1fb76e71 100644 --- a/js/common/model/Curve.ts +++ b/js/common/model/Curve.ts @@ -57,7 +57,7 @@ export default class Curve extends PhetioObject { // The collection of points that describe the curve. This is an array of CurvePoint instances that are typically // mutated in place, so that we have acceptable performance. If Curve was instantiated with pointsPropertyReadOnly:false, // then it is possible to set pointsProperty via PhET-iO. - private readonly pointsProperty: Property; + public readonly pointsProperty: Property; // Using an observable Property for the y-value was considered, but it was deemed to be // invasive to the performance of the simulation as observers had to listen to the yProperty