邓洁 : 隧道模型合并
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
export function handleDBLClick(e) {
|
||||
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);
|
||||
// 选中的物体闪梭(这里必需放在下一个函数之前,这里需要使用到下一个函数需要清空的上一个模型)
|
||||
// handleModelFlash(e, this);
|
||||
|
||||
// 动画完成过后自动弹出标签
|
||||
autoOutTag(e, this);
|
||||
this.listenerEventFlag = false;
|
||||
});
|
||||
}
|
||||
//点击模型视角位移过去后模型闪烁函数
|
||||
// function handleModelFlash(e, context) {
|
||||
// if (context.timer) {
|
||||
// clearInterval(context.timer);
|
||||
// context.preTargetModel.material.color.set("white");
|
||||
// }
|
||||
// context.timer = setInterval(fun, 400);
|
||||
// let flag = false;
|
||||
// function fun() {
|
||||
// if (flag) {
|
||||
// e.material.color.set("red");
|
||||
// flag = false;
|
||||
// } else {
|
||||
// e.material.color.set("white");
|
||||
// flag = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 视角移动过去自动弹出标签
|
||||
function autoOutTag(targetModel, context) {
|
||||
// 判断是否纯在设备
|
||||
// if (targetModel.hasDevice) return;
|
||||
context.preTargetModel = targetModel;
|
||||
context.tagCSS2DObj.element.style.display = "block";
|
||||
displayDevInfo(context, targetModel);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
function displayDevInfo(context, targetModel) {
|
||||
if (!targetModel.info) {
|
||||
// 因为标签内的内容共同使用所以附着点没有信心则清空信息
|
||||
// context.tagCSS2DObj.element.children[1].children[1].innerHTML = "无";
|
||||
// context.tagCSS2DObj.element.children[2].children[1].innerHTML = "无";
|
||||
return;
|
||||
}
|
||||
console.log(targetModel.info);
|
||||
context.tagCSS2DObj.element.children[1].children[1].innerHTML =
|
||||
targetModel.info.name;
|
||||
context.tagCSS2DObj.element.children[2].children[1].innerHTML =
|
||||
targetModel.info.state;
|
||||
}
|
||||
Reference in New Issue
Block a user