add build volume lines

This commit is contained in:
Stewart Allen 2020-11-10 15:38:09 -05:00
commit 35448175ea
2 changed files with 55 additions and 15 deletions

View file

@ -106,7 +106,8 @@
group: platformGroup, group: platformGroup,
group_done: platformGroupDone, group_done: platformGroupDone,
set_font: SPACE.platform.setFont, set_font: SPACE.platform.setFont,
set_axes: SPACE.platform.setAxes set_axes: SPACE.platform.setAxes,
set_volume: SPACE.platform.setVolume
}; };
const color = { const color = {
@ -966,7 +967,8 @@
SPACE.platform.setSize( SPACE.platform.setSize(
width = parseInt(dev.bedWidth), width = parseInt(dev.bedWidth),
depth = parseInt(dev.bedDepth), depth = parseInt(dev.bedDepth),
height = parseFloat(dev.bedHeight) height = parseFloat(dev.bedHeight),
parseFloat(dev.maxHeight)
); );
let proc = settings.process, let proc = settings.process,
ctrl = settings.controller, ctrl = settings.controller,

View file

@ -63,6 +63,7 @@
rulerColor, rulerColor,
axisColor, axisColor,
axesOn = true, axesOn = true,
volumeOn = true,
viewControl, viewControl,
trackPlane, trackPlane,
platform, platform,
@ -71,6 +72,7 @@
platformClickAt, platformClickAt,
platformOnMove, platformOnMove,
platformMoveTimer, platformMoveTimer,
volume,
light1, light1,
light2, light2,
light3, light3,
@ -215,7 +217,7 @@
requestRefresh(); requestRefresh();
} }
function setPlatformSize(width, depth, height) { function setPlatformSize(width, depth, height, maxz) {
if (isRound) { if (isRound) {
platform.scale.set(width || 300, height || 5, depth || 175); platform.scale.set(width || 300, height || 5, depth || 175);
} else { } else {
@ -228,10 +230,38 @@
light2.position.set(-width, y, -depth); light2.position.set(-width, y, -depth);
light4.position.set( width, light4.position.y, -depth); light4.position.set( width, light4.position.y, -depth);
light5.position.set(-width, light5.position.y, depth); light5.position.set(-width, light5.position.y, depth);
if (volume) {
SCENE.remove(volume);
volume = null;
}
if (maxz) {
const points = [
// pillars
{x: -width/2, z: -depth/2, y: 0},
{x: -width/2, z: -depth/2, y: maxz},
{x: width/2, z: depth/2, y: 0},
{x: width/2, z: depth/2, y: maxz},
{x: -width/2, z: depth/2, y: 0},
{x: -width/2, z: depth/2, y: maxz},
{x: width/2, z: -depth/2, y: 0},
{x: width/2, z: -depth/2, y: maxz},
// top
{x: -width/2, z: -depth/2, y: maxz},
{x: -width/2, z: depth/2, y: maxz},
{x: -width/2, z: -depth/2, y: maxz},
{x: width/2, z: -depth/2, y: maxz},
{x: width/2, z: depth/2, y: maxz},
{x: width/2, z: -depth/2, y: maxz},
{x: width/2, z: depth/2, y: maxz},
{x: -width/2, z: depth/2, y: maxz},
];
SCENE.add(volume = makeLinesFromPoints(points, 0x888888, 0.25));
setVolume(volumeOn);
}
} }
function setPlatformSizeUpdateGrid(width, depth, height) { function setPlatformSizeUpdateGrid(width, depth, height, maxz) {
setPlatformSize(width, depth, height); setPlatformSize(width, depth, height, maxz);
setGrid(gridUnitMajor, gridUnitMinor); setGrid(gridUnitMajor, gridUnitMinor);
} }
@ -255,6 +285,12 @@
setRulers(); setRulers();
} }
function setVolume(bool) {
volumeOn = bool;
if (volume) volume.visible = bool;
requestRefresh();
}
function setRulers(drawX, drawY, offsetCenter) { function setRulers(drawX, drawY, offsetCenter) {
if (drawX === undefined) drawX = rulerX; if (drawX === undefined) drawX = rulerX;
if (drawY === undefined) drawY = rulerY; if (drawY === undefined) drawY = rulerY;
@ -552,22 +588,23 @@
* ThreeJS Helper Functions * ThreeJS Helper Functions
******************************************************************* */ ******************************************************************* */
function makeLinesFromPoints(points, color, width) { function makeLinesFromPoints(points, color, opacity) {
if (points.length % 2 != 0) throw "invalid line : "+points.length; if (points.length % 2 != 0) {
let geo = new THREE.Geometry(), throw "invalid line : "+points.length;
i = 0, p1, p2, mesh; }
while (i < points.length) { const geo = new THREE.Geometry();
p1 = points[i++]; for (let i=0; i < points.length; ) {
p2 = points[i++]; const p1 = points[i++];
const p2 = points[i++];
geo.vertices.push(new THREE.Vector3(p1.x, p1.y, p1.z)); geo.vertices.push(new THREE.Vector3(p1.x, p1.y, p1.z));
geo.vertices.push(new THREE.Vector3(p2.x, p2.y, p2.z)); geo.vertices.push(new THREE.Vector3(p2.x, p2.y, p2.z));
} }
geo.verticesNeedUpdate = true; geo.verticesNeedUpdate = true;
mesh = new THREE.LineSegments(geo, new THREE.LineBasicMaterial({ return new THREE.LineSegments(geo, new THREE.LineBasicMaterial({
color: color, color: color,
linewidth: width || 1 opacity: opacity || 1,
transparent: opacity != 1
})); }));
return mesh;
} }
function intersect(objects, recurse) { function intersect(objects, recurse) {
@ -752,6 +789,7 @@
setGrid: setGrid, setGrid: setGrid,
setFont: setFont, setFont: setFont,
setAxes: setAxes, setAxes: setAxes,
setVolume: setVolume,
add: function(o) { WORLD.add(o) }, add: function(o) { WORLD.add(o) },
remove: function(o) { WORLD.remove(o) }, remove: function(o) { WORLD.remove(o) },
setMaxZ: function(z) { panY = z / 2 }, setMaxZ: function(z) { panY = z / 2 },