|  |  |  | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const rotationParseNum = (num) => { | 
|---|
|  |  |  | const normalizedDegrees = num % 360; | 
|---|
|  |  |  | const normalizedDegrees = positiveAngle(num); | 
|---|
|  |  |  | return normalizedDegrees * Math.PI / 180; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const minDiffTheta = (originTheta, targetTheta) => { | 
|---|
|  |  |  | return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const positiveAngle = (angle) => { | 
|---|
|  |  |  | return ((angle % 360) + 360) % 360; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const normalizeAngle = (angle) => { | 
|---|
|  |  |  | let newAngle = angle % 360; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (newAngle < -180) { | 
|---|
|  |  |  | newAngle += 360; | 
|---|
|  |  |  | } else if (newAngle > 180) { | 
|---|
|  |  |  | newAngle -= 360; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return newAngle; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const setColor = (obj) => { | 
|---|
|  |  |  | export const setColor = (obj, color = 0x4680BF) => { | 
|---|
|  |  |  | if (obj.material) { | 
|---|
|  |  |  | obj.material.color.set(0x4680BF); | 
|---|
|  |  |  | obj.material.color.set(color); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (obj.children) { | 
|---|
|  |  |  | obj.children.forEach((child) => { | 
|---|
|  |  |  | setColor(child); | 
|---|
|  |  |  | setColor(child, color); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const parseLocNo = (locNo) => { | 
|---|
|  |  |  | if (!locNo || typeof locNo !== 'string') { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | const locParseArr = locNo.split('-'); | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | row: Number(locParseArr?.[0]), | 
|---|
|  |  |  | bay: Number(locParseArr?.[1]), | 
|---|
|  |  |  | lev: Number(locParseArr?.[2]), | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const generateLocNo = (row, bay, lev) => { | 
|---|
|  |  |  | return row + '-' + bay + '-' + lev; | 
|---|
|  |  |  | } | 
|---|