diff --git a/src/editor/propEditors/BayEditor.vue b/src/editor/propEditors/BayEditor.vue index 09cd98f..5fc324c 100644 --- a/src/editor/propEditors/BayEditor.vue +++ b/src/editor/propEditors/BayEditor.vue @@ -14,6 +14,8 @@ interface DtBay { bayWidth: number; /** 列偏移 */ offset: number; + /** 列的顶部空间 */ + topHeight: number; /** 每层的高度 */ levelHeight: Array; } @@ -85,6 +87,7 @@ function applyBasicSettings() { const bay: DtBay = { bayWidth: widthOfBays, offset: 0, + topHeight: 0, levelHeight: [], }; for (let i = 0; i < numberOfLevels; i++) { @@ -124,6 +127,12 @@ function updateBayWidth(bay: DtBay, bayWidth?: number) { emit("update:modelValue", newValue); } +function updateBayTopHeight(bay: DtBay, topHeight?: number) { + bay.topHeight = topHeight; + const newValue = getModelValue(); + emit("update:modelValue", newValue); +} + function updateBayOffset(bay: DtBay, offset?: number) { bay.offset = offset; const newValue = getModelValue(); @@ -227,6 +236,13 @@ export type { @change="(offset: number) => updateBayOffset(selectDay, offset)" /> + + +
Level Heights
diff --git a/src/modules/rack/Rack3dObject.ts b/src/modules/rack/Rack3dObject.ts index db86e8f..56f1086 100644 --- a/src/modules/rack/Rack3dObject.ts +++ b/src/modules/rack/Rack3dObject.ts @@ -25,7 +25,6 @@ export default class Rack3dObject extends THREE.Object3D { private static rackHorizontalBarGeometryMap: Map = new Map() private static rackHorizontalBarMaterial: Material = null - bottomBarHeight = 0.2 bottomLinkHeight = 0.2 topLinkDistance = 0.2 @@ -297,7 +296,10 @@ export default class Rack3dObject extends THREE.Object3D { const heights = [] for (let i = 0; i < item.dt.bays.length; i++) { const bay = item.dt.bays[i] - const bayHeight = decimalSumBy(bay.levelHeight) + if (bay.topHeight == null || bay.topHeight < 0) { + bay.topHeight = 0.5 + } + const bayHeight = bay.levelHeight[bay.levelHeight.length - 1] + bay.topHeight heights.push(bayHeight) } const rackHeight = _.max(heights) @@ -357,16 +359,15 @@ export default class Rack3dObject extends THREE.Object3D { const hBarMatrix: { x: number, y: number, z: number, sx: number, sy: number, sz: number, rx: number, ry: number, rz: number, l: number }[] = [] distanceX = 0 for (let i = 0; i < item.dt.bays.length; i++) { - distanceY = this.bottomBarHeight const bay = item.dt.bays[i] for (let j = 0; j < bay.levelHeight.length; j++) { - const levelHeight = bay.levelHeight[j] - if (distanceY <= 0) { + const levelHeight = bay.levelHeight[j] - 0.05 // 0.05为横梁自身高度的一半 + if (levelHeight <= 0.0) { continue } hBarMatrix.push({ x: distanceX - rackWidth / 2, - y: distanceY, + y: levelHeight, z: -rackDepth / 2, sx: 1, sy: 0.8, @@ -378,7 +379,7 @@ export default class Rack3dObject extends THREE.Object3D { }) hBarMatrix.push({ x: distanceX - rackWidth / 2, - y: distanceY, + y: levelHeight, z: item.dt.rackDepth - rackDepth / 2, sx: 1, sy: 0.8, @@ -388,7 +389,7 @@ export default class Rack3dObject extends THREE.Object3D { rz: 0, l: bay.bayWidth }) - distanceY += levelHeight + distanceY = levelHeight } distanceX += bay.bayWidth } diff --git a/src/types/Types.d.ts b/src/types/Types.d.ts index a706e4e..5b9c759 100644 --- a/src/types/Types.d.ts +++ b/src/types/Types.d.ts @@ -257,6 +257,7 @@ interface ItemJson extends ItemMetrix { bays?: { bayWidth: number, + topHeight: number, levelHeight: number[] }[]