|
|
@ -1,13 +1,12 @@ |
|
|
import * as THREE from 'three' |
|
|
import * as THREE from 'three' |
|
|
import BaseRenderer from '@/core/base/BaseRenderer.ts' |
|
|
import BaseRenderer from '@/core/base/BaseRenderer.ts' |
|
|
import MoveLinePointPng from '@/assets/images/moveline_point.png' |
|
|
import MoveLinePointPng from '@/assets/images/moveline_point.png' |
|
|
import { getLineId, getMatrixFromTf, linkPlaneByPoint } from '@/core/ModelUtils.ts' |
|
|
import { getLineId, linkPlaneByPoint } from '@/core/ModelUtils.ts' |
|
|
import Constract from '@/core/Constract.ts' |
|
|
import Constract from '@/core/Constract.ts' |
|
|
import InstancePointManager, { PointManageWrap } from '@/core/manager/InstancePointManager.ts' |
|
|
import InstancePointManager, { PointManageWrap } from '@/core/manager/InstancePointManager.ts' |
|
|
import type { Object3DLike } from '@/types/ModelTypes.ts' |
|
|
import type { Object3DLike } from '@/types/ModelTypes.ts' |
|
|
import TriangleUrl from '@/assets/images/conveyor/shapes/triangle.png' |
|
|
import TriangleUrl from '@/assets/images/conveyor/shapes/triangle.png' |
|
|
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial' |
|
|
import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' |
|
|
import LineSegmentManager from '@/core/manager/LineSegmentManager.ts' |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* AGV行走路线渲染器 point 是二维码站点 |
|
|
* AGV行走路线渲染器 point 是二维码站点 |
|
|
@ -136,7 +135,7 @@ export default class WayRenderer extends BaseRenderer { |
|
|
if (object.userData.dirWraps) { |
|
|
if (object.userData.dirWraps) { |
|
|
// 清空之前的箭头
|
|
|
// 清空之前的箭头
|
|
|
object.userData.dirWraps.forEach((uuid: string) => { |
|
|
object.userData.dirWraps.forEach((uuid: string) => { |
|
|
this.dirPointManager.deletePoint(uuid) |
|
|
this.dirPointManager.delete(uuid) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -147,18 +146,20 @@ export default class WayRenderer extends BaseRenderer { |
|
|
|
|
|
|
|
|
} else if (length < 3) { |
|
|
} else if (length < 3) { |
|
|
// 如果两点距离小于 3m,则在中间添加一个方向指示器
|
|
|
// 如果两点距离小于 3m,则在中间添加一个方向指示器
|
|
|
const dirWrap = this.dirPointManager.createPointSimple(object.uuid + '_dir') |
|
|
const dirWrap = this.dirPointManager.create(object.uuid + '_dir') |
|
|
dirWrap.position.setFromMatrixPosition(matrix) |
|
|
|
|
|
dirWrap.rotation.setFromRotationMatrix(matrix) |
|
|
const dummy = new THREE.Object3D() |
|
|
dirWrap.scale.set(0.4, 0.01, 0.2) |
|
|
dummy.position.setFromMatrixPosition(matrix) |
|
|
dirWrap.manager.syncMeshObject3D(dirWrap) |
|
|
dummy.rotation.setFromRotationMatrix(matrix) |
|
|
|
|
|
dummy.scale.set(0.4, 0.01, 0.2) |
|
|
|
|
|
dummy.updateMatrix() |
|
|
|
|
|
dirWrap.setMatrix4(dummy.matrix) |
|
|
object.userData.dirWraps = [dirWrap.uuid] |
|
|
object.userData.dirWraps = [dirWrap.uuid] |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 否则每隔 3m 添加一个方向指示器
|
|
|
// 否则每隔 3m 添加一个方向指示器
|
|
|
for (let i = 0; i < length; i += 3) { |
|
|
for (let i = 0; i < length; i += 3) { |
|
|
const dirWrap = this.dirPointManager.createPointSimple(object.uuid + '_dir_' + i) |
|
|
const dirWrap = this.dirPointManager.create(object.uuid + '_dir_' + i) |
|
|
const position = startPosition.clone().lerp(endPosition, i / length) |
|
|
const position = startPosition.clone().lerp(endPosition, i / length) |
|
|
const dummy = new THREE.Object3D() |
|
|
const dummy = new THREE.Object3D() |
|
|
dummy.position.copy(position) |
|
|
dummy.position.copy(position) |
|
|
@ -166,7 +167,7 @@ export default class WayRenderer extends BaseRenderer { |
|
|
dummy.scale.set(0.4, 0.01, 0.2) |
|
|
dummy.scale.set(0.4, 0.01, 0.2) |
|
|
dummy.updateMatrix() |
|
|
dummy.updateMatrix() |
|
|
|
|
|
|
|
|
dirWrap.applyMatrix4(dummy.matrix) |
|
|
dirWrap.setMatrix4(dummy.matrix) |
|
|
|
|
|
|
|
|
if (!object.userData.dirWraps) { |
|
|
if (!object.userData.dirWraps) { |
|
|
object.userData.dirWraps = [] |
|
|
object.userData.dirWraps = [] |
|
|
@ -185,7 +186,7 @@ export default class WayRenderer extends BaseRenderer { |
|
|
if (object.userData.dirWraps) { |
|
|
if (object.userData.dirWraps) { |
|
|
// 清空之前的箭头
|
|
|
// 清空之前的箭头
|
|
|
object.userData.dirWraps.forEach((uuid: string) => { |
|
|
object.userData.dirWraps.forEach((uuid: string) => { |
|
|
this.dirPointManager.deletePoint(uuid) |
|
|
this.dirPointManager.delete(uuid) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -224,13 +225,13 @@ export default class WayRenderer extends BaseRenderer { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
get dirPointManager(): InstancePointManager { |
|
|
get dirPointManager(): InstanceMeshManager { |
|
|
if (!this.tempViewport) { |
|
|
if (!this.tempViewport) { |
|
|
throw new Error('tempViewport is not set.') |
|
|
throw new Error('tempViewport is not set.') |
|
|
} |
|
|
} |
|
|
return this.tempViewport.getOrCreatePointManager(this.itemTypeName + '_dir', () => |
|
|
return this.tempViewport.getOrCreateMeshManager(this.itemTypeName + '_dir', () => |
|
|
// 构建 InstanceMesh 代理对象
|
|
|
// 构建 InstanceMesh 代理对象
|
|
|
InstancePointManager.create(this.itemTypeName + '_dir', |
|
|
new InstanceMeshManager(this.itemTypeName + '_dir', |
|
|
this.tempViewport, |
|
|
this.tempViewport, |
|
|
this.dirGeometry, |
|
|
this.dirGeometry, |
|
|
this.dirMaterial, |
|
|
this.dirMaterial, |
|
|
|