Browse Source

rack 调整

master
yuliang 6 months ago
parent
commit
56e14ad9e3
  1. 51
      src/example/example1.js
  2. 62
      src/modules/rack/RackRenderer.ts

51
src/example/example1.js

@ -157,7 +157,7 @@ export default {
id: 'rack1',
t: 'rack',
v: true,
tf: [[4.196, 0.1, 5.882], [0, 270, 0], [1, 1, 1]],
tf: [[4.196, 0.1, 5.882], [0, 90, 0], [1, 1, 1]],
dt: {
rackDepth: 1,
rackWidth: 5.1,
@ -168,51 +168,10 @@ export default {
extendColumns: true,
columnSpacing: 1,
bays: [
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4, 1.4, 1.4, 1.4, 1.4] }],
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4] },
{ bayWidth: 1.275, levelHeight: [1.4, 1.4, 1.4] }],
center: [],
in: [],
out: []

62
src/modules/rack/RackRenderer.ts

@ -67,14 +67,14 @@ export default class RackRenderer extends BaseRenderer {
const group = new THREE.Group()
group.name = RackRenderer.POINT_NAME
// const rackWidth = decimalSumBy(item.dt.bays, (b: any) => b.bayWidth)
// const heights = []
// for (let i = 0; i < item.dt.bays.length; i++) {
// const bay = item.dt.bays[i]
// const bayHeight = decimalSumBy(bay.levelHeight)
// heights.push(bayHeight)
// }
// const rackHeight = _.max(heights)
const rackWidth = decimalSumBy(item.dt.bays, (b: any) => b.bayWidth)
const heights = []
for (let i = 0; i < item.dt.bays.length; i++) {
const bay = item.dt.bays[i]
const bayHeight = decimalSumBy(bay.levelHeight)
heights.push(bayHeight)
}
const rackHeight = _.max(heights)
// // 绘制背景矩形框
// const planeGeometry = new THREE.PlaneGeometry(rackWidth, item.dt.rackDepth)
//
@ -131,11 +131,19 @@ export default class RackRenderer extends BaseRenderer {
group.add(mesh)
})
// 设置位置
// group.position.set(item.tf[0][0], item.tf[0][1], item.tf[0][2])
group.position.set(item.tf[0][0], item.tf[0][1], item.tf[0][2])
group.rotation.set(
THREE.MathUtils.degToRad(item.tf[1][0]),
THREE.MathUtils.degToRad(item.tf[1][1]),
THREE.MathUtils.degToRad(item.tf[1][2])
)
//
// item.dt.rackWidth = rackWidth
// item.dt.rackHeight = rackHeight
item.dt.rackWidth = rackWidth
item.dt.rackHeight = rackHeight
return group
}
@ -442,6 +450,8 @@ export default class RackRenderer extends BaseRenderer {
z: item.tf[0][2]
}
const rackWidth = decimalSumBy(item.dt.bays, (b: any) => b.bayWidth)
const rackDepth = item.dt.rackDepth
const heights = []
for (let i = 0; i < item.dt.bays.length; i++) {
const bay = item.dt.bays[i]
@ -464,9 +474,9 @@ export default class RackRenderer extends BaseRenderer {
distanceX += bay.bayWidth
}
vBarMatrix.push({
x: rackPoint.x + distanceX,
y: rackPoint.y,
z: rackPoint.z,
x: distanceX - rackWidth/2,
y: 0,
z: -rackDepth/2,
sx: 0.8,
sy: 1,
sz: 1,
@ -476,9 +486,9 @@ export default class RackRenderer extends BaseRenderer {
l: rackHeight
})
vBarMatrix.push({
x: rackPoint.x + distanceX,
y: rackPoint.y,
z: rackPoint.z + item.dt.rackDepth,
x: distanceX - rackWidth/2,
y: 0,
z: item.dt.rackDepth - rackDepth/2,
sx: 0.8,
sy: 1,
sz: 1,
@ -488,9 +498,9 @@ export default class RackRenderer extends BaseRenderer {
l: rackHeight
})
linkBarMatrix.push({
x: rackPoint.x + distanceX,
y: rackPoint.y,
z: i % 2 == 0 ? (rackPoint.z + item.dt.rackDepth) : rackPoint.z,
x: distanceX - rackWidth/2,
y: 0,
z: i % 2 == 0 ? (item.dt.rackDepth - rackDepth/2) : -rackDepth/2,
sx: 1,
sy: 1,
sz: 1,
@ -513,9 +523,9 @@ export default class RackRenderer extends BaseRenderer {
continue
}
hBarMatrix.push({
x: rackPoint.x + distanceX,
y: rackPoint.y + distanceY,
z: rackPoint.z,
x: distanceX - rackWidth/2,
y: distanceY,
z: -rackDepth/2,
sx: 1,
sy: 0.8,
sz: 1,
@ -525,9 +535,9 @@ export default class RackRenderer extends BaseRenderer {
l: bay.bayWidth
})
hBarMatrix.push({
x: rackPoint.x + distanceX,
y: rackPoint.y + distanceY,
z: rackPoint.z + item.dt.rackDepth,
x: distanceX - rackWidth/2,
y: distanceY,
z: item.dt.rackDepth-rackDepth/2,
sx: 1,
sy: 0.8,
sz: 1,

Loading…
Cancel
Save