|
@@ -78,7 +78,8 @@ const props = withDefaults(defineProps<{
|
|
|
}),
|
|
}),
|
|
|
mapConfig: () => ({
|
|
mapConfig: () => ({
|
|
|
cameraP: { X: 0, Y: 0, Z: 18 },
|
|
cameraP: { X: 0, Y: 0, Z: 18 },
|
|
|
- isRotate: true
|
|
|
|
|
|
|
+ isRotate: true,
|
|
|
|
|
+ contrlLeft: true
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
const leng = [
|
|
const leng = [
|
|
@@ -237,6 +238,66 @@ function createExceedBreakPoint(designArr: [], breakArr: [], position = { x: -2.
|
|
|
return group
|
|
return group
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 创建网格坐标
|
|
|
|
|
+function createGridding() {
|
|
|
|
|
+ const geometry = new threeService.THREE.BufferGeometry() // geometry为三维空间中的点集同点集闭合后的各个面的集合
|
|
|
|
|
+ // 在x轴上定义两个点p1(-500,0,0),p2(500,0,0)。
|
|
|
|
|
+ const vertices = new Float32Array([
|
|
|
|
|
+ -7, 0, 0,
|
|
|
|
|
+ 7, 0, 0
|
|
|
|
|
+ ])
|
|
|
|
|
+ geometry.setAttribute('position', new threeService.THREE.BufferAttribute(vertices, 3))
|
|
|
|
|
+ const group = new threeService.THREE.Group()
|
|
|
|
|
+ for (let i = 0; i <= 10; i++) {
|
|
|
|
|
+ const linex = new threeService.THREE.Line(geometry, new threeService.THREE.LineBasicMaterial({ color: '#ccc', opacity: 0.5 }))
|
|
|
|
|
+ linex.position.z = (i * 1.4) - 7 // 7/(10/2)
|
|
|
|
|
+ const liney = new threeService.THREE.Line(geometry, new threeService.THREE.LineBasicMaterial({ color: '#ccc', opacity: 0.5 }))
|
|
|
|
|
+ liney.position.x = (i * 1.4) - 7 // 7/(10/2)
|
|
|
|
|
+ liney.rotation.y = Math.PI / 2 // 将线旋转90度
|
|
|
|
|
+ group.add(linex, liney)
|
|
|
|
|
+ }
|
|
|
|
|
+ group.rotation.x = Math.PI / 2
|
|
|
|
|
+ return group
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 创建超欠挖线
|
|
|
|
|
+function createExceedBreakLine(arr: { x: number, y: number, z: number }[], color: string, position = { x: 0, y: -1.5, z: 0 }) {
|
|
|
|
|
+ const group = new threeService.THREE.Group()
|
|
|
|
|
+ const material = new threeService.THREE.LineBasicMaterial({ color })
|
|
|
|
|
+ const points = arr.map((el) => (new threeService.THREE.Vector3(el.x, el.y, el.z)))
|
|
|
|
|
+ const geometry = new threeService.THREE.BufferGeometry().setFromPoints(points)
|
|
|
|
|
+ const line = new threeService.THREE.Line(geometry, material)
|
|
|
|
|
+ group.position.set(position.x, position.y, position.z)
|
|
|
|
|
+ group.add(line)
|
|
|
|
|
+ return group
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 创建3D文字+对应点
|
|
|
|
|
+function create3DLabel(point: { x: number; y: number; z: number; txt: string; r: number; c: string }[], position = { x: 0, y: -1.5, z: 0 }, size = 1.2, showPoint = true) {
|
|
|
|
|
+ const group = new threeService.THREE.Group()
|
|
|
|
|
+ for (let k = 0; k < point.length; k++) {
|
|
|
|
|
+ const item = point[k]
|
|
|
|
|
+ const canvas = document.createElement('canvas')
|
|
|
|
|
+ const context = canvas.getContext('2d')
|
|
|
|
|
+ context!.font = `${size * 50}px Arial`
|
|
|
|
|
+ context!.fillStyle = 'white'
|
|
|
|
|
+ context!.fillText(item.txt, 170, 100)
|
|
|
|
|
+ const texture = new threeService.THREE.CanvasTexture(canvas)
|
|
|
|
|
+ const material = new threeService.THREE.SpriteMaterial({ map: texture, rotation: item.r })
|
|
|
|
|
+ const sprite = new threeService.THREE.Sprite(material)
|
|
|
|
|
+ sprite.scale.set(size, size * 0.5, 1)
|
|
|
|
|
+ // sprite.center.set(0.1, 0.1)
|
|
|
|
|
+ sprite.position.set(item.x, item.y, item.z)
|
|
|
|
|
+ group.add(sprite)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (showPoint) {
|
|
|
|
|
+ const points = createPoint(point, { x: 0, y: 0, z: 0 }, 0.05)
|
|
|
|
|
+ group.add(points)
|
|
|
|
|
+ }
|
|
|
|
|
+ group.position.set(position.x, position.y, position.z)
|
|
|
|
|
+ return group
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 添加obj
|
|
// 添加obj
|
|
|
function addOBJ() {
|
|
function addOBJ() {
|
|
|
if (!threeService.scene) return
|
|
if (!threeService.scene) return
|
|
@@ -386,14 +447,17 @@ function addOBJ() {
|
|
|
}
|
|
}
|
|
|
// 超欠挖点图
|
|
// 超欠挖点图
|
|
|
if (props.holeConfig.show === 7) {
|
|
if (props.holeConfig.show === 7) {
|
|
|
- const designArr = props.holeConfig.data[0].map((el: number[]) => ({
|
|
|
|
|
- x: el[0], y: el[1], z: 0, c: '#33D7FF'
|
|
|
|
|
- })) || []
|
|
|
|
|
|
|
+ const designArr = props.holeConfig.data[0].map((el: number[]) => ({ x: +el[0], y: +el[1], z: 0 })) || []
|
|
|
const breakArr = props.holeConfig.data[1].map((el: number[]) => ({
|
|
const breakArr = props.holeConfig.data[1].map((el: number[]) => ({
|
|
|
- x: el[0], y: el[1], z: 0, c: el[3] > 0 ? '#2F3CFC' : '#BB343B'
|
|
|
|
|
|
|
+ x: +el[0] || 0, y: +el[1] || 0, z: 0, txt: Math.floor(+el[3] * 100) / 100 || 0, c: '#BB343B'
|
|
|
})) || []
|
|
})) || []
|
|
|
- const group = createExceedBreakPoint(designArr, breakArr, props.holeConfig.position)
|
|
|
|
|
- threeService.scene.add(group)
|
|
|
|
|
|
|
+ if (!designArr.length || !breakArr.length) return
|
|
|
|
|
+ const num = 36 // 抽取36个点/角度平均分布
|
|
|
|
|
+ const breakArrText = threeService.splitArray(breakArr, num).map((el:{x: number; y: number; z: number; txt: string; r: number; c: string;}[], index) => ({ ...el[0], r: index * (Math.PI / num) }))
|
|
|
|
|
+ const designLine = createExceedBreakLine(designArr, '#33D7FF')
|
|
|
|
|
+ const breakLine = createExceedBreakLine(breakArr.concat(breakArr[0]), '#BB343B')
|
|
|
|
|
+ const textGroup = create3DLabel(breakArrText)
|
|
|
|
|
+ threeService.scene.add(designLine, breakLine, textGroup)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|