yuliang 6 months ago
parent
commit
1c4d9538fd
  1. 4
      src/example/example1.js
  2. 24
      src/modules/clx/Clx3dObject.ts
  3. 23
      src/modules/clx/ClxEntity.ts

4
src/example/example1.js

@ -205,12 +205,12 @@ export default {
}, },
{ {
id: '6Vu3dX1V7Si0ISWIiCkoEh', t: 'gstore', v: true, strokeWidth: 0.1, id: '6Vu3dX1V7Si0ISWIiCkoEh', t: 'gstore', v: true, strokeWidth: 0.1,
tf: [[1.5, 0.1, 0.63], [0, 0, 0], [1, 0.01, 1]], tf: [[1.5, 0.1, 0.63], [0, 90, 0], [1, 0.01, 1]],
dt: { in: [], out: [], center: [], storeWidth: 1.1 } dt: { in: [], out: [], center: [], storeWidth: 1.1 }
}, },
{ {
id: '592UY0EMScbwIyQqgs8aAs', t: 'gstore', v: true, strokeWidth: 0.1, id: '592UY0EMScbwIyQqgs8aAs', t: 'gstore', v: true, strokeWidth: 0.1,
tf: [[3.9, 0.1, 0.63], [0, 0, 0], [1, 0.01, 1]], tf: [[3.9, 0.1, 0.63], [0, 90, 0], [1, 0.01, 1]],
dt: { in: [], out: [], center: [] } dt: { in: [], out: [], center: [] }
}, },
{ {

24
src/modules/clx/Clx3dObject.ts

@ -589,7 +589,7 @@ export default class Clx3dObject extends THREE.Object3D {
return this.animationShowFork(0) return this.animationShowFork(0)
} }
animationUpFork(y: number): Promise<void> { animationUpFork(y: number, time?: number = 3): 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')
@ -597,7 +597,6 @@ export default class Clx3dObject extends THREE.Object3D {
const clxGemelMeshR2 = this.getObjectByName('clxGemelMeshR2') const clxGemelMeshR2 = this.getObjectByName('clxGemelMeshR2')
const clxForkBasePlateMesh = this.getObjectByName('clxForkBasePlateMesh') const clxForkBasePlateMesh = this.getObjectByName('clxForkBasePlateMesh')
const time = 3
gsap.to(clxGemelMeshL1.position, { gsap.to(clxGemelMeshL1.position, {
y: y + 0.72, y: y + 0.72,
@ -631,12 +630,31 @@ export default class Clx3dObject extends THREE.Object3D {
}) })
return new Promise(resolve => { return new Promise(resolve => {
const bh = 0.22 + 0.075
const children = clxFork.children
gsap.to(clxFork.position, { gsap.to(clxFork.position, {
y: y, y: y,
duration: time, duration: time,
repeat: 0, repeat: 0,
ease: 'sine.inOut', ease: 'sine.inOut',
onComplete: resolve onComplete: resolve,
onUpdate: function() {
const a = this.targets()[0]
if (a.y < 0.1 ) {
for (let i = 0; i < children.length; i++) {
const child = children[i]
child.position.y = -0.05 + 0.15 - a.y
}
}
if (a.y < bh && a.z > -1) {
console.log(a.z)
for (let i = 0; i < children.length; i++) {
const child = children[i]
child.position.y = -0.05 + bh - a.y
}
}
}
}) })
}) })
} }

23
src/modules/clx/ClxEntity.ts

@ -43,31 +43,22 @@ export default class ClxEntity extends BaseEntity {
// 装 // 装
addLoad(item: string): void { addLoad(item: string): void {
const ptrForkMesh = this.getArmObject()
this.taskQueue.add(this.createTask('LOAD', async () => { this.taskQueue.add(this.createTask('LOAD', async () => {
// 实际业务中应包含装载逻辑 // 实际业务中应包含装载逻辑
this.isCarrying = true this.isCarrying = true
const arm = this.getArmObject()
this.isLoading = true this.isLoading = true
// 将物品拾取到机械臂上 // 将物品拾取到机械臂上
const mesh = this.pickupItem(item) const mesh = this.pickupItem(item)
const ptrForkMesh = this.getArmObject() mesh.position.set(0, -0.05, -0.2)
mesh.position.set(0, 0.1, 0)
mesh.rotation.set(0, THREE.MathUtils.degToRad(90), 0) mesh.rotation.set(0, THREE.MathUtils.degToRad(90), 0)
ptrForkMesh.add(mesh) 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
}
})
})) }))
this.taskQueue.add(this.createTask('ARM_RAISE',
()=>this.clxObject.animationUpFork(ptrForkMesh.position.y + 0.2, 1).then(()=>{
this.isCarrying = true
this.isLoading = false
})))
} }
// 卸 // 卸

Loading…
Cancel
Save