@tweenjs/tween.js 动画库,定义的上下往复运动动画会在不正确的位置闪动,在(0,60,0)和(0,80,0),这个闪动要怎么解决?
createCone() {
// 四棱锥
const geometry = new THREE.ConeGeometry(10, 15, 4);
const material = new THREE.MeshBasicMaterial({ color: 0xffff00 });
const cone = new THREE.Mesh(geometry, material);
// 外线框
let lineMaterial = new THREE.LineBasicMaterial({ color: 0x0000ff });
let edgesGeometry = new THREE.EdgesGeometry(geometry);
let line = new THREE.LineSegments(edgesGeometry, lineMaterial);
line.scale.copy(cone.scale);
line.position.copy(cone.position);
line.rotation.copy(cone.rotation);
cone.add(line);
cone.position.set(0, 60, 0);
cone.rotation.x = Math.PI;
this.cone = cone;
this.scene.add(cone);
// 定义动画
new TWEEN.Tween(cone.position)
.to({ x: 0, y: 80, z: 0, }, 1000)
.repeat(Infinity)
.yoyo(true)
.easing(TWEEN.Easing.Cubic.InOut)
.start();
new TWEEN.Tween(cone.rotation)
.to({ x: cone.rotation.x, y: Math.PI*2, z: cone.rotation.z, }, 2000)
.repeat(Infinity)
.start();
}
```javascript
function animate() {
TWEEN.update();
stats.update();
controls.update();
camera.updateMatrixWorld();
renderer.render(scene, camera);
// effectComposer.render();
requestAnimationFrame(animate);
}
```