Browse Source

Merge remote-tracking branch 'origin/master'

master
修宁 6 months ago
parent
commit
87a8db2594
  1. 16
      src/editor/propEditors/BayEditor.vue
  2. 17
      src/modules/rack/Rack3dObject.ts
  3. 1
      src/types/Types.d.ts

16
src/editor/propEditors/BayEditor.vue

@ -14,6 +14,8 @@ interface DtBay {
bayWidth: number; bayWidth: number;
/** 列偏移 */ /** 列偏移 */
offset: number; offset: number;
/** 列的顶部空间 */
topHeight: number;
/** 每层的高度 */ /** 每层的高度 */
levelHeight: Array<number>; levelHeight: Array<number>;
} }
@ -85,6 +87,7 @@ function applyBasicSettings() {
const bay: DtBay = { const bay: DtBay = {
bayWidth: widthOfBays, bayWidth: widthOfBays,
offset: 0, offset: 0,
topHeight: 0,
levelHeight: [], levelHeight: [],
}; };
for (let i = 0; i < numberOfLevels; i++) { for (let i = 0; i < numberOfLevels; i++) {
@ -124,6 +127,12 @@ function updateBayWidth(bay: DtBay, bayWidth?: number) {
emit("update:modelValue", newValue); 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) { function updateBayOffset(bay: DtBay, offset?: number) {
bay.offset = offset; bay.offset = offset;
const newValue = getModelValue(); const newValue = getModelValue();
@ -227,6 +236,13 @@ export type {
@change="(offset: number) => updateBayOffset(selectDay, offset)" @change="(offset: number) => updateBayOffset(selectDay, offset)"
/> />
</ElFormItem> </ElFormItem>
<ElFormItem label="Bay Top Height" :labelWidth="80">
<ElInputNumber
:controls="false"
:modelValue="selectDay.topHeight"
@change="(height: number) => updateBayTopHeight(selectDay, height)"
/>
</ElFormItem>
</div> </div>
<div>Level Heights</div> <div>Level Heights</div>
<div class="flex-item-fill bay-editor-bay-info-level-height"> <div class="flex-item-fill bay-editor-bay-info-level-height">

17
src/modules/rack/Rack3dObject.ts

@ -25,7 +25,6 @@ export default class Rack3dObject extends THREE.Object3D {
private static rackHorizontalBarGeometryMap: Map<number, BufferGeometry> = new Map<number, BufferGeometry>() private static rackHorizontalBarGeometryMap: Map<number, BufferGeometry> = new Map<number, BufferGeometry>()
private static rackHorizontalBarMaterial: Material = null private static rackHorizontalBarMaterial: Material = null
bottomBarHeight = 0.2
bottomLinkHeight = 0.2 bottomLinkHeight = 0.2
topLinkDistance = 0.2 topLinkDistance = 0.2
@ -297,7 +296,10 @@ export default class Rack3dObject extends THREE.Object3D {
const heights = [] const heights = []
for (let i = 0; i < item.dt.bays.length; i++) { for (let i = 0; i < item.dt.bays.length; i++) {
const bay = item.dt.bays[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) heights.push(bayHeight)
} }
const rackHeight = _.max(heights) 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 }[] = [] const hBarMatrix: { x: number, y: number, z: number, sx: number, sy: number, sz: number, rx: number, ry: number, rz: number, l: number }[] = []
distanceX = 0 distanceX = 0
for (let i = 0; i < item.dt.bays.length; i++) { for (let i = 0; i < item.dt.bays.length; i++) {
distanceY = this.bottomBarHeight
const bay = item.dt.bays[i] const bay = item.dt.bays[i]
for (let j = 0; j < bay.levelHeight.length; j++) { for (let j = 0; j < bay.levelHeight.length; j++) {
const levelHeight = bay.levelHeight[j] const levelHeight = bay.levelHeight[j] - 0.05 // 0.05为横梁自身高度的一半
if (distanceY <= 0) { if (levelHeight <= 0.0) {
continue continue
} }
hBarMatrix.push({ hBarMatrix.push({
x: distanceX - rackWidth / 2, x: distanceX - rackWidth / 2,
y: distanceY, y: levelHeight,
z: -rackDepth / 2, z: -rackDepth / 2,
sx: 1, sx: 1,
sy: 0.8, sy: 0.8,
@ -378,7 +379,7 @@ export default class Rack3dObject extends THREE.Object3D {
}) })
hBarMatrix.push({ hBarMatrix.push({
x: distanceX - rackWidth / 2, x: distanceX - rackWidth / 2,
y: distanceY, y: levelHeight,
z: item.dt.rackDepth - rackDepth / 2, z: item.dt.rackDepth - rackDepth / 2,
sx: 1, sx: 1,
sy: 0.8, sy: 0.8,
@ -388,7 +389,7 @@ export default class Rack3dObject extends THREE.Object3D {
rz: 0, rz: 0,
l: bay.bayWidth l: bay.bayWidth
}) })
distanceY += levelHeight distanceY = levelHeight
} }
distanceX += bay.bayWidth distanceX += bay.bayWidth
} }

1
src/types/Types.d.ts

@ -257,6 +257,7 @@ interface ItemJson extends ItemMetrix {
bays?: { bays?: {
bayWidth: number, bayWidth: number,
topHeight: number,
levelHeight: number[] levelHeight: number[]
}[] }[]

Loading…
Cancel
Save