Skip to content

Commit

Permalink
Adding Image.imageProperty/Path.shapeProperty usages, see phetsims/sc…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Feb 20, 2024
1 parent efd73cf commit a2d9e80
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions js/common/view/DensityBuoyancyScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,27 +646,30 @@ export default class DensityBuoyancyScreenView<Model extends DensityBuoyancyMode
this.sceneNode.backgroundEventTarget.addChild( focusablePath );

mass.transformedEmitter.addListener( () => {
const translation = mass.matrix.translation;
const bbox = mass.getLocalBounds();
if ( focusablePath.isDisposed ) {
return;
}

const shiftedBbox = bbox.shifted( translation.toVector3() );
const translation = mass.matrix.translation;
const bbox = mass.getLocalBounds();

const viewPoints = [
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.maxZ ) )
];
const shiftedBbox = bbox.shifted( translation.toVector3() );

focusablePath.shape = Shape.polygon( ConvexHull2.grahamScan( viewPoints, false ) );
const viewPoints = [
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.minY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.minX, shiftedBbox.maxY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.minY, shiftedBbox.maxZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.minZ ) ),
this.modelToViewPoint( new Vector3( shiftedBbox.maxX, shiftedBbox.maxY, shiftedBbox.maxZ ) )
];

focusablePath.focusHighlight = focusablePath.shape;
}
);
focusablePath.shape = Shape.polygon( ConvexHull2.grahamScan( viewPoints, false ) );

focusablePath.focusHighlight = focusablePath.shape;
} );

if ( massView instanceof ScaleView ) {

Expand Down

0 comments on commit a2d9e80

Please sign in to comment.