69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
export function handleDBLClick(e) {
|
|
return;
|
|
this._saveSate();
|
|
// 注意位置不能改变
|
|
this.clearTagsObj();
|
|
|
|
this.preDBLModel = e;
|
|
//获取模型世界坐标位置
|
|
const modelP = new this.THREE.Vector3();
|
|
e.getWorldPosition(modelP);
|
|
this._checkAnimation(modelP);
|
|
|
|
this.setBoxHelper(e);
|
|
if (/l$/.test(e.name)) {
|
|
//匹配单个隧道左边附着点
|
|
modelP.x += 5;
|
|
modelP.y -= 5;
|
|
modelP.z += 10;
|
|
|
|
this.orbitControls.target = modelP;
|
|
this.cameraPositionTween = new this.TWEEN.Tween(this.camera.position);
|
|
this.cameraPositionTween.to(modelP, 400);
|
|
this.cameraPositionTween.start();
|
|
|
|
modelP.x -= 4;
|
|
modelP.y += 4;
|
|
modelP.z -= 20;
|
|
} else if (/r$/.test(e.name)) {
|
|
//匹配单个隧道右边附着点
|
|
modelP.x -= 5;
|
|
modelP.y -= 5;
|
|
modelP.z += 10;
|
|
this.orbitControls.target = modelP;
|
|
this.cameraPositionTween = new this.TWEEN.Tween(this.camera.position);
|
|
this.cameraPositionTween.to(modelP, 400);
|
|
this.cameraPositionTween.start();
|
|
modelP.x += 4;
|
|
modelP.y += 4;
|
|
modelP.z -= 20;
|
|
}
|
|
if (this.preTargetModel) {
|
|
this.preTargetModel.remove(this.tagCSS2DObj);
|
|
}
|
|
this.cameraPositionTween.onComplete(() => {
|
|
this.orbitControls.target = modelP;
|
|
this.camera.lookAt(modelP);
|
|
// 动画完成过后自动弹出标签
|
|
autoOutTag(e, this);
|
|
this.listenerEventFlag = false;
|
|
// 返回个组件
|
|
this.displayDevInfo(e);
|
|
});
|
|
}
|
|
|
|
// 视角移动过去自动弹出标签
|
|
function autoOutTag(targetModel, context) {
|
|
// 判断是否纯在设备
|
|
// if (targetModel.hasDevice) return;
|
|
context.preTargetModel = targetModel;
|
|
context.tagCSS2DObj.element.style.display = "block";
|
|
|
|
targetModel.add(context.tagCSS2DObj);
|
|
if (/l$/.test(targetModel.name)) {
|
|
context.tagCSS2DObj.position.set(150, 0, 700);
|
|
} else if (/r$/.test(targetModel.name)) {
|
|
context.tagCSS2DObj.position.set(-150, 0, 700);
|
|
}
|
|
}
|