Skip to content

Commit

Permalink
Show G-code file name as text sprite on 3D visualizer (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Dec 24, 2016
1 parent 3090825 commit a71092b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/web/widgets/Visualizer/Visualizer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,25 @@ class Visualizer extends Component {
// Update work position
this.setWorkPosition(this.workPosition);

{ // G-code meta text sprite
const { units, gcode } = this.props.state;
const gridLength = (units === METRIC_UNITS) ? 10 : 25.4;
const textSize = 5;
const posx = bbox.min.x + (dX / 2);
const posy = Math.floor(bbox.min.y / gridLength) * gridLength - (gridLength / 2);
const posz = textSize / 2;
const metaTextSprite = new TextSprite({
x: posx,
y: posy,
z: posz,
size: textSize,
text: gcode.name,
color: colornames('gray 44'), // grid color
opacity: 0.5
});
obj.add(metaTextSprite);
}

{ // Fit the camera to object
const objectWidth = dX;
const objectHeight = dY;
Expand Down

0 comments on commit a71092b

Please sign in to comment.