Browse Source

CLX 完成

master
修宁 6 months ago
parent
commit
8d71367455
  1. 12
      src/core/base/BaseItemEntity.ts
  2. 3
      src/core/script/ModelManager.ts
  3. 2
      src/modules/carton/CartonRenderer.ts
  4. 230
      src/modules/clx/Clx3dObject.ts
  5. 88
      src/modules/clx/ClxEntity.ts
  6. 20
      src/modules/pallet/PalletRenderer.ts
  7. 4
      src/modules/rack/RackRenderer.ts
  8. 4
      src/modules/shuttle_rack/ShuttleRackRenderer.ts
  9. 2
      src/modules/tote/ToteRenderer.ts
  10. 4
      src/modules/way/WayRenderer.ts

12
src/core/base/BaseItemEntity.ts

@ -34,10 +34,16 @@ export default abstract class BaseEntity implements EntityIf, Loadable, Carry, W
} }
// 帮助方法:获取机械臂对象 // 帮助方法:获取机械臂对象
abstract getArmObject(): THREE.Object3D | undefined getArmObject(): THREE.Object3D | undefined {
console.error('getArmObject 方法未实现')
return undefined
}
// 帮助方法:获取机械臂立柱 // 帮助方法:获取机械臂立柱
abstract getArmPillar(): THREE.Object3D | undefined getArmPillar(): THREE.Object3D | undefined {
console.error('getArmPillar 方法未实现')
return undefined
}
// 待执行任务总数 // 待执行任务总数
get taskCount(): number { get taskCount(): number {
@ -116,7 +122,7 @@ export default abstract class BaseEntity implements EntityIf, Loadable, Carry, W
} }
// 伸 // 伸
addArmExtender(): void { addArmExtender(z: number = 1.3): void {
this.taskQueue.add(this.createTask('ARM_EXTEND', async () => { this.taskQueue.add(this.createTask('ARM_EXTEND', async () => {
return new Promise(resolve => { return new Promise(resolve => {
const pillar = this.getArmPillar() const pillar = this.getArmPillar()

3
src/core/script/ModelManager.ts

@ -5,6 +5,7 @@ import { getMatrixFromTf } from '@/core/ModelUtils.ts'
import type { Object3DLike } from '@/types/ModelTypes.ts' import type { Object3DLike } from '@/types/ModelTypes.ts'
import TaskManager from '../manager/TaskManager.ts' import TaskManager from '../manager/TaskManager.ts'
import Cl2Entity from '@/modules/cl2/Cl2Entity.ts' import Cl2Entity from '@/modules/cl2/Cl2Entity.ts'
import ClxEntity from '@/modules/clx/ClxEntity.ts'
export default class ModelManager implements IControls, Model { export default class ModelManager implements IControls, Model {
private viewport: Viewport private viewport: Viewport
@ -14,7 +15,7 @@ export default class ModelManager implements IControls, Model {
} }
getClx(id: string): ClxIf { getClx(id: string): ClxIf {
throw new Error('Method not implemented.') return new ClxEntity(this.viewport, id)
} }
createTask(agv: object): TaskManager { createTask(agv: object): TaskManager {

2
src/modules/carton/CartonRenderer.ts

@ -3,7 +3,7 @@ import BaseRenderer from '@/core/base/BaseRenderer.ts'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.ts'
import type { Object3DLike } from '@/types/ModelTypes.ts' import type { Object3DLike } from '@/types/ModelTypes.ts'
import MODULE_GLB_File from '@/assets/Models/carton.glb?url' import MODULE_GLB_File from '@/assets/Models/carton.glb?url'
import MODULE_3DS_TEX from '@/assets/Models/carton.jpg?url' import MODULE_3DS_TEX from '@/assets/Models/carton.jpg?inline'
import { loadGlbModule, loadTexture, processModel } from '@/core/ModelUtils.ts' import { loadGlbModule, loadTexture, processModel } from '@/core/ModelUtils.ts'
import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts'

230
src/modules/clx/Clx3dObject.ts

@ -1,5 +1,5 @@
import * as THREE from "three"; import * as THREE from 'three'
import {CSG} from "three-csg-ts"; import { CSG } from 'three-csg-ts'
import gsap from 'gsap' import gsap from 'gsap'
//@ts-ignore //@ts-ignore
import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js' import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js'
@ -15,26 +15,26 @@ export default class Clx3dObject extends THREE.Object3D {
const dd = 0.05 const dd = 0.05
const bd = 0.175 const bd = 0.175
const shape = new THREE.Shape(); const shape = new THREE.Shape()
shape.moveTo(-width/2, -depth/2 + bd); shape.moveTo(-width / 2, -depth / 2 + bd)
shape.lineTo(-width/2 + bd, -depth/2); shape.lineTo(-width / 2 + bd, -depth / 2)
shape.lineTo(width/2 - bd, -depth/2); shape.lineTo(width / 2 - bd, -depth / 2)
shape.lineTo(width/2, -depth/2 + bd); shape.lineTo(width / 2, -depth / 2 + bd)
shape.lineTo(width/2, -0.285); shape.lineTo(width / 2, -0.285)
shape.lineTo(-0.475, -0.285); shape.lineTo(-0.475, -0.285)
shape.lineTo(-0.475, -0.125); shape.lineTo(-0.475, -0.125)
shape.lineTo(width/2, -0.125); shape.lineTo(width / 2, -0.125)
shape.lineTo(width/2, 0.125); shape.lineTo(width / 2, 0.125)
shape.lineTo(-0.475, 0.125); shape.lineTo(-0.475, 0.125)
shape.lineTo(-0.475, 0.285); shape.lineTo(-0.475, 0.285)
shape.lineTo(width/2, 0.285); shape.lineTo(width / 2, 0.285)
shape.lineTo(width/2, depth/2 - bd); shape.lineTo(width / 2, depth / 2 - bd)
shape.lineTo(width/2 - bd, depth/2); shape.lineTo(width / 2 - bd, depth / 2)
shape.lineTo(-width/2 + bd, depth/2); shape.lineTo(-width / 2 + bd, depth / 2)
shape.lineTo(-width/2, depth/2 - bd); shape.lineTo(-width / 2, depth / 2 - bd)
shape.closePath(); // 闭合路径 shape.closePath() // 闭合路径
// 拉伸轨迹线 // 拉伸轨迹线
const curve = new THREE.CatmullRomCurve3( const curve = new THREE.CatmullRomCurve3(
@ -52,26 +52,26 @@ export default class Clx3dObject extends THREE.Object3D {
} }
// 创建挤出几何体 // 创建挤出几何体
const geometry = new THREE.ExtrudeGeometry(shape, options) const geometry = new THREE.ExtrudeGeometry(shape, options)
const material = new THREE.MeshBasicMaterial({color: 0xffdddbca}); const material = new THREE.MeshBasicMaterial({ color: 0xffdddbca })
const mesh = new THREE.Mesh(geometry, material); const mesh = new THREE.Mesh(geometry, material)
mesh.updateMatrix() mesh.updateMatrix()
// 倒角 // 倒角
const shapeD = new THREE.Shape(); const shapeD = new THREE.Shape()
shapeD.moveTo(-0.02, -0.02); shapeD.moveTo(-0.02, -0.02)
shapeD.lineTo(0.02, 0.02) shapeD.lineTo(0.02, 0.02)
shapeD.lineTo(-0.02, 0.02) shapeD.lineTo(-0.02, 0.02)
shapeD.closePath() shapeD.closePath()
const shapeDW = new THREE.Shape(); const shapeDW = new THREE.Shape()
shapeDW.moveTo(0.02, -0.02); shapeDW.moveTo(0.02, -0.02)
shapeDW.lineTo(0.02, 0.02) shapeDW.lineTo(0.02, 0.02)
shapeDW.lineTo(-0.02, 0.02) shapeDW.lineTo(-0.02, 0.02)
shapeDW.closePath() shapeDW.closePath()
const shapeDW1 = new THREE.Shape(); const shapeDW1 = new THREE.Shape()
shapeDW1.moveTo(-0.02, -0.02); shapeDW1.moveTo(-0.02, -0.02)
shapeDW1.lineTo(0.02, -0.02) shapeDW1.lineTo(0.02, -0.02)
shapeDW1.lineTo(-0.02, 0.02) shapeDW1.lineTo(-0.02, 0.02)
shapeDW1.closePath() shapeDW1.closePath()
@ -101,7 +101,7 @@ export default class Clx3dObject extends THREE.Object3D {
steps: 1, steps: 1,
bevelEnabled: false, bevelEnabled: false,
extrudePath: curveD extrudePath: curveD
}; }
let geometryD: THREE.BufferGeometry = null let geometryD: THREE.BufferGeometry = null
if (i == 1) { if (i == 1) {
geometryD = new THREE.ExtrudeGeometry(shapeDW, optionsD) geometryD = new THREE.ExtrudeGeometry(shapeDW, optionsD)
@ -110,7 +110,7 @@ export default class Clx3dObject extends THREE.Object3D {
} else { } else {
geometryD = new THREE.ExtrudeGeometry(shapeD, optionsD) geometryD = new THREE.ExtrudeGeometry(shapeD, optionsD)
} }
const meshD = new THREE.Mesh(geometryD, material); const meshD = new THREE.Mesh(geometryD, material)
meshD.updateMatrix() meshD.updateMatrix()
result = CSG.subtract(result, meshD) result = CSG.subtract(result, meshD)
} }
@ -123,21 +123,21 @@ export default class Clx3dObject extends THREE.Object3D {
const width = 0.3 const width = 0.3
const depth = 1.188 const depth = 1.188
const dd = 0.05 const dd = 0.05
const shape = new THREE.Shape(); const shape = new THREE.Shape()
shape.moveTo(-0.744, -0.594 + dd); shape.moveTo(-0.744, -0.594 + dd)
shape.lineTo(-0.744 + dd, -0.594); shape.lineTo(-0.744 + dd, -0.594)
shape.lineTo(-0.744 + width - dd, -0.594); shape.lineTo(-0.744 + width - dd, -0.594)
shape.lineTo(-0.744 + width, -0.594 + dd); shape.lineTo(-0.744 + width, -0.594 + dd)
shape.lineTo(-0.744 + width, -0.4); shape.lineTo(-0.744 + width, -0.4)
shape.lineTo(-0.744 + width - 0.08, -0.4); shape.lineTo(-0.744 + width - 0.08, -0.4)
shape.lineTo(-0.744 + width - 0.08, 0.4); shape.lineTo(-0.744 + width - 0.08, 0.4)
shape.lineTo(-0.744 + width, 0.4); shape.lineTo(-0.744 + width, 0.4)
shape.lineTo(-0.744 + width, -0.594 + depth - dd); shape.lineTo(-0.744 + width, -0.594 + depth - dd)
shape.lineTo(-0.744 + width - dd, -0.594 + depth); shape.lineTo(-0.744 + width - dd, -0.594 + depth)
shape.lineTo(-0.744 + dd, -0.594 + depth); shape.lineTo(-0.744 + dd, -0.594 + depth)
shape.lineTo(-0.744, -0.594 + depth - dd); shape.lineTo(-0.744, -0.594 + depth - dd)
// shape.lineTo(-0.728, -0.594 + dd); // shape.lineTo(-0.728, -0.594 + dd);
// shape.closePath() // shape.closePath()
@ -171,24 +171,24 @@ export default class Clx3dObject extends THREE.Object3D {
const dd = 0.05 const dd = 0.05
const fdx = 0.06 const fdx = 0.06
const fdy = 0.03 const fdy = 0.03
const shape = new THREE.Shape(); const shape = new THREE.Shape()
shape.moveTo(-0.744 + width - 0.08, -0.4); shape.moveTo(-0.744 + width - 0.08, -0.4)
shape.lineTo(-0.744 + width + 0.02, -0.4); shape.lineTo(-0.744 + width + 0.02, -0.4)
shape.lineTo(-0.744 + width + 0.02, -0.275); shape.lineTo(-0.744 + width + 0.02, -0.275)
shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, -0.275); shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, -0.275)
shape.lineTo(-0.744 + width + 0.02 + 1.24, -0.275 + fdy); shape.lineTo(-0.744 + width + 0.02 + 1.24, -0.275 + fdy)
shape.lineTo(-0.744 + width + 0.02 + 1.24, -0.135 - fdy); shape.lineTo(-0.744 + width + 0.02 + 1.24, -0.135 - fdy)
shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, -0.135); shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, -0.135)
shape.lineTo(-0.744 + width + 0.02, -0.135); shape.lineTo(-0.744 + width + 0.02, -0.135)
shape.lineTo(-0.744 + width + 0.02, 0.135); shape.lineTo(-0.744 + width + 0.02, 0.135)
shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, 0.135); shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, 0.135)
shape.lineTo(-0.744 + width + 0.02 + 1.24, 0.135 + fdy); shape.lineTo(-0.744 + width + 0.02 + 1.24, 0.135 + fdy)
shape.lineTo(-0.744 + width + 0.02 + 1.24, 0.275 - fdy); shape.lineTo(-0.744 + width + 0.02 + 1.24, 0.275 - fdy)
shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, 0.275); shape.lineTo(-0.744 + width + 0.02 + 1.24 - fdx, 0.275)
shape.lineTo(-0.744 + width + 0.02, 0.275); shape.lineTo(-0.744 + width + 0.02, 0.275)
shape.lineTo(-0.744 + width + 0.02, 0.4); shape.lineTo(-0.744 + width + 0.02, 0.4)
shape.lineTo(-0.744 + width - 0.08, 0.4); shape.lineTo(-0.744 + width - 0.08, 0.4)
shape.closePath() shape.closePath()
@ -209,17 +209,17 @@ export default class Clx3dObject extends THREE.Object3D {
} }
// 创建挤出几何体 // 创建挤出几何体
const geometry = new THREE.ExtrudeGeometry(shape, options) const geometry = new THREE.ExtrudeGeometry(shape, options)
const material = new THREE.MeshBasicMaterial({color: 0xffdddbca}); const material = new THREE.MeshBasicMaterial({ color: 0xffdddbca })
const mesh = new THREE.Mesh(geometry, material); const mesh = new THREE.Mesh(geometry, material)
mesh.updateMatrix() mesh.updateMatrix()
const shapeD = new THREE.Shape(); const shapeD = new THREE.Shape()
shapeD.moveTo(-0.744 + width + 0.02, -0.3); shapeD.moveTo(-0.744 + width + 0.02, -0.3)
shapeD.lineTo(-0.744 + width + 0.02 + 1.3, -0.3); shapeD.lineTo(-0.744 + width + 0.02 + 1.3, -0.3)
shapeD.lineTo(-0.744 + width + 0.02 + 1.3, 0.3); shapeD.lineTo(-0.744 + width + 0.02 + 1.3, 0.3)
shapeD.lineTo(-0.744 + width + 0.02, 0.3); shapeD.lineTo(-0.744 + width + 0.02, 0.3)
shape.closePath() shape.closePath()
// 拉伸轨迹线 // 拉伸轨迹线
@ -239,7 +239,7 @@ export default class Clx3dObject extends THREE.Object3D {
} }
// 创建挤出几何体 // 创建挤出几何体
const geometryD = new THREE.ExtrudeGeometry(shapeD, optionsD) const geometryD = new THREE.ExtrudeGeometry(shapeD, optionsD)
const meshD = new THREE.Mesh(geometryD, material); const meshD = new THREE.Mesh(geometryD, material)
meshD.updateMatrix() meshD.updateMatrix()
@ -254,20 +254,20 @@ export default class Clx3dObject extends THREE.Object3D {
const width = 0.08 const width = 0.08
const depth = 0.9 const depth = 0.9
const dd = 0.02 const dd = 0.02
const shape = new THREE.Shape(); const shape = new THREE.Shape()
shape.moveTo(-width/2, -depth/2 + dd); shape.moveTo(-width / 2, -depth / 2 + dd)
shape.lineTo(-width/2 + dd, -depth/2); shape.lineTo(-width / 2 + dd, -depth / 2)
shape.lineTo(width/2 - dd, -depth/2); shape.lineTo(width / 2 - dd, -depth / 2)
shape.lineTo(width/2, -depth/2 + dd); shape.lineTo(width / 2, -depth / 2 + dd)
shape.lineTo(width/2, depth/2 - dd); shape.lineTo(width / 2, depth / 2 - dd)
shape.lineTo(width/2 - dd, depth/2); shape.lineTo(width / 2 - dd, depth / 2)
shape.lineTo(-width/2 + dd, depth/2); shape.lineTo(-width / 2 + dd, depth / 2)
shape.lineTo(-width/2, depth/2 - dd); shape.lineTo(-width / 2, depth / 2 - dd)
shape.closePath() shape.closePath()
const shapeBar = new THREE.Shape(); const shapeBar = new THREE.Shape()
shapeBar.moveTo(0, 0); // 起点在圆心 shapeBar.moveTo(0, 0) // 起点在圆心
shapeBar.absarc(0, 0, 0.02, 0, Math.PI * 2, false); // 从0到π绘制半圆 shapeBar.absarc(0, 0, 0.02, 0, Math.PI * 2, false) // 从0到π绘制半圆
shapeBar.closePath() shapeBar.closePath()
const geometries: THREE.BufferGeometry[] = [] const geometries: THREE.BufferGeometry[] = []
@ -337,25 +337,25 @@ export default class Clx3dObject extends THREE.Object3D {
steps: 1, steps: 1,
bevelEnabled: false, bevelEnabled: false,
extrudePath: curveL1 extrudePath: curveL1
}); })
const geometryL2 = new THREE.ExtrudeGeometry(shape, { const geometryL2 = new THREE.ExtrudeGeometry(shape, {
steps: 1, steps: 1,
bevelEnabled: false, bevelEnabled: false,
extrudePath: curveL2 extrudePath: curveL2
}); })
const geometryL3 = new THREE.ExtrudeGeometry(shape, { const geometryL3 = new THREE.ExtrudeGeometry(shape, {
steps: 1, steps: 1,
bevelEnabled: false, bevelEnabled: false,
extrudePath: curveL3 extrudePath: curveL3
}); })
const geometryL4 = new THREE.ExtrudeGeometry(shape, { const geometryL4 = new THREE.ExtrudeGeometry(shape, {
steps: 1, steps: 1,
bevelEnabled: false, bevelEnabled: false,
extrudePath: curveL4 extrudePath: curveL4
}); })
geometries.push(geometryL1, geometryL2, geometryL3, geometryL4) geometries.push(geometryL1, geometryL2, geometryL3, geometryL4)
@ -365,8 +365,8 @@ export default class Clx3dObject extends THREE.Object3D {
private static clxPedestalGeometry: THREE.BufferGeometry = null private static clxPedestalGeometry: THREE.BufferGeometry = null
private static clxPillarGeometry: THREE.BufferGeometry = null private static clxPillarGeometry: THREE.BufferGeometry = null
private static clxForkGeometry: THREE.BufferGeometry = null private static clxForkGeometry: THREE.BufferGeometry = null
private static clxGemelGeometryL: THREE.BufferGeometry = null; private static clxGemelGeometryL: THREE.BufferGeometry = null
private static clxGemelGeometryR: THREE.BufferGeometry = null; private static clxGemelGeometryR: THREE.BufferGeometry = null
constructor(item: ItemJson, option?: RendererCudOption) { constructor(item: ItemJson, option?: RendererCudOption) {
super() super()
@ -375,22 +375,22 @@ export default class Clx3dObject extends THREE.Object3D {
Clx3dObject.clxPedestalGeometry = Clx3dObject.createClxPedestal() Clx3dObject.clxPedestalGeometry = Clx3dObject.createClxPedestal()
} }
const clxPedestalGeometry = Clx3dObject.clxPedestalGeometry const clxPedestalGeometry = Clx3dObject.clxPedestalGeometry
const clxPedestalMaterial = new THREE.MeshPhongMaterial({color: 0xffdddbca}); const clxPedestalMaterial = new THREE.MeshPhongMaterial({ color: 0xffdddbca })
const clxPedestalMesh = new THREE.Mesh(clxPedestalGeometry, clxPedestalMaterial); const clxPedestalMesh = new THREE.Mesh(clxPedestalGeometry, clxPedestalMaterial)
if (!Clx3dObject.clxPillarGeometry) { if (!Clx3dObject.clxPillarGeometry) {
Clx3dObject.clxPillarGeometry = Clx3dObject.createClxPillar() Clx3dObject.clxPillarGeometry = Clx3dObject.createClxPillar()
} }
const clxPillarGeometry = Clx3dObject.clxPillarGeometry const clxPillarGeometry = Clx3dObject.clxPillarGeometry
const clxPillarMaterial = new THREE.MeshPhongMaterial({color: 0xff6c6956}); const clxPillarMaterial = new THREE.MeshPhongMaterial({ color: 0xff6c6956 })
const clxPillarMesh = new THREE.Mesh(clxPillarGeometry, clxPillarMaterial); const clxPillarMesh = new THREE.Mesh(clxPillarGeometry, clxPillarMaterial)
if (!Clx3dObject.clxForkGeometry) { if (!Clx3dObject.clxForkGeometry) {
Clx3dObject.clxForkGeometry = Clx3dObject.createClxFork() Clx3dObject.clxForkGeometry = Clx3dObject.createClxFork()
} }
const clxForkGeometry = Clx3dObject.clxForkGeometry; const clxForkGeometry = Clx3dObject.clxForkGeometry
const clxForkMaterial = new THREE.MeshPhongMaterial({color: 0xff444444}); const clxForkMaterial = new THREE.MeshPhongMaterial({ color: 0xff444444 })
const clxForkMesh = new THREE.Mesh(clxForkGeometry, clxForkMaterial); const clxForkMesh = new THREE.Mesh(clxForkGeometry, clxForkMaterial)
clxForkMesh.name = 'clxFork' clxForkMesh.name = 'clxFork'
if (!Clx3dObject.clxGemelGeometryL) { if (!Clx3dObject.clxGemelGeometryL) {
@ -403,14 +403,14 @@ export default class Clx3dObject extends THREE.Object3D {
} }
const clxGemelGeometryR = Clx3dObject.clxGemelGeometryR const clxGemelGeometryR = Clx3dObject.clxGemelGeometryR
const clxGemelMaterial = new THREE.MeshPhongMaterial({color: 0xff555555}); const clxGemelMaterial = new THREE.MeshPhongMaterial({ color: 0xff555555 })
const clxGemelMeshL1 = new THREE.Mesh(clxGemelGeometryL, clxGemelMaterial); const clxGemelMeshL1 = new THREE.Mesh(clxGemelGeometryL, clxGemelMaterial)
clxGemelMeshL1.name = 'clxGemelMeshL1' clxGemelMeshL1.name = 'clxGemelMeshL1'
const clxGemelMeshL2 = new THREE.Mesh(clxGemelGeometryL, clxGemelMaterial); const clxGemelMeshL2 = new THREE.Mesh(clxGemelGeometryL, clxGemelMaterial)
clxGemelMeshL2.name = 'clxGemelMeshL2' clxGemelMeshL2.name = 'clxGemelMeshL2'
const clxGemelMeshR1 = new THREE.Mesh(clxGemelGeometryR, clxGemelMaterial); const clxGemelMeshR1 = new THREE.Mesh(clxGemelGeometryR, clxGemelMaterial)
clxGemelMeshR1.name = 'clxGemelMeshR1' clxGemelMeshR1.name = 'clxGemelMeshR1'
const clxGemelMeshR2 = new THREE.Mesh(clxGemelGeometryR, clxGemelMaterial); const clxGemelMeshR2 = new THREE.Mesh(clxGemelGeometryR, clxGemelMaterial)
clxGemelMeshR2.name = 'clxGemelMeshR2' clxGemelMeshR2.name = 'clxGemelMeshR2'
const d = 0 const d = 0
@ -445,7 +445,7 @@ export default class Clx3dObject extends THREE.Object3D {
this.add(clxGemelMeshR2) this.add(clxGemelMeshR2)
} }
animationShowFork(z: number): gsap.core.Tween { animationShowFork(z: number): Promise<void> {
const clxFork = this.getObjectByName('clxFork') const clxFork = this.getObjectByName('clxFork')
const clxGemelMeshL1 = this.getObjectByName('clxGemelMeshL1') const clxGemelMeshL1 = this.getObjectByName('clxGemelMeshL1')
const clxGemelMeshL2 = this.getObjectByName('clxGemelMeshL2') const clxGemelMeshL2 = this.getObjectByName('clxGemelMeshL2')
@ -523,18 +523,23 @@ export default class Clx3dObject extends THREE.Object3D {
ease: 'sine.inOut' ease: 'sine.inOut'
}) })
return gsap.to(clxFork.position, { return new Promise(resolve => {
gsap.to(clxFork.position, {
z: -z, z: -z,
duration: 3, duration: 3,
repeat: 0, repeat: 0,
ease: 'sine.inOut' ease: 'sine.inOut',
onComplete: resolve
}) })
})
} }
animationHideFork(): gsap.core.Tween {
animationHideFork(): Promise<void> {
return this.animationShowFork(0) return this.animationShowFork(0)
} }
animationUpFork(y: number): gsap.core.Tween { animationUpFork(y: number): Promise<void> {
const clxFork = this.getObjectByName('clxFork') const clxFork = this.getObjectByName('clxFork')
const clxGemelMeshL1 = this.getObjectByName('clxGemelMeshL1') const clxGemelMeshL1 = this.getObjectByName('clxGemelMeshL1')
const clxGemelMeshL2 = this.getObjectByName('clxGemelMeshL2') const clxGemelMeshL2 = this.getObjectByName('clxGemelMeshL2')
@ -566,15 +571,18 @@ export default class Clx3dObject extends THREE.Object3D {
ease: 'sine.inOut' ease: 'sine.inOut'
}) })
return gsap.to(clxFork.position, { return new Promise(resolve => {
gsap.to(clxFork.position, {
y: y, y: y,
duration: 3, duration: 3,
repeat: 0, repeat: 0,
ease: 'sine.inOut' ease: 'sine.inOut',
onComplete: resolve
})
}) })
} }
animationDownFork(): gsap.core.Tween { animationDownFork(): Promise<void> {
return this.animationUpFork(0) return this.animationUpFork(0)
} }

88
src/modules/clx/ClxEntity.ts

@ -1,5 +1,93 @@
import BaseEntity from '@/core/base/BaseItemEntity.ts' import BaseEntity from '@/core/base/BaseItemEntity.ts'
import type Viewport from '@/core/engine/Viewport.ts'
import * as THREE from 'three'
import gsap from 'gsap'
import Clx3dObject from '@/modules/clx/Clx3dObject.ts'
export default class ClxEntity extends BaseEntity { export default class ClxEntity extends BaseEntity {
constructor(viewport: Viewport, id: string) {
super(viewport, id)
}
// 抬
addArmRaise(height: number) {
// super.addArmRaise(height)
this.taskQueue.add(this.createTask('ARM_RAISE',
() => this.clxObject.animationUpFork(height)
))
}
// 降
addArmLower() {
// super.addArmLower()
this.taskQueue.add(this.createTask('ARM_LOWER',
() => this.clxObject.animationDownFork()
))
}
// 伸
addArmExtender(z: number = 1.3) {
// super.addArmExtender()
this.taskQueue.add(this.createTask('ARM_EXTEND',
() => this.clxObject.animationShowFork(z)
))
}
// 缩
addArmRetractor() {
// super.addArmRetractor()
this.taskQueue.add(this.createTask('ARM_RETRACT',
() => this.clxObject.animationHideFork()
))
}
// 装
addLoad(item: string): void {
this.taskQueue.add(this.createTask('LOAD', async () => {
// 实际业务中应包含装载逻辑
this.isCarrying = true
const arm = this.getArmObject()
this.isLoading = true
// 将物品拾取到机械臂上
const mesh = this.pickupItem(item)
const ptrForkMesh = this.getArmObject()
mesh.position.set(0, 0.1, 0)
mesh.rotation.set(0, THREE.MathUtils.degToRad(90), 0)
ptrForkMesh.add(mesh)
// 抬高20cm
gsap.to(arm.position, {
y: arm.position.y + 0.2,
duration: 0.5,
ease: 'sine.inOut',
onComplete: () => {
this.isCarrying = true
this.isLoading = false
}
})
}))
}
// 卸
addUnload(itemId: string, rackId: string, bay?: number, level?: number, cell?: number): void {
this.taskQueue.add(this.createTask('UNLOAD', async () => {
const item = this.viewport.entityManager.findItemById(itemId)
this.isCarrying = false
this.isUnloading = false
// 将物品从机械臂上卸下
this.dropItem(item, rackId, bay, level)
}))
}
get clxObject(): Clx3dObject {
return this.object as Clx3dObject
}
// 帮助方法:获取机械臂对象
getArmObject(): THREE.Object3D {
return this.clxObject.getObjectByName('clxFork')
}
} }

20
src/modules/pallet/PalletRenderer.ts

@ -2,8 +2,8 @@ import * as THREE from 'three'
import BaseRenderer from '@/core/base/BaseRenderer.ts' import BaseRenderer from '@/core/base/BaseRenderer.ts'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.ts'
import type { Object3DLike } from '@/types/ModelTypes.ts' import type { Object3DLike } from '@/types/ModelTypes.ts'
import MODULE_GLB_File from '@/assets/Models/Pallet.glb?url' import MODULE_PALLET_GLB from '@/assets/Models/Pallet.glb?url'
import MODULE_3DS_TEX from '@/assets/Models/Pallet.jpg?url' import MODULE_PALLET_TEX from '@/assets/Models/Pallet.jpg?inline'
import { loadGlbModule, loadTexture, processModel } from '@/core/ModelUtils.ts' import { loadGlbModule, loadTexture, processModel } from '@/core/ModelUtils.ts'
import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts'
@ -30,24 +30,24 @@ export default class PalletRenderer extends BaseRenderer {
init() { init() {
return Promise.all([ return Promise.all([
super.init(), super.init(),
loadGlbModule(MODULE_GLB_File), loadGlbModule(MODULE_PALLET_GLB),
loadTexture(MODULE_3DS_TEX) loadTexture(MODULE_PALLET_TEX)
]).then(([_, glbGroup, cartonTexture]) => { ]).then(([_, glbGroup, palletTexture]) => {
const mesh = glbGroup.children[0] as THREE.Mesh const mesh = glbGroup.children[0] as THREE.Mesh
this.palletGeometry = processModel(mesh) this.palletGeometry = processModel(mesh)
this.palletMaterial = new THREE.MeshPhongMaterial({ color: 0x2b5d94 }) this.palletMaterial = new THREE.MeshPhongMaterial({ color: 0x2b5d94 })
cartonTexture.flipY = true palletTexture.flipY = true
cartonTexture.wrapS = THREE.RepeatWrapping palletTexture.wrapS = THREE.RepeatWrapping
cartonTexture.wrapT = THREE.RepeatWrapping palletTexture.wrapT = THREE.RepeatWrapping
cartonTexture.repeat.set(0.5, 0.5) palletTexture.repeat.set(0.5, 0.5)
//@ts-ignore //@ts-ignore
this.palletMaterial.color.set(this.defaultUserData.color) this.palletMaterial.color.set(this.defaultUserData.color)
//@ts-ignore //@ts-ignore
this.palletMaterial.normalMap = cartonTexture this.palletMaterial.normalMap = palletTexture
}) })
} }

4
src/modules/rack/RackRenderer.ts

@ -3,8 +3,8 @@ import { BufferGeometry } from 'three'
import BaseRenderer from '@/core/base/BaseRenderer.ts' import BaseRenderer from '@/core/base/BaseRenderer.ts'
import { decimalSumBy } from '@/core/ModelUtils' import { decimalSumBy } from '@/core/ModelUtils'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.ts'
import Plastic_Rough_JPG from '@/assets/Models/Plastic_Rough.jpg' import Plastic_Rough_JPG from '@/assets/Models/Plastic_Rough.jpg?inline'
import storageBar_PNG from '@/assets/Models/storageBar.png' import storageBar_PNG from '@/assets/Models/storageBar.png?inline'
import { Material } from 'three/src/materials/Material' import { Material } from 'three/src/materials/Material'
import { InstancedMesh } from 'three/src/objects/InstancedMesh' import { InstancedMesh } from 'three/src/objects/InstancedMesh'
//@ts-ignore //@ts-ignore

4
src/modules/shuttle_rack/ShuttleRackRenderer.ts

@ -3,8 +3,8 @@ import { BufferGeometry } from 'three'
import BaseRenderer from '@/core/base/BaseRenderer.ts' import BaseRenderer from '@/core/base/BaseRenderer.ts'
import { decimalSumBy } from '@/core/ModelUtils' import { decimalSumBy } from '@/core/ModelUtils'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.ts'
import Plastic_Rough_JPG from '@/assets/Models/Plastic_Rough.jpg' import Plastic_Rough_JPG from '@/assets/Models/Plastic_Rough.jpg?inline'
import storageBar_PNG from '@/assets/Models/storageBar.png' import storageBar_PNG from '@/assets/Models/storageBar.png?inline'
import { Material } from 'three/src/materials/Material' import { Material } from 'three/src/materials/Material'
import { InstancedMesh } from 'three/src/objects/InstancedMesh' import { InstancedMesh } from 'three/src/objects/InstancedMesh'
//@ts-ignore //@ts-ignore

2
src/modules/tote/ToteRenderer.ts

@ -3,7 +3,7 @@ import BaseRenderer from '@/core/base/BaseRenderer.ts'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.ts'
import type { Object3DLike } from '@/types/ModelTypes.ts' import type { Object3DLike } from '@/types/ModelTypes.ts'
import MODULE_3DS_File from '@/assets/Models/Tote.3ds?url' import MODULE_3DS_File from '@/assets/Models/Tote.3ds?url'
import MODULE_3DS_TEX from '@/assets/Models/ToteTex.png?url' import MODULE_3DS_TEX from '@/assets/Models/ToteTex.png?inline'
import { load3DModule, loadByUrl, loadTexture, processModel } from '@/core/ModelUtils.ts' import { load3DModule, loadByUrl, loadTexture, processModel } from '@/core/ModelUtils.ts'
import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts'

4
src/modules/way/WayRenderer.ts

@ -4,8 +4,8 @@ import MoveLinePointPng from '@/assets/images/moveline_point.png'
import { createLinkPlaneMatrix4, getCargoLineId, getLinkDirection, getMatrixFromTf } from '@/core/ModelUtils.ts' import { createLinkPlaneMatrix4, getCargoLineId, getLinkDirection, getMatrixFromTf } from '@/core/ModelUtils.ts'
import Constract from '@/core/Constract.ts' import Constract from '@/core/Constract.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?inline'
import Triangle2Url from '@/assets/images/conveyor/shapes/triangle-double.png' import Triangle2Url from '@/assets/images/conveyor/shapes/triangle-double.png?inline'
import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts' import InstanceMeshManager from '@/core/manager/InstanceMeshManager.ts'
/** /**

Loading…
Cancel
Save