diff --git a/src/example/example1.js b/src/example/example1.js index 2d37c14..fc978cb 100644 --- a/src/example/example1.js +++ b/src/example/example1.js @@ -205,12 +205,12 @@ export default { }, { 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 } }, { 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: [] } }, { diff --git a/src/modules/clx/Clx3dObject.ts b/src/modules/clx/Clx3dObject.ts index a5f6c55..9594606 100644 --- a/src/modules/clx/Clx3dObject.ts +++ b/src/modules/clx/Clx3dObject.ts @@ -589,7 +589,7 @@ export default class Clx3dObject extends THREE.Object3D { return this.animationShowFork(0) } - animationUpFork(y: number): Promise { + animationUpFork(y: number, time?: number = 3): Promise { const clxFork = this.getObjectByName('clxFork') const clxGemelMeshL1 = this.getObjectByName('clxGemelMeshL1') const clxGemelMeshL2 = this.getObjectByName('clxGemelMeshL2') @@ -597,7 +597,6 @@ export default class Clx3dObject extends THREE.Object3D { const clxGemelMeshR2 = this.getObjectByName('clxGemelMeshR2') const clxForkBasePlateMesh = this.getObjectByName('clxForkBasePlateMesh') - const time = 3 gsap.to(clxGemelMeshL1.position, { y: y + 0.72, @@ -631,12 +630,31 @@ export default class Clx3dObject extends THREE.Object3D { }) return new Promise(resolve => { + const bh = 0.22 + 0.075 + const children = clxFork.children + gsap.to(clxFork.position, { y: y, duration: time, repeat: 0, 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 + } + } + } }) }) } diff --git a/src/modules/clx/ClxEntity.ts b/src/modules/clx/ClxEntity.ts index 6df043a..8d6f09f 100644 --- a/src/modules/clx/ClxEntity.ts +++ b/src/modules/clx/ClxEntity.ts @@ -43,31 +43,22 @@ export default class ClxEntity extends BaseEntity { // 装 addLoad(item: string): void { + const ptrForkMesh = this.getArmObject() 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.position.set(0, -0.05, -0.2) 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 - } - }) })) + this.taskQueue.add(this.createTask('ARM_RAISE', + ()=>this.clxObject.animationUpFork(ptrForkMesh.position.y + 0.2, 1).then(()=>{ + this.isCarrying = true + this.isLoading = false + }))) } // 卸