Add a ruler for the grid
See original GitHub issueA ruler would be useful to check part dimensions before exporting.
This proof of concept kind of works:
diff --git a/src/moto/space.js b/src/moto/space.js
index 06589e0..6711326 100644
--- a/src/moto/space.js
+++ b/src/moto/space.js
@@ -248,13 +248,29 @@
h = y / 2,
d = z / 2,
zp = -d - platformZOff + gridZOff,
- majors = [], minors = unitMinor ? [] : null, i;
+ majors = [], minors = unitMinor ? [] : null, i,
+ labelSize = gridUnitMinor * 1.5,
+ canvasScale = 4,
+ canvasPadding = 10,
+ xLabelsMesh,
+ xLabelCanvas = document.createElement('canvas'),
+ xLabelCtx = xLabelCanvas.getContext('2d');
+
+ xLabelCanvas.width = x * canvasScale + canvasPadding * 2 * canvasScale;
+ xLabelCanvas.height = labelSize * canvasScale;
+ xLabelCtx.scale(canvasScale, canvasScale);
+ xLabelCtx.fillStyle = '#333333';
+ xLabelCtx.font = labelSize + 'px monospace';
+ xLabelCtx.textAlign = 'center';
+ xLabelCtx.textBaseline = 'top';
+
for (i = -xo; i <= xo; i += unitMinor) {
let oh = isRound ? Math.sqrt(1-(i/xo)*(i/xo)) * h : h,
dM = Math.abs(i % unitMajor);
if (i < -w || i > w) continue;
if (dM < 1 || Math.abs(unitMajor - dM) < 0.1) {
majors.append({x:i, y:-oh, z:zp}).append({x:i, y:oh, z:zp});
+ xLabelCtx.fillText('' + (i + w), i + xo + canvasPadding, 0)
} else {
minors.append({x:i, y:-oh, z:zp}).append({x:i, y:oh, z:zp});
}
@@ -273,6 +289,18 @@
if (minors) gridView.add(makeLinesFromPoints(minors, gridColorMinor || 0xcccccc, 1));
if (oldGridView) Space.scene.remove(oldGridView);
Space.scene.add(gridView);
+
+ xLabelsMesh = new THREE.Mesh(
+ new THREE.PlaneGeometry(x + canvasPadding * 2, labelSize),
+ new THREE.MeshBasicMaterial({
+ transparent: true,
+ map: new THREE.CanvasTexture(xLabelCanvas),
+ })
+ );
+ xLabelsMesh.position.x = 0;
+ xLabelsMesh.position.y = - h - labelSize;
+ xLabelsMesh.position.z = zp;
+ gridView.add(xLabelsMesh);
}
function setOrigin(x, y, z) {

Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Grid Ruler
It allow you to creates vertical and horizontal grids, Photoshop style. It has a ruler to measure distance between your grids too.
Read more >Rulers, grids, and guides in Photoshop Elements
In Adobe Photoshop Elements, learn how to use rulers, grids, and guides to help you position items such as selections, layers, and shapes....
Read more >Ruler and Grid - SAi Cloud
Rulers appear along the top and left side of the main screen to help you measure and align objects. As you move the...
Read more >Using rulers, grids, and guides - Corel
To display the ruler, grid, or guides · Choose the View menu, and select one of the following: · Rulers · Grid ·...
Read more >Tips for Grids, Guides, and Ruler Options in Photoshop
Discover everything about working with Grid, Guides, and Ruler Shortcuts in ... To add a guide using the rulers, click in the ruler...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for this project and for merging. The ruler will be useful to us.
Makes sense. Will see what I can do.