export function handleLClick(targetPoint) {
  // 保存进入状态
  this._saveState();
  this.clearTagsObj();
  // 全局临时标记该选中的模型;
  this.targetPoint = targetPoint;
  const worldPosition = new this.THREE.Vector3();
  //获取附着点的世界坐标系
  targetPoint.getWorldPosition(worldPosition);
  this._checkAnimation(worldPosition);

  // 设置标签位置
  this.tag3CSS2DObj.position.set(
    worldPosition.x,
    worldPosition.y,
    worldPosition.z
  );
  this.isControlOrbit(false);
  this.position = worldPosition;
  if (/tr$/.test(targetPoint.name)) {
    this.tag3CSS2DObj.translateX(3);
    this.tag3CSS2DObj.translateZ(10);
    this.tag3CSS2DObj.translateY(-5);
    intoAnimation.call(this, 4.31, -2.55, -11);
  } else if (/tl$/.test(targetPoint.name)) {
    this.tag3CSS2DObj.translateX(-3);
    this.tag3CSS2DObj.translateZ(10);
    this.tag3CSS2DObj.translateY(-5);
    intoAnimation.call(this, -4.31, -2.55, -11);
  } else if (/tc$/.test(targetPoint.name)) {
    this.tag3CSS2DObj.translateX(0);
    this.tag3CSS2DObj.translateZ(10);
    this.tag3CSS2DObj.translateY(-6);
    intoAnimation.call(this, 0, -2.55, -11);
  } else if (/br$/.test(targetPoint.name)) {
    this.tag3CSS2DObj.translateX(2);
    this.tag3CSS2DObj.translateZ(10);
    this.tag3CSS2DObj.translateY(3);
    intoAnimation.call(this, 4.31, 5, -11);
  } else if (/bl$/.test(targetPoint.name)) {
    this.tag3CSS2DObj.translateX(-2);
    this.tag3CSS2DObj.translateZ(10);
    this.tag3CSS2DObj.translateY(3);
    intoAnimation.call(this, -4.31, 5, -11);
  }
  this.scene.add(this.tag3CSS2DObj);
  // 返回给编辑组件的回调函数
  this.editDev(targetPoint);
}

function intoAnimation(x = -10, y = 3, z = -12) {
  const worldP = this.targetPoint.getWorldPosition(new this.THREE.Vector3());
  const positionOBj = this.camera.position;
  const start = this.orbitControls.target;
  this.intoPointAnimation = new this.TWEEN.Tween({
    x: positionOBj.x,
    y: positionOBj.y,
    z: positionOBj.z,
    xTarget: start.x,
    yTarget: start.y,
    zTarget: start.z,
    ctlTargetX: 0,
    ctlTargetY: 0,
    ctlTargetZ: 0,
  });
  this.intoPointAnimation.to(
    {
      x: worldP.x + x,
      y: worldP.y + y,
      z: worldP.z + z,
      xTarget: -5,
      yTarget: 8.814,
      zTarget: worldP.z + 30,
      ctlTargetX: 0,
      ctlTargetY: 0,
      ctlTargetZ: 120,
    },
    500
  );
  this.intoPointAnimation.start();
  this.intoPointAnimation.onUpdate((obj) => {
    this.camera.position.set(obj.x, obj.y, obj.z);
    this.camera.lookAt(obj.xTarget, obj.yTarget, obj.zTarget);
    // this.orbitControls.target.set(obj.x, obj.y, -obj.z);
    this.orbitControls.target.set(obj.xTarget, obj.yTarget, obj.zTarget);
  });
  this.intoPointAnimation.onComplete(() => {
    this.tag3CSS2DObj.element.style.opacity = "1";
    this.tag3CSS2DObj.element.style.display = "block";
  });
}
