From 1930a52581c2189e0a929985d14bd67ec96f7988 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期三, 24 四月 2024 15:25:57 +0800 Subject: [PATCH] # --- src/utils/common.js | 9 +++++++++ src/config/setting.js | 8 +++++++- src/assets/data/shelf.js | 22 ++++++++-------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/assets/data/shelf.js b/src/assets/data/shelf.js index 4170eb0..9896f71 100644 --- a/src/assets/data/shelf.js +++ b/src/assets/data/shelf.js @@ -1,45 +1,39 @@ -// row +import * as Common from '@/utils/common'; +// row // bay const realBayPos = [1589, 3540, 5491, 7442, 9393, 11344]; -const mapBayMaxAbs = 500; - -const calBayMapPos = (realPosition, minRealPosition = Math.min(...realBayPos), maxRealPosition = Math.max(...realBayPos), maxMapPosition = mapBayMaxAbs) => { - return ((realPosition - minRealPosition) / (maxRealPosition - minRealPosition)) * (2 * maxMapPosition) - maxMapPosition; -} - -console.log(Math.max(...realBayPos)); const shelfData = [ { no: '3-1-1', - position: [0, 0, calBayMapPos(realBayPos[5])], + position: Common.calculateMappedPosition([0, 0, realBayPos[5]]), rotationY: Math.PI / 2, }, { no: '3-4-1', - position: [0, 0, calBayMapPos(realBayPos[4])], + position: Common.calculateMappedPosition([0, 0, realBayPos[4]]), rotationY: Math.PI / 2, }, { no: '3-7-1', - position: [0, 0, calBayMapPos(realBayPos[3])], + position: Common.calculateMappedPosition([0, 0, realBayPos[3]]), rotationY: Math.PI / 2, }, { no: '3-10-1', - position: [0, 0, calBayMapPos(realBayPos[2])], + position: Common.calculateMappedPosition([0, 0, realBayPos[2]]), rotationY: Math.PI / 2, }, { no: '3-13-1', - position: [0, 0, calBayMapPos(realBayPos[1])], + position: Common.calculateMappedPosition([0, 0, realBayPos[1]]), rotationY: Math.PI / 2, }, { no: '3-16-1', - position: [0, 0, calBayMapPos(realBayPos[0])], + position: Common.calculateMappedPosition([0, 0, realBayPos[0]]), rotationY: Math.PI / 2, }, ]; diff --git a/src/config/setting.js b/src/config/setting.js index b37e7f6..0495e01 100644 --- a/src/config/setting.js +++ b/src/config/setting.js @@ -12,4 +12,10 @@ export const MODEL_BOX_SCALE = .5; -export const MODEL_SHELF_SCALE = 1; \ No newline at end of file +export const MODEL_SHELF_SCALE = 1; + +export const REAL_COMPARE_MAP_SCALE = .1; + +export const REAL_COMPARE_MAP_OFFSET_X = -200; + +export const REAL_COMPARE_MAP_OFFSET_Z = -400; \ No newline at end of file diff --git a/src/utils/common.js b/src/utils/common.js index 01b74cc..5c5c8df 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -1,4 +1,5 @@ import * as THREE from 'three'; +import { REAL_COMPARE_MAP_SCALE, REAL_COMPARE_MAP_OFFSET_X, REAL_COMPARE_MAP_OFFSET_Z } from '../config/setting' export const isNullOfUndefined = (param) => { if (null === param || undefined === param) { @@ -27,6 +28,14 @@ return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta; } +export const calculateMappedPosition = (realPos) => { + return [ + realPos[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X, + realPos[1], + realPos[2] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_Z + ]; +}; + export const setShadow = (obj) => { obj.castShadow = true; obj.receiveShadow = true; -- Gitblit v1.9.1