tighten label to platform, remove belt specific render
This commit is contained in:
parent
f7edbad51d
commit
ba294c34b1
1 changed files with 18 additions and 29 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
import { broker } from './broker.js';
|
|
||||||
import { THREE } from '../ext/three.js';
|
import { THREE } from '../ext/three.js';
|
||||||
import { Orbit } from './orbit.js';
|
import { Orbit } from './orbit.js';
|
||||||
import { Text3D } from './text3d.js';
|
import { Text3D } from './text3d.js';
|
||||||
|
|
@ -462,33 +461,23 @@ function updateRulers() {
|
||||||
// Canvas is centered at world X=0, canvas width = x + xPadding
|
// Canvas is centered at world X=0, canvas width = x + xPadding
|
||||||
// So world X = (canvasX - canvasWidth/2) = (ruler.xo + i + xPadding/2) - (x + xPadding)/2
|
// So world X = (canvasX - canvasWidth/2) = (ruler.xo + i + xPadding/2) - (x + xPadding)/2
|
||||||
// = ruler.xo + i - x/2 = ruler.xo + i - w
|
// = ruler.xo + i - x/2 = ruler.xo + i - w
|
||||||
if (platformBelt) {
|
|
||||||
for (let i = 0; i <= ruler.x2; i += grid.unitMajor) {
|
|
||||||
const value = (i * factor).round(1).toString();
|
|
||||||
const label = text3d.createLabel(value, labelSize, rulerColor, 'center');
|
|
||||||
label.position.set(ruler.x2 - i, -h - labelSize * 2, zp);
|
|
||||||
label.rotation.x = Math.PI;
|
|
||||||
view.add(label);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i >= ruler.x1; i -= grid.unitMajor) {
|
for (let i = 0; i >= ruler.x1; i -= grid.unitMajor) {
|
||||||
const value = (i * factor).round(1).toString();
|
const value = (i * factor).round(1).toString();
|
||||||
const label = text3d.createLabel(value, labelSize, rulerColor, 'center');
|
const label = text3d.createLabel(value, labelSize, rulerColor, 'center');
|
||||||
label.position.set(ruler.xo + i - w, -h - labelSize * 2, zp);
|
label.position.set(ruler.xo + i - w, -h - labelSize, zp);
|
||||||
label.rotation.x = Math.PI;
|
label.rotation.x = Math.PI;
|
||||||
view.add(label);
|
view.add(label);
|
||||||
}
|
}
|
||||||
for (let i = 0; i <= ruler.x2; i += grid.unitMajor) {
|
for (let i = 0; i <= ruler.x2; i += grid.unitMajor) {
|
||||||
const value = (i * factor).round(1).toString();
|
const value = (i * factor).round(1).toString();
|
||||||
const label = text3d.createLabel(value, labelSize, rulerColor, 'center');
|
const label = text3d.createLabel(value, labelSize, rulerColor, 'center');
|
||||||
label.position.set(ruler.xo + i - w, -h - labelSize * 2, zp);
|
label.position.set(ruler.xo + i - w, -h - labelSize, zp);
|
||||||
label.rotation.x = Math.PI;
|
label.rotation.x = Math.PI;
|
||||||
view.add(label);
|
view.add(label);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create X-axis label
|
// Create X-axis label
|
||||||
const xLabel = text3d.createLabel(xlabel, labelSize * 0.75, rulerColor, 'center');
|
const xLabel = text3d.createLabel(xlabel, labelSize, rulerColor, 'center');
|
||||||
xLabel.position.set(0, -h - labelSize * 3.5, zp);
|
xLabel.position.set(0, -h - labelSize * 3.5, zp);
|
||||||
xLabel.rotation.x = Math.PI;
|
xLabel.rotation.x = Math.PI;
|
||||||
view.add(xLabel);
|
view.add(xLabel);
|
||||||
|
|
@ -503,21 +492,21 @@ function updateRulers() {
|
||||||
for (let i = 0; i >= ruler.y1; i -= grid.unitMajor) {
|
for (let i = 0; i >= ruler.y1; i -= grid.unitMajor) {
|
||||||
const value = (i * factor).round(1).toString();
|
const value = (i * factor).round(1).toString();
|
||||||
const label = text3d.createLabel(value, labelSize, rulerColor, 'right');
|
const label = text3d.createLabel(value, labelSize, rulerColor, 'right');
|
||||||
label.position.set(-w - labelSize * 2 - 5, -h + ruler.yo + i, zp);
|
label.position.set(-w - labelSize + 3, -h + ruler.yo + i, zp);
|
||||||
label.rotation.x = Math.PI;
|
label.rotation.x = Math.PI;
|
||||||
view.add(label);
|
view.add(label);
|
||||||
}
|
}
|
||||||
for (let i = 0; i <= ruler.y2; i += grid.unitMajor) {
|
for (let i = 0; i <= ruler.y2; i += grid.unitMajor) {
|
||||||
const value = (i * factor).round(1).toString();
|
const value = (i * factor).round(1).toString();
|
||||||
const label = text3d.createLabel(value, labelSize, rulerColor, 'right');
|
const label = text3d.createLabel(value, labelSize, rulerColor, 'right');
|
||||||
label.position.set(-w - labelSize * 2 - 5, -h + ruler.yo + i, zp);
|
label.position.set(-w - labelSize + 3, -h + ruler.yo + i, zp);
|
||||||
label.rotation.x = Math.PI;
|
label.rotation.x = Math.PI;
|
||||||
view.add(label);
|
view.add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Y-axis label
|
// Create Y-axis label
|
||||||
const yLabel = text3d.createLabel(ylabel, labelSize * 0.75, rulerColor, 'center');
|
const yLabel = text3d.createLabel(ylabel, labelSize, rulerColor, 'center');
|
||||||
yLabel.position.set(-w - labelSize * 5, 0, zp);
|
yLabel.position.set(-w - labelSize * 4, 0, zp);
|
||||||
yLabel.rotation.x = Math.PI;
|
yLabel.rotation.x = Math.PI;
|
||||||
view.add(yLabel);
|
view.add(yLabel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue