|
|
@ -10,6 +10,7 @@ import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' |
|
|
import LineSegmentManager from '@/core/manager/LineSegmentManager.ts' |
|
|
import LineSegmentManager from '@/core/manager/LineSegmentManager.ts' |
|
|
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial' |
|
|
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial' |
|
|
import { getRenderer } from '@/core/manager/ModuleManager.ts' |
|
|
import { getRenderer } from '@/core/manager/ModuleManager.ts' |
|
|
|
|
|
import chargerUrl from '@/assets/images/ptr/charger.png' |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* AGV行走路线渲染器 point 是二维码站点 |
|
|
* AGV行走路线渲染器 point 是二维码站点 |
|
|
@ -17,7 +18,7 @@ import { getRenderer } from '@/core/manager/ModuleManager.ts' |
|
|
export default class WayRenderer extends BaseRenderer { |
|
|
export default class WayRenderer extends BaseRenderer { |
|
|
static LABEL_NAME = 'way_label' |
|
|
static LABEL_NAME = 'way_label' |
|
|
static POINT_NAME = 'way_point' |
|
|
static POINT_NAME = 'way_point' |
|
|
static LINE_NAME = 'way_line' |
|
|
static CHARGER_POINT_NAME = 'charger' |
|
|
static GUIDEWAY_LINE_NAME = 'guideway' |
|
|
static GUIDEWAY_LINE_NAME = 'guideway' |
|
|
static RED_LINE_NAME = 'red_line' |
|
|
static RED_LINE_NAME = 'red_line' |
|
|
|
|
|
|
|
|
@ -42,6 +43,7 @@ export default class WayRenderer extends BaseRenderer { |
|
|
dirGeometry: THREE.PlaneGeometry |
|
|
dirGeometry: THREE.PlaneGeometry |
|
|
dirMaterial: THREE.Material |
|
|
dirMaterial: THREE.Material |
|
|
dir2Material: THREE.Material |
|
|
dir2Material: THREE.Material |
|
|
|
|
|
chargerMaterial: THREE.Material |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 默认点的高度, 防止和地面重合 |
|
|
* 默认点的高度, 防止和地面重合 |
|
|
@ -58,13 +60,18 @@ export default class WayRenderer extends BaseRenderer { |
|
|
super.init(), |
|
|
super.init(), |
|
|
new THREE.TextureLoader().loadAsync(MoveLinePointPng), |
|
|
new THREE.TextureLoader().loadAsync(MoveLinePointPng), |
|
|
new THREE.TextureLoader().loadAsync(TriangleUrl), |
|
|
new THREE.TextureLoader().loadAsync(TriangleUrl), |
|
|
new THREE.TextureLoader().loadAsync(Triangle2Url) |
|
|
new THREE.TextureLoader().loadAsync(Triangle2Url), |
|
|
|
|
|
new THREE.TextureLoader().loadAsync(chargerUrl) |
|
|
|
|
|
|
|
|
]).then(([_, texture, dirTexture, dir2Texture]) => { |
|
|
]).then(([_, texture, dirTexture, dir2Texture, chargerTexture]) => { |
|
|
texture.flipY = false |
|
|
texture.flipY = false |
|
|
|
|
|
|
|
|
this.pointGeometry = new THREE.PlaneGeometry(1, 1).rotateX(-Math.PI / 2) |
|
|
this.pointGeometry = new THREE.PlaneGeometry(1, 1).rotateX(-Math.PI / 2) |
|
|
this.pointGeometry.center() |
|
|
this.pointGeometry.center() |
|
|
|
|
|
this.chargerMaterial = new THREE.MeshLambertMaterial({ |
|
|
|
|
|
map: chargerTexture, // 颜色贴图
|
|
|
|
|
|
transparent: true // 允许透明纹理
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.pointMaterial = new THREE.MeshBasicMaterial({ |
|
|
this.pointMaterial = new THREE.MeshBasicMaterial({ |
|
|
map: texture, |
|
|
map: texture, |
|
|
@ -98,16 +105,35 @@ export default class WayRenderer extends BaseRenderer { |
|
|
|
|
|
|
|
|
createPointBasic(item: ItemJson, option?: RendererCudOption): Object3DLike { |
|
|
createPointBasic(item: ItemJson, option?: RendererCudOption): Object3DLike { |
|
|
// 不允许改变高度/角度/大小
|
|
|
// 不允许改变高度/角度/大小
|
|
|
item.tf = [ |
|
|
if (item.dt.isCharger) { |
|
|
[item.tf[0][0], this.defulePositionY, item.tf[0][2]], |
|
|
return this.createCharger(item) |
|
|
[this.defaultRotation.x, this.defaultRotation.y, this.defaultRotation.z], |
|
|
|
|
|
[this.defaultScale.x, this.defaultScale.y, this.defaultScale.z] |
|
|
} else { |
|
|
] |
|
|
item.tf = [ |
|
|
return this.pointManager.createByItem(item) |
|
|
[item.tf[0][0], this.defulePositionY, item.tf[0][2]], |
|
|
|
|
|
[this.defaultRotation.x, this.defaultRotation.y, this.defaultRotation.z], |
|
|
|
|
|
[this.defaultScale.x, this.defaultScale.y, this.defaultScale.z] |
|
|
|
|
|
] |
|
|
|
|
|
return this.pointManager.createByItem(item) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private createCharger(item: ItemJson) { |
|
|
|
|
|
// 创建平面几何体
|
|
|
|
|
|
const group = new THREE.Group() |
|
|
|
|
|
group.name = WayRenderer.CHARGER_POINT_NAME |
|
|
|
|
|
|
|
|
|
|
|
// 绘制背景矩形框
|
|
|
|
|
|
const planeGeometry = new THREE.PlaneGeometry(item.dt.chargerWidth, item.dt.chargerDepth) |
|
|
|
|
|
planeGeometry.rotateX(-Math.PI / 2) |
|
|
|
|
|
const planeMesh = new THREE.Mesh(planeGeometry, this.chargerMaterial) |
|
|
|
|
|
group.add(planeMesh) |
|
|
|
|
|
|
|
|
|
|
|
return group |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
createLine(start: ItemJson, end: ItemJson, type: LinkType): Object3DLike { |
|
|
createLine(start: ItemJson, end: ItemJson, type: LinkType): Object3DLike { |
|
|
if (start.t === this.itemTypeName && end.t === this.itemTypeName) { |
|
|
if ((start.t === this.itemTypeName) && end.t === this.itemTypeName) { |
|
|
return this._createOrUpdateGuideway(start, end, type) |
|
|
return this._createOrUpdateGuideway(start, end, type) |
|
|
} else { |
|
|
} else { |
|
|
// throw new Error('目前只支持二维码站点之间的连接')
|
|
|
// throw new Error('目前只支持二维码站点之间的连接')
|
|
|
@ -260,6 +286,9 @@ export default class WayRenderer extends BaseRenderer { |
|
|
*/ |
|
|
*/ |
|
|
afterCreateOrUpdatePoint(item: ItemJson, option: RendererCudOption, object: Object3DLike) { |
|
|
afterCreateOrUpdatePoint(item: ItemJson, option: RendererCudOption, object: Object3DLike) { |
|
|
super.afterCreateOrUpdatePoint(item, option, object) |
|
|
super.afterCreateOrUpdatePoint(item, option, object) |
|
|
|
|
|
if (item.dt.isCharger) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 创建一个 id 标签
|
|
|
// 创建一个 id 标签
|
|
|
this.tempViewport.labelManager.createOrUpdateMeshLabel(object, '' + item.id, { |
|
|
this.tempViewport.labelManager.createOrUpdateMeshLabel(object, '' + item.id, { |
|
|
|