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', id: 'rack1',
t: 'rack', t: 'rack',
v: true, 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: { dt: {
rackDepth: 1, rackDepth: 1,
rackWidth: 5.1, rackWidth: 5.1,
@ -168,51 +168,10 @@ export default {
extendColumns: true, extendColumns: true,
columnSpacing: 1, columnSpacing: 1,
bays: [ 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] },
{ 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, 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, 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, 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] }],
center: [], center: [],
in: [], in: [],
out: [] out: []

62
src/modules/rack/RackRenderer.ts

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

Loading…
Cancel
Save